user.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. echo -e '
  3. _ _
  4. | | | |___ ___ _ _
  5. | |_| (_-</ -_) ._|
  6. \___//__/\___|_|
  7. '
  8. echo -e "Create new user (you will be asked a user name and a password)"
  9. . bin/checkroot.sh
  10. sleep 3
  11. echo -n "Enter user name: "
  12. read user
  13. while [ "$user" = "" ]
  14. do
  15. read -p "enter a user name ? " user
  16. if [ "$user" != "" ]; then
  17. # check if user already exists
  18. if id "$user" >/dev/null 2>&1; then
  19. echo "user $user alreday exists, you must provide a non existing user name."
  20. user=""
  21. else
  22. read -p "is user name $user correcte [y|n] " validated
  23. if [ "$validated" = "y" ]; then
  24. break
  25. else
  26. user=""
  27. fi
  28. fi
  29. fi
  30. done
  31. # read -p "Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
  32. adduser "$user"
  33. sed -i "s/$user:\/bin\/ash/$user:\/bin\/bash/g" /etc/passwd
  34. # TODO limiting su to the admin group
  35. # echo "adding $user to admin group and limiting su to the admin group"
  36. # groupadd admin
  37. # usermod -a -G admin "$user"
  38. # allow admin group to su
  39. # dpkg-statoverride --update --add root admin 4750 /bin/su
  40. echo -e "user $user configured"