#!/bin/sh # # adduser(8) - add a user to the system # VERSION="#VERSION#" usage(){ echo "Usage: adduser [USERNAME]... [OPTION]..." echo "Add a user to the system using the standard bash shell and" echo "install some default settings for the user." echo echo " -s, --skippass don't set the password" echo " -h, --help print this help and exit" echo " -v, --version output version information and exit" echo echo "Report bugs to ." exit 0 } displayversion(){ echo "adduser (rltools) $VERSION" exit 0 } if [ ! "$UID" = 0 ]; then echo "adduser: you must be root to add users." exit 1 fi if [ "$1" = "-h" -o "$1" = "--help" ]; then usage fi if [ "$1" = "-v" -o "$1" = "--version" ]; then displayversion fi if [ "$1" = "" ]; then echo -n "New user's name: " read user else if [ "$1" = "-s" ]; then echo "adduser: first argument must be the username." exit 1 fi user=$1 fi if [ -z "$user" ]; then echo "adduser: no username specificed." exit 1 else mkdir -p /home/$user 2>/dev/null >/dev/null useradd -g users -s /bin/bash -d /home/$user $user fi for i in $1 $2 $3 $4; do if [ "$i" = "-s" ]; then nopass=true break fi done if [ ! -z "$nopass" ]; then passwd -q $user fi if ( which startkde >/dev/null 2>/dev/null ); then cp -r /usr/share/rl/defset/.kde /home/$user fi cp /usr/share/rl/defset/.bash_logout /home/$user cp /usr/share/rl/defset/.bashrc /home/$user cp /usr/share/rl/defset/.bash_profile /home/$user cp /usr/share/rl/defset/.inputrc /home/$user # Set permissions chmod 644 /home/$user -R if [ -d /home/$user/.kde ]; then chmod 700 /home/$user/.kde -R fi chown $user.users /home/$user -R chmod 700 /home/$user # EOF