Advertisement
Guest User

Untitled

a guest
May 28th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.98 KB | None | 0 0
  1.  elif [ "$CURRENT_SELECTION" = "User-Name" ]; then
  2.                 if [ $(id -u) -eq 0 ]; then
  3.                     DIALOG --inputbox  "Enter username : " 25 100 {username}
  4.                     DIALOG --inputbox  "Enter password : " 25 100 {password}
  5.                     chroot ${DESTDIR} egrep "^$username" /etc/passwd >/dev/null
  6.                 if [ $? -eq 0 ]; then
  7.                     DIALOG --msgbox "$username exists!" 25 100
  8.                     exit 1
  9.                 else
  10.                     pass=$(perl -e'print crypt("$password", "aa")')
  11.                     chroot ${DESTDIR} useradd -m -G adm,wheel,floppy,scanner,power,locate,camera,storage,optical,audio,video,network,avahi  -p $pass $username
  12.                     cp -r /etc/skel/* ${DESTDIR}/home/$username
  13.                     [ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
  14.                 fi
  15.                     else
  16.                 DIALOG --msgbox  "Only root may add a user to the system" 25 100
  17.                 exit 2
  18.                 fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement