check for user in vhost and user creation
This commit is contained in:
parent
6e5433b041
commit
c5a8b8b87b
@ -7,29 +7,29 @@ _cwd="$(pwd)"
|
|||||||
|
|
||||||
while [ "$_bare_name" = "" ]
|
while [ "$_bare_name" = "" ]
|
||||||
do
|
do
|
||||||
read -p "enter the bare repos folder name ? " _bare_name
|
read -p "enter the bare repos folder name ? " _bare_name
|
||||||
if [ "$_bare_name" != "" ]; then
|
if [ "$_bare_name" != "" ]; then
|
||||||
read -p "is bare folder name $_bare_name correcte [y|n] " validated
|
read -p "is bare folder name $_bare_name correcte [y|n] " validated
|
||||||
if [ "$validated" = "y" ]; then
|
if [ "$validated" = "y" ]; then
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
_bare_name=""
|
_bare_name=""
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
while [ "$_prod_folder_path" = "" ]
|
while [ "$_prod_folder_path" = "" ]
|
||||||
do
|
do
|
||||||
read -p "enter the prod folder path (must be a public_html parent's) ? " _prod_folder_path
|
read -p "enter the prod folder path (must be a public_html parent's) ? " _prod_folder_path
|
||||||
if [ "$_prod_folder_path" != "" ]; then
|
if [ "$_prod_folder_path" != "" ]; then
|
||||||
# TODO check if path exists
|
# TODO check if path exists
|
||||||
read -p "is prod folder path $_prod_folder_path correcte [y|n] " validated
|
read -p "is prod folder path $_prod_folder_path correcte [y|n] " validated
|
||||||
if [ "$validated" = "y" ]; then
|
if [ "$validated" = "y" ]; then
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
_prod_folder_path=""
|
_prod_folder_path=""
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# ask for simple php conf or drupal conf
|
# ask for simple php conf or drupal conf
|
||||||
|
22
bin/user.sh
22
bin/user.sh
@ -16,10 +16,28 @@ fi
|
|||||||
|
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|
||||||
# TODO check if root
|
|
||||||
|
|
||||||
echo -n "Enter user name: "
|
echo -n "Enter user name: "
|
||||||
read user
|
read user
|
||||||
|
while [ "$user" = "" ]
|
||||||
|
do
|
||||||
|
read -p "enter a user name ? " user
|
||||||
|
if [ "$user" != "" ]; then
|
||||||
|
# check if user already exists
|
||||||
|
if id "$user" >/dev/null 2>&1; then
|
||||||
|
echo "user $user alreday exists, you must provide a non existing user name."
|
||||||
|
user=""
|
||||||
|
else
|
||||||
|
read -p "is user name $user correcte [y|n] " validated
|
||||||
|
if [ "$validated" = "y" ]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
user=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
# read -p "Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
|
# read -p "Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
|
||||||
adduser "$user"
|
adduser "$user"
|
||||||
echo "adding $user to admin group and limiting su to the admin group"
|
echo "adding $user to admin group and limiting su to the admin group"
|
||||||
|
46
bin/vhost.sh
46
bin/vhost.sh
@ -9,9 +9,9 @@ echo '\033[35m
|
|||||||
echo "\033[35;1mNginx VHOST install \033[0m"
|
echo "\033[35;1mNginx VHOST install \033[0m"
|
||||||
while [ "$vh" != "y" ] && [ "$vh" != "n" ]
|
while [ "$vh" != "y" ] && [ "$vh" != "n" ]
|
||||||
do
|
do
|
||||||
echo -n "Should we install a vhost? [y|n] "
|
echo -n "Should we install a vhost? [y|n] "
|
||||||
read vh
|
read vh
|
||||||
# vh=${vh:-y}
|
# vh=${vh:-y}
|
||||||
done
|
done
|
||||||
if [ "$vh" = "y" ]; then
|
if [ "$vh" = "y" ]; then
|
||||||
|
|
||||||
@ -84,10 +84,44 @@ if [ "$vh" = "y" ]; then
|
|||||||
|
|
||||||
# create a shortcut to the site
|
# create a shortcut to the site
|
||||||
# TODO ask for $user name if not existing
|
# TODO ask for $user name if not existing
|
||||||
mkdir /home/"$user"/www/
|
|
||||||
chown "$user":admin /home/"$user"/www/
|
|
||||||
ln -s /var/www/"$_domain" /home/"$user"/www/"$_domain"
|
|
||||||
|
|
||||||
|
echo -n "Should we install a shortcut for a user? [Y|n] "
|
||||||
|
read yn
|
||||||
|
yn=${yn:-y}
|
||||||
|
if [ "$yn" = "y" ]; then
|
||||||
|
if [ -z ${user+x} ]; then
|
||||||
|
echo -n "Enter an existing user name: "
|
||||||
|
read user
|
||||||
|
while [ "$user" = "" ]
|
||||||
|
do
|
||||||
|
read -p "enter a user name ? " user
|
||||||
|
if [ "$user" != "" ]; then
|
||||||
|
check if user already exists
|
||||||
|
if id "$user" >/dev/null 2>&1; then
|
||||||
|
read -p "is user name $user correcte [y|n] " validated
|
||||||
|
if [ "$validated" = "y" ]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
user=""
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "user $user doesn't exists, you must provide an existing user"
|
||||||
|
user=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "shortcut will be installed for '$user'";
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
mkdir /home/"$user"/www/
|
||||||
|
chown "$user":admin /home/"$user"/www/
|
||||||
|
ln -s /var/www/"$_domain" /home/"$user"/www/"$_domain"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo 'no shortcut installed'
|
||||||
|
fi
|
||||||
# activate the vhost
|
# activate the vhost
|
||||||
ln -s /etc/nginx/sites-available/"$_domain".conf /etc/nginx/sites-enabled/"$_domain".conf
|
ln -s /etc/nginx/sites-available/"$_domain".conf /etc/nginx/sites-enabled/"$_domain".conf
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user