user.sh 750 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/sh
  2. echo '\033[35m
  3. __ _______ __________
  4. / / / / ___// ____/ __ \
  5. / / / /\__ \/ __/ / /_/ /
  6. / /_/ /___/ / /___/ _, _/
  7. \____//____/_____/_/ |_|
  8. \033[0m'
  9. echo "\033[35;1mCreate new user (you will be asked a user name and a password) \033[0m"
  10. if [ "$EUID" -ne 0 ]; then
  11. echo "Please run as root"
  12. exit
  13. fi
  14. sleep 3
  15. # TODO check if root
  16. echo -n "Enter user name: "
  17. read user
  18. # read -p "Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
  19. adduser "$user"
  20. echo "adding $user to admin group and limiting su to the admin group"
  21. groupadd admin
  22. usermod -a -G admin "$user"
  23. # allow admin group to su
  24. dpkg-statoverride --update --add root admin 4750 /bin/su
  25. echo "\033[92;1muser $user configured\033[Om"