diff --git a/bin/vhost-deploy.sh b/bin/vhost-deploy.sh index 7151a6e..e58472a 100755 --- a/bin/vhost-deploy.sh +++ b/bin/vhost-deploy.sh @@ -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 [-u ] [-p ] [-x ] [-j] [-w] [-h]" + echo "usage: $thisfilename -d [-u ] [-p ] [-x ] [-j <0|1>] [-w] [-h]" echo "" echo " -h Print this help." echo " -d Domain name of VirtualHost to remove." echo " -u Username to use for this virtualhost. Optional, defaults to first 8 alphanumeric characters of virtualhost." echo " -p Password for username. Optional, random password generated if none specified." echo " -x 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 diff --git a/bin/vhost.sh b/bin/vhost.sh index f6c68a1..49fa143 100755 --- a/bin/vhost.sh +++ b/bin/vhost.sh @@ -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