diff --git a/debian-add-user.sh b/debian-add-user.sh index 80522e6..2e2cf54 100755 --- a/debian-add-user.sh +++ b/debian-add-user.sh @@ -28,10 +28,17 @@ sed -i "s|/home/$NewUser:/bin/sh$|/home/$NewUser:/bin/bash|g" /etc/passwd # Debian 9 default to empty sed -i "s|/home/$NewUser:$|/home/$NewUser:/bin/bash|g" /etc/passwd -echo "=== Allow the new user $NewUser to sudo without password" -#usermod -a -G sudo $NewUser # Add to sudo group # Option 1: add user to %sudo group -echo "$NewUser ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/${NewUser//./-} # Option 2: add a user file into /etc/sudoers.d/ -chmod a-w /etc/sudoers.d/${NewUser//./-} +echo "=== Allow the new user $NewUser to sudo without password? for yes, <> for no" +read -p ">>> " AllowSudo +if [ $AllowSudo ] && [ $AllowSudo == "y" ] +then + #usermod -a -G sudo $NewUser # Add to sudo group # Option 1: add user to %sudo group + echo "$NewUser ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/${NewUser//./-} # Option 2: add a user file into /etc/sudoers.d/ + chmod a-w /etc/sudoers.d/${NewUser//./-} + echo "Added /etc/sudoers.d/${NewUser//./-} to allow sudo without password" +else + echo "--- Nothing changed." +fi echo # 注意,由 root 为新用户创建的配置文件的 owner 是 root,而不是新用户 @@ -40,8 +47,8 @@ then source /faronear/fon/sysconfig/home-config.sh /faronear/fon/sysconfig/nixhome /home/$NewUser else echo "=== Configure $NewUser home with standard scripts? for yes, <> for no" - read -p ">>> " YesOrNo - if [ $YesOrNo ] && [ $YesOrNo = 'y' ] + read -p ">>> " ConfigHome + if [ $ConfigHome ] && [ $ConfigHome = 'y' ] then source /faronear/fon/sysconfig/home-config.sh /faronear/fon/sysconfig/nixhome /home/$NewUser else