change jail flag, defaults to enabled

This commit is contained in:
Matthew Saunders Brown 2023-05-04 17:00:35 -07:00
parent 6850a5b6e2
commit fa65c5dac2
2 changed files with 15 additions and 6 deletions

View File

@ -13,14 +13,14 @@ help()
thisfilename=$(basename -- "$0")
echo "Add virtualhost to this server, including shell user and MySQL database."
echo ""
echo "usage: $thisfilename -d <domain> [-u <username>] [-p <password>] [-x <fpmmax>] [-j] [-w] [-h]"
echo "usage: $thisfilename -d <domain> [-u <username>] [-p <password>] [-x <fpmmax>] [-j <0|1>] [-w] [-h]"
echo ""
echo " -h Print this help."
echo " -d <domain> Domain name of VirtualHost to remove."
echo " -u <username> Username to use for this virtualhost. Optional, defaults to first 8 alphanumeric characters of virtualhost."
echo " -p <password> Password for username. Optional, random password generated if none specified."
echo " -x <fpmmax> PHP-FPM pm.max_children. Optional, defaults to 4, recommended range 2-12 on Shared Server."
echo " -j Whether or not to jail the user. Optional, default is to not jail user."
echo " -j <0|1> Whether or not to jail the user. 0 = no, 1 = yes. Default is 1, which can be overriden in main config."
echo " -w Write user & mysql info to files."
exit
}
@ -103,8 +103,12 @@ if ! grep -q "^$username:" /etc/passwd; then
else
/usr/local/bin/vhost-user-add.sh -u $username -p "$password" -x $fpmmax
fi
# if jail option is set then jail user
if [[ -n $jail ]]; then
# check for and set jail option
if [[ -z $jail ]]; then
jail=$JAIL_USER
fi
# if jail option is yes (1) then jail user
if [[ $jail == 1 ]]; then
# job is run in the background as it can take about 1 minute to complete
/usr/local/bin/vhost-user-jail.sh -u $username >/dev/null 2>/dev/null &
# pause to give above script time to create jail home dir which is used by vhost-add.sh below

View File

@ -13,6 +13,7 @@ fi
# constants
FPM_MAX=4
JAIL_USER=1
# functions
@ -87,8 +88,12 @@ function vhost:getoptions () {
u ) # username
username=${OPTARG,,}
;;
j ) # jail - if enabled user will be jailed
jail=true
j ) # jail - Whether or not to jail the user. 0 = no, 1 = yes.
jail=${OPTARG}
if [[ $jail != "0" ]] && [[ $jail != "1" ]]; then
echo "ERROR: Invalid jail setting: -j $jail."
exit 1
fi
;;
n ) # dry-run
dryrun=true