48
install_shell/create_users.sh
Executable file
48
install_shell/create_users.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
. ./check_function.sh
|
||||
#$1:user name,$2:home directory,$3:shell type
|
||||
#examples :
|
||||
#d5000 /home/d5000/guodiao tcsh
|
||||
#kingsoft /home/kingsoft/guodiao bash
|
||||
#ems /users/ems tcsh
|
||||
USER_SHELL=$3
|
||||
USER_HOME=$2
|
||||
USER_NAME=$1
|
||||
# check $USER_NAME group
|
||||
GRP_CONFIG=/etc/group
|
||||
check_config $GRP_CONFIG ^${USER_NAME}
|
||||
if [ $rtn -eq 2 ]; then
|
||||
groupadd ${USER_NAME}
|
||||
elif [ $rtn -eq 0 ]; then
|
||||
echo "${USER_NAME} group exist..."
|
||||
fi
|
||||
|
||||
# check ${USER_NAME}
|
||||
USER_CONFIG=/etc/passwd
|
||||
|
||||
check_config $USER_CONFIG ${USER_NAME}
|
||||
if [ $rtn -eq 2 ]; then
|
||||
mkdir -p ${USER_HOME}
|
||||
useradd -m -d ${USER_HOME} -s /bin/${USER_SHELL} ${USER_NAME}
|
||||
usermod -p `openssl passwd ${USER_NAME}` -g ${USER_NAME} -G audio,tty ${USER_NAME}
|
||||
elif [ $rtn -eq 0 ]; then
|
||||
usermod -g ${USER_NAME} -G audio,tty ${USER_NAME}
|
||||
echo "${USER_NAME} user exist..."
|
||||
fi
|
||||
|
||||
# check ${USER_NAME} home
|
||||
|
||||
check_konsole $USER_HOME
|
||||
check_konsole $HOME
|
||||
|
||||
ln -sf /bin/tcsh /bin/csh
|
||||
cp -r root-kde/.kde $HOME/
|
||||
cp -r d5000-kde/.kde $USER_HOME/
|
||||
#cp -r /etc/skel/.kde $USER_HOME/
|
||||
cp -r d5000-fcitx/.config $USER_HOME/
|
||||
chown -R ${USER_NAME}:${USER_NAME} ${USER_HOME}
|
||||
cp bash_profile /etc/skel/.bash_profile
|
||||
|
||||
usermod -p `openssl passwd root` root
|
||||
Reference in New Issue
Block a user