Browse Source

add confirmation box and final result screen

master
Simon Vieille 3 months ago
parent
commit
8a2117a423
Signed by: Simon Vieille <simon@deblan.fr> GPG Key ID: 03383D15A1D31745
3 changed files with 53 additions and 13 deletions
  1. 38
    13
      bin/vhost-add
  2. 2
    0
      src/templates/result.twig
  3. 13
    0
      src/templates/summary.twig

+ 38
- 13
bin/vhost-add View File

@@ -65,6 +65,35 @@ SYSTEM_USER_PASSWORD=$(export PASSWORD="$USER_PASSWORD"; export SALT=$(date +'%S

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

################
# Confirmation #
################

export DOMAIN
export DOMAIN_ALIASES
export DOCUMENT_ROOT
export SYSTEM_USER_USERNAME
export SYSTEM_USER_GROUP
export PHP_ENABLED
export PHP_VERSION
export WEB_HTTP
export WEB_HTTPS
export WEB_HTTPS_FORCE

TMP_FILE="/tmp/vhost-add-$(tr -dc "qwertQWERTasdfgASDFGzxcvbZXCVB" < /dev/urandom | head -c 16)"
template summary > "$TMP_FILE"
chmod 600 "$TMP_FILE"
whiptail --textbox "$TMP_FILE" 20 80
rm "$TMP_FILE"

CONTINUE="$(form_yes_no -t "$TITLE" -l "Do you confirm?")"

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

exit 0
fi

###############################
# User and directory creation #
###############################
@@ -82,15 +111,6 @@ SERVICES_TO_RELOAD="apache2"
SYSTEM_USER_ID="$(id -u "$SYSTEM_USER_USERNAME")"
PHP_FPM_PORT=$(($SYSTEM_USER_ID + 12000))

export DOMAIN
export DOMAIN_ALIASES
export DOCUMENT_ROOT
export SYSTEM_USER_USERNAME
export SYSTEM_USER_GROUP
export PHP_ENABLED
export PHP_FPM_PORT
export WEB_HTTPS_FORCE

if [ "$WEB_HTTP" = "yes" ]; then
VHOST_FILE_SA="/etc/apache2/sites-available/${DOMAIN}.${WEB_HTTP_PORT}.conf"
VHOST_FILE_SE="/etc/apache2/sites-enabled/${DOMAIN}.${WEB_HTTP_PORT}.conf"
@@ -117,6 +137,8 @@ if [ "$PHP_ENABLED" = "yes" ]; then
PHP_FPM_FILE="/etc/php/$PHP_VERSION/fpm/pool.d/${SYSTEM_USER_USERNAME}.conf"
fi

export PHP_FPM_PORT

template php-fpm > "$PHP_FPM_FILE"
fi

@@ -124,7 +146,10 @@ for SERVICE in $SERVICES_TO_RELOAD; do
service $SERVICE reload
done

printf "┌──────────────────────────────────────────┐\n"
printf "│ Nom d'utilisateur : %-20s │\n" "$SYSTEM_USER_USERNAME"
printf "│ Mot de passe : %-25s │\n" "$USER_PASSWORD"
printf "└──────────────────────────────────────────┘\n"
export USER_PASSWORD

TMP_FILE="/tmp/vhost-add-$(tr -dc "qwertQWERTasdfgASDFGzxcvbZXCVB" < /dev/urandom | head -c 16)"
template result > "$TMP_FILE"
chmod 600 "$TMP_FILE"
whiptail --textbox "$TMP_FILE" 8 0
rm "$TMP_FILE"

+ 2
- 0
src/templates/result.twig View File

@@ -0,0 +1,2 @@
Username: {{ SYSTEM_USER_USERNAME }}
Password: {{ USER_PASSWORD }}

+ 13
- 0
src/templates/summary.twig View File

@@ -0,0 +1,13 @@
DOMAIN: {{ DOMAIN }}
DOMAIN_ALIASES: {{ DOMAIN }}
DOCUMENT_ROOT: {{ DOCUMENT_ROOT }}

SYSTEM_USER_USERNAME: {{ SYSTEM_USER_USERNAME }}
SYSTEM_USER_GROUP: {{ SYSTEM_USER_GROUP }}

WEB_HTTP: {{ WEB_HTTP }}
WEB_HTTPS: {{ WEB_HTTPS }}
WEB_HTTPS_FORCE: {{ WEB_HTTPS_FORCE }}

PHP_ENABLED: {{ PHP_ENABLED }}
PHP_VERSION: {{ PHP_VERSION }}

Loading…
Cancel
Save