Browse Source

add shellcheck compliance

master
Simon Vieille 3 months ago
parent
commit
153ec73aa3
Signed by: Simon Vieille <simon@deblan.fr> GPG Key ID: 03383D15A1D31745
3 changed files with 21 additions and 12 deletions
  1. 19
    8
      bin/vhost-add
  2. 1
    3
      share/bin/form_choices
  3. 1
    1
      share/bin/form_input

+ 19
- 8
bin/vhost-add View File

@@ -1,8 +1,12 @@
#!/bin/sh

export SCRIPT_NAME="$(realpath "$0")"
export SCRIPT_PATH="$(dirname "$SCRIPT_NAME")"
export PATH="$SCRIPT_PATH/../share/bin/:$PATH"
SCRIPT_NAME="$(realpath "$0")"
SCRIPT_PATH="$(dirname "$SCRIPT_NAME")"
PATH="$SCRIPT_PATH/../share/bin/:$PATH"

export SCRIPT_NAME
export SCRIPT_PATH
export PATH

cd "$SCRIPT_PATH/../"

@@ -11,7 +15,7 @@ cd "$SCRIPT_PATH/../"
exit_if_empty() {
if [ -z "$1" ]; then
if [ -n "$2" ]; then
printf "$2\n"
printf "%s\\n" "$2"
fi

exit 1
@@ -33,7 +37,7 @@ DOMAIN_ALIASES="$(form_input -t "$TITLE" -l "Aliase(s)")"
WEB_HTTP="$(form_yes_no -t "$TITLE" -l "Support of HTTP (recommanded)")"
WEB_HTTPS="$(form_yes_no -t "$TITLE" -l "Support of HTTPS (recommanded)")"

if [ "$WEB_HTTP" = "yes" -a "$WEB_HTTPS" = "yes" ]; then
if [ "$WEB_HTTP" = "yes" ] && [ "$WEB_HTTPS" = "yes" ]; then
WEB_HTTPS_FORCE="$(form_yes_no -t "$TITLE" -l "Redirect HTTP to HTTPS (recommanded)")"
fi

@@ -61,7 +65,14 @@ USER_PASSWORD="$(tr -dc "12345!@#$%qwertQWERTasdfgASDFGzxcvbZXCVB" < /dev/urando

SYSTEM_USER_USERNAME="$(form_input -t "$TITLE" -l "System username" -d "web" -r)"
SYSTEM_USER_GROUP="webgroup"
SYSTEM_USER_PASSWORD=$(export PASSWORD="$USER_PASSWORD"; export SALT=$(date +'%S'); crypt)

SYSTEM_USER_PASSWORD=$(
PASSWORD="$USER_PASSWORD"
SALT=$(date +'%S')
export PASSWORD
export SALT
crypt
)

exit_if_empty "$SYSTEM_USER_USERNAME" "Aborded! (SYSTEM_USERNAME_EMPTY)"

@@ -89,7 +100,7 @@ rm "$TMP_FILE"
CONTINUE="$(form_yes_no -t "$TITLE" -l "Do you confirm?")"

if [ "$CONTINUE" = "no" ]; then
printf "Aborded!\n"
printf "Aborded!\\n"

exit 0
fi
@@ -109,7 +120,7 @@ chmod o-r "/services/web/www/$DOMAIN"
SERVICES_TO_RELOAD="apache2"

SYSTEM_USER_ID="$(id -u "$SYSTEM_USER_USERNAME")"
PHP_FPM_PORT=$(($SYSTEM_USER_ID + 12000))
PHP_FPM_PORT=$((SYSTEM_USER_ID + 12000))

if [ "$WEB_HTTP" = "yes" ]; then
VHOST_FILE_SA="/etc/apache2/sites-available/${DOMAIN}.${WEB_HTTP_PORT}.conf"

+ 1
- 3
share/bin/form_choices View File

@@ -7,8 +7,6 @@ HEIGHT=25
MENU_HEIGHT=16
WIDTH=50

PARAMS=

while getopts "t:l:d:h:w:m:r" option; do
case "$option" in
l) LABEL="$OPTARG";;
@@ -27,4 +25,4 @@ fi

shift $((OPTIND-1))

echo "$(whiptail --title "$TITLE" --menu "$LABEL" $HEIGHT $WIDTH $MENU_HEIGHT "$@" 3>&1 1>&2 2>&3)"
whiptail --title "$TITLE" --menu "$LABEL" $HEIGHT $WIDTH $MENU_HEIGHT "$@" 3>&1 1>&2 2>&3

+ 1
- 1
share/bin/form_input View File

@@ -33,7 +33,7 @@ while [ $DO_ASK -eq 1 ]; do
STATUS=$?

if [ $STATUS -eq 0 ]; then
if [ $REQUIRED -eq 1 -a -z "$VALUE" ]; then
if [ $REQUIRED -eq 1 ] && [ -z "$VALUE" ]; then
DO_ASK=1
else
DO_ASK=0

Loading…
Cancel
Save