Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECISION=yes
- while [ "$DECISION" = 'yes' ]; do
- echo Please, enter the users first name.
- read FNAME
- echo Please, enter the users last name.
- read LNAME
- echo Please, enter the users initial group.
- read IGROUP
- echo Please, enter any additional groups the user belongs to.
- read AGROUP
- IGROUPL=`echo $IGROUP | tr [:upper:] [:lower:]`
- AGROUPL=`echo $AGROUP | tr [:upper:] [:lower:]`
- LNAMEU=`echo $LNAME | tr [:lower:] [:upper:]`
- FNAMEU=`echo $FNAME | tr [:lower:] [:upper:]`
- USRNM1=`echo $LNAME | tr [:upper:] [:lower:]`
- USRNM2=`echo $FNAME | cut -c 1 | tr [:upper:] [:lower:]`
- USRNM=$USRNM1$USRNM2
- useradd -c "$FNAMEU $LNAMEU" -g $IGROUPL -G $AGROUPL $USRNM
- echo 123456 | passwd $USRNM --stdin
- if getent passwd "$username" >/dev/null; then
- for i in {1..50}; do
- getent passwd "$username$i" >/dev/null || { username="$username$i; break; };
- done;
- fi
- echo "Would you like to add another user?(yes/no)"
- read YESNO
- DECISION=`echo $YESNO | tr [:upper:] [:lower:]`
- DONELOOP=1
- while [ "$DONELOOP" -eq "1" ]; do
- if [ $DECISION == 'yes' ]; then
- DECISION=yes
- DONELOOP=2
- elif [ "$DECISION" == "no" ]; then
- echo "Thank you for using this program"
- DONELOOP=2
- else
- echo "Please use a correct option.(yes/no)"
- read YESNO
- DECISION=`echo $YESNO | tr [:upper:] [:lower:]`
- fi
- done
- done
Advertisement
Add Comment
Please, Sign In to add comment