check for user in vhost and user creation
This commit is contained in:
parent
6e5433b041
commit
c5a8b8b87b
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"
|
||||||
|
34
bin/vhost.sh
34
bin/vhost.sh
@ -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
|
||||||
|
|
||||||
|
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/
|
mkdir /home/"$user"/www/
|
||||||
chown "$user":admin /home/"$user"/www/
|
chown "$user":admin /home/"$user"/www/
|
||||||
ln -s /var/www/"$_domain" /home/"$user"/www/"$_domain"
|
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