Paste #137423

   
pasted on 02.07.2020 15:47
  • Edit to this paste
  • Print
  • Raw
  • Compare with paste
    #  
  • Toggle line numbers
  • Syntax highlighting  
Text paste
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#cat /etc/passwd | grep ${username} >/dev/null 2>&1
#if [ $? -eq 0 ] ; then
#    echo -e "\e[1;38m user $username already exists, quit." || exit 1
#else
#    read -e -p "User $username doesn't exist, would you like to create? Answer with y/n. `echo $'\n--> '`" choice 
#    case "$choice" in
#	y) echo -e "\e[1;33m creating user $username \e[0m"; exec useradd -m $username; ;;
#	n) exit 1; ;;
#	*) echo "Invalid, please answer with y/n."; ;;
#    esac
#
#    read -e -p "Would you like to create specific user directories (php56 php71 php73 publick_html ssl tmp)? Answer with y/n. `echo $'\n--> '`" userdirs
#    case "$userdirs" in
#	y) echo -e "\e[1;33m creating specific user directories for $username \e[0m"; exec mkdir /home/${username}/ ;;
#	n) exit 1; ;;
#	*) echo "Invalid, please answer with y/n."; ;;
#    esac
#fi


if id -u ${username} &>> /dev/null; then echo -e "\e[1;38m user $username already exists, quit."; exit 1;
else
    read -e -p "User ${username} does not exist, would you like to create? [y/n]: " -i "y" choice
    case "$choice" in
	y) echo -e "\e[1;33m creating user ${username} \e[0m"; useradd -m "${username}"; ;;
	n) exit 1; ;;
	*) echo "Invalid, please answer with y/n."; ;;
    esac

    read -e -p "Would you like to create user directories php56 php71 php73 publick_html ssl and tmp? [y/n]:  " -i "y" userdirs
    case "$userdirs" in
	y) echo -e "\e[1;33m creating specific user directories for ${username} \e[0m"; mkdir -p "/home/${username}"; ;;
	n) exit 1; ;;
	*) echo "Invalid, please answer with y/n."; ;;
    esac
fi
Add Comment
Author