valis

Untitled

Apr 19th, 2011
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.37 KB | None | 0 0
  1. DECISION=yes
  2.    
  3.     while [ "$DECISION" = 'yes' ]; do
  4.  
  5.     echo Please, enter the users first name.
  6.         read FNAME
  7.     echo Please, enter the users last name.
  8.         read LNAME
  9.     echo Please, enter the users initial group.
  10.         read IGROUP
  11.     echo Please, enter any additional groups the user belongs to.
  12.         read AGROUP
  13.  
  14. IGROUPL=`echo $IGROUP | tr [:upper:] [:lower:]`
  15. AGROUPL=`echo $AGROUP | tr [:upper:] [:lower:]`
  16. LNAMEU=`echo $LNAME | tr [:lower:] [:upper:]`
  17. FNAMEU=`echo $FNAME | tr [:lower:] [:upper:]`
  18. USRNM1=`echo $LNAME | tr [:upper:] [:lower:]`
  19. USRNM2=`echo $FNAME | cut -c 1 | tr [:upper:] [:lower:]`
  20. USRNM=$USRNM1$USRNM2
  21.  
  22.     useradd -c "$FNAMEU $LNAMEU" -g $IGROUPL -G $AGROUPL $USRNM
  23.     echo 123456 | passwd $USRNM --stdin
  24.  
  25.         if getent passwd "$username" >/dev/null; then
  26.             for i in {1..50}; do
  27.             getent passwd "$username$i" >/dev/null || { username="$username$i; break; };
  28.             done;
  29.         fi
  30.    
  31.     echo "Would you like to add another user?(yes/no)"
  32.         read YESNO
  33.         DECISION=`echo $YESNO | tr [:upper:] [:lower:]`
  34.  
  35.     DONELOOP=1
  36.         while [ "$DONELOOP" -eq "1" ]; do
  37.             if [ $DECISION == 'yes' ]; then
  38.                 DECISION=yes
  39.     DONELOOP=2
  40.         elif [ "$DECISION" == "no" ]; then
  41.             echo "Thank you for using this program"
  42.     DONELOOP=2
  43.         else
  44.             echo "Please use a correct option.(yes/no)"
  45.                 read YESNO
  46.             DECISION=`echo $YESNO | tr [:upper:] [:lower:]`
  47.         fi
  48.     done
  49. done
Advertisement
Add Comment
Please, Sign In to add comment