From 8619d41265954818b1ce6cc7d75f669ac5c19f09 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Fri, 30 Aug 2019 08:10:56 +0000 Subject: [PATCH] Update adduser.sh to handle incorrect arguments --- scripts/adduser.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/adduser.sh b/scripts/adduser.sh index 52c2428..15f8510 100755 --- a/scripts/adduser.sh +++ b/scripts/adduser.sh @@ -4,8 +4,24 @@ ## Syntax: ./adduser.sh ## ############################################################################### +if [ "$#" -ne 2 ]; then + printf "Illegal number of parameters." + printf "\nUsage: sudo ./adduser.sh " + printf "\n\nAvailable groupd IDs:" + printf "\n60001......61183 Unused | 65520...............65533 Unused" + printf "\n65536.....524287 Unused | 1879048191.....2147483647 Unused\n" + exit +fi + sudo adduser $1 --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password --uid $2 +printf "\nEnter 1 if $1 should have sudo privileges. Any other value will continue and make no changes\n" +read choice +if [ $choice -eq 1 ] ; then +printf "\nConfiguring sudo for $1...\n" +sudo usermod -G sudo $1 +fi + printf "\nEnter 1 to set a password for $1, any other value will exit with no password set\n" read choice @@ -14,6 +30,3 @@ printf "\nChanging password for $1...\n" sudo passwd $1 fi -printf "\nRun the following command to remove a user -\n" -printf "\nsudo userdel -r \n" -