user.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. echo -e '\033[35m
  3. __ _______ __________
  4. / / / / ___// ____/ __ \
  5. / / / /\__ \/ __/ / /_/ /
  6. / /_/ /___/ / /___/ _, _/
  7. \____//____/_____/_/ |_|
  8. \033[0m'
  9. echo -e "\033[35;1mCreate new user (you will be asked a user name and a password) \033[0m"
  10. . checkroot.sh
  11. sleep 3
  12. echo -n "Enter user name: "
  13. read user
  14. while [ "$user" = "" ]
  15. do
  16. read -p "enter a user name ? " user
  17. if [ "$user" != "" ]; then
  18. # check if user already exists
  19. if id "$user" >/dev/null 2>&1; then
  20. echo "user $user alreday exists, you must provide a non existing user name."
  21. user=""
  22. else
  23. read -p "is user name $user correcte [y|n] " validated
  24. if [ "$validated" = "y" ]; then
  25. break
  26. else
  27. user=""
  28. fi
  29. fi
  30. fi
  31. done
  32. # read -p "Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
  33. adduser "$user"
  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 "\033[92;1muser $user configured\033[Om"