create input_box_flow (#1449)

Co-authored-by: Daniel Hansson <github@hanssonit.se>
This commit is contained in:
szaimen 2020-09-13 19:18:02 +02:00 committed by GitHub
parent fa3e1e5d5a
commit eda50026fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 52 additions and 283 deletions

View File

@ -58,14 +58,7 @@ then
fi
# Ask for domain
while :
do
SUBDOMAIN=$(input_box "Please enter the Domain that you want to use for Bitwarden RS.")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "Please enter the Domain that you want to use for Bitwarden RS.")
# curl the lib another time to get the correct https_conf
# shellcheck source=lib.sh

View File

@ -56,16 +56,7 @@ then
fi
# Enter mailserver
while :
do
MAIL_SERVER=$(input_box "Please enter the mailserver URL that you want to use.\nE.g. smtp.mail.de\nIf you don't want to change the mailserver, that is already configured inside the global.override.env-file, just leave the box empty.")
if ! yesno_box_yes "Is this correct? $MAIL_SERVER"
then
msg_box "OK, please try again."
else
break
fi
done
MAIL_SERVER=$(input_box_flow "Please enter the mailserver URL that you want to use.\nE.g. smtp.mail.de\nIf you don't want to change the mailserver, that is already configured inside the global.override.env-file, just leave the box empty.")
# Enter if you want to use ssl
while :
@ -98,52 +89,16 @@ do
done
# Enter Port or just use standard port (defined by usage of ssl)
while :
do
SMTP_PORT=$(input_box "Please enter the port for your mailserver. The default port based on your protocol setting is $DEFAULT_PORT?\nPlease type that port into the inputbox, if you want to use it.\n\nIf you don't want to change the port, that is already configured inside the global.override.env-file, just leave the box empty.")
if ! yesno_box_yes "Is this correct? $SMTP_PORT"
then
msg_box "OK, please try again."
else
break
fi
done
SMTP_PORT=$(input_box_flow "Please enter the port for your mailserver. The default port based on your protocol setting is $DEFAULT_PORT?\nPlease type that port into the inputbox, if you want to use it.\n\nIf you don't want to change the port, that is already configured inside the global.override.env-file, just leave the box empty.")
# Enter your mail username
while :
do
MAIL_USERNAME=$(input_box "Please enter the username for the login to your mail provider. E.g. mail@example.com\nPlease note: the domain used for your mail username and the mailserver domain have to match!\nIf you don't want to change the mail username that is already configured inside the global.override.env-file, just leave the box empty.")
if ! yesno_box_yes "Is this correct? $MAIL_USERNAME"
then
msg_box "OK, please try again."
else
break
fi
done
MAIL_USERNAME=$(input_box_flow "Please enter the username for the login to your mail provider. E.g. mail@example.com\nPlease note: the domain used for your mail username and the mailserver domain have to match!\nIf you don't want to change the mail username that is already configured inside the global.override.env-file, just leave the box empty.")
# Enter your mailuser password
while :
do
MAIL_PASSWORD=$(input_box "Please enter the password for your mailserver user.\nIf you don't want to change the password, that is already configured inside the global.override.env-file, just leave the box empty.")
if ! yesno_box_yes "Is this correct? $MAIL_PASSWORD"
then
msg_box "OK, please try again."
else
break
fi
done
MAIL_PASSWORD=$(input_box_flow "Please enter the password for your mailserver user.\nIf you don't want to change the password, that is already configured inside the global.override.env-file, just leave the box empty.")
# Enter admin mailadresses
while :
do
ADMIN_ACCOUNT=$(input_box "Please enter mailaccounts, that should have access to the Bitwarden admin-panel, reachable under https://your-bitwarden-domain/admin/.\nThey don't have to be registered Bitwarden accounts.\nTo make this setting work, your Bitwarden mailserver settings have to be correct.\nYou can enter just one e-mailaddress or enter more than one like so:\n'bitwarden@example.com,bitwarden2@example1.com,bitwarden3@example2.com'\nIf you want to keep the admin accounts that are already configured inside the global.override.env-file, just leave the box empty.")
if ! yesno_box_yes "Is this correct? $ADMIN_ACCOUNT"
then
msg_box "OK, please try again."
else
break
fi
done
ADMIN_ACCOUNT=$(input_box_flow "Please enter mailaccounts, that should have access to the Bitwarden admin-panel, reachable under https://your-bitwarden-domain/admin/.\nThey don't have to be registered Bitwarden accounts.\nTo make this setting work, your Bitwarden mailserver settings have to be correct.\nYou can enter just one e-mailaddress or enter more than one like so:\n'bitwarden@example.com,bitwarden2@example1.com,bitwarden3@example2.com'\nIf you want to keep the admin accounts that are already configured inside the global.override.env-file, just leave the box empty.")
# Get results and store in a variable:
RESULT="These are the settings that will be changed in global.override.env. Please check that everything seems correct.\n\n"

View File

@ -42,14 +42,7 @@ then
# If yes, then stop and prune the docker container
docker_prune_this 'collabora/code'
# Revoke LE
while :
do
SUBDOMAIN=$(input_box "Please enter the subdomain you are using for Collabora, e.g: office.yourdomain.com")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "Please enter the subdomain you are using for Collabora, e.g: office.yourdomain.com")
if [ -f "$CERTFILES/$SUBDOMAIN/cert.pem" ]
then
yes no | certbot revoke --cert-path "$CERTFILES/$SUBDOMAIN/cert.pem"
@ -106,14 +99,7 @@ if does_this_docker_exist 'onlyoffice/documentserver'
then
docker_prune_this 'onlyoffice/documentserver'
# Revoke LE
while :
do
SUBDOMAIN=$(input_box "Please enter the subdomain you are using for OnlyOffice, e.g: office.yourdomain.com")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "Please enter the subdomain you are using for OnlyOffice, e.g: office.yourdomain.com")
if [ -f "$CERTFILES/$SUBDOMAIN/cert.pem" ]
then
yes no | certbot revoke --cert-path "$CERTFILES/$SUBDOMAIN/cert.pem"
@ -157,15 +143,7 @@ then
fi
# Ask for the domain for Collabora
while :
do
# Collabora URL
SUBDOMAIN=$(input_box "Collabora subdomain e.g: office.yourdomain.com\n\nNOTE: This domain must be different than your Nextcloud domain. They can however be hosted on the same server, but would require seperate DNS entries.")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "Collabora subdomain e.g: office.yourdomain.com\n\nNOTE: This domain must be different than your Nextcloud domain. They can however be hosted on the same server, but would require seperate DNS entries.")
# Nextcloud Main Domain
NCDOMAIN=$(occ_command_no_check config:system:get overwrite.cli.url | sed 's|https://||;s|/||')

View File

@ -48,14 +48,7 @@ then
occ_command app:remove onlyoffice
fi
# Revoke LE
while :
do
SUBDOMAIN=$(input_box "Please enter the subdomain you are using for Collabora, e.g: office.yourdomain.com")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "Please enter the subdomain you are using for Collabora, e.g: office.yourdomain.com")
if [ -f "$CERTFILES/$SUBDOMAIN/cert.pem" ]
then
yes no | certbot revoke --cert-path "$CERTFILES/$SUBDOMAIN/cert.pem"
@ -120,14 +113,7 @@ then
# Remove docker image
docker_prune_this 'onlyoffice/documentserver'
# Revoke LE
while :
do
SUBDOMAIN=$(input_box "Please enter the subdomain you are using for Onlyoffice, e.g: office.yourdomain.com")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "Please enter the subdomain you are using for Onlyoffice, e.g: office.yourdomain.com")
if [ -f "$CERTFILES/$SUBDOMAIN/cert.pem" ]
then
yes no | certbot revoke --cert-path "$CERTFILES/$SUBDOMAIN/cert.pem"

View File

@ -49,14 +49,7 @@ then
# If yes, then stop and prune the docker container
docker_prune_this 'onlyoffice/documentserver'
# Revoke LE
while :
do
SUBDOMAIN=$(input_box "Please enter the subdomain you are using for OnlyOffice, e.g: office.yourdomain.com")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "Please enter the subdomain you are using for OnlyOffice, e.g: office.yourdomain.com")
if [ -f "$CERTFILES/$SUBDOMAIN/cert.pem" ]
then
yes no | certbot revoke --cert-path "$CERTFILES/$SUBDOMAIN/cert.pem"
@ -114,14 +107,7 @@ then
# Remove docker image
docker_prune_this 'collabora/code'
# Revoke LE
while :
do
SUBDOMAIN=$(input_box "Please enter the subdomain you are using for Collabora, e.g: office.yourdomain.com")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "Please enter the subdomain you are using for Collabora, e.g: office.yourdomain.com")
if [ -f "$CERTFILES/$SUBDOMAIN/cert.pem" ]
then
yes no | certbot revoke --cert-path "$CERTFILES/$SUBDOMAIN/cert.pem"
@ -172,15 +158,7 @@ then
fi
# Ask for the domain for OnlyOffice
while :
do
# OnlyOffice URL (onlyoffice.sh)
SUBDOMAIN=$(input_box "OnlyOffice subdomain e.g: office.yourdomain.com\n\nNOTE: This domain must be different than your Nextcloud domain. They can however be hosted on the same server, but would require seperate DNS entries.")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "OnlyOffice subdomain e.g: office.yourdomain.com\n\nNOTE: This domain must be different than your Nextcloud domain. They can however be hosted on the same server, but would require seperate DNS entries.")
# Nextcloud Main Domain
NCDOMAIN=$(occ_command_no_check config:system:get overwrite.cli.url | sed 's|https://||;s|/||')

View File

@ -48,14 +48,7 @@ then
occ_command app:remove onlyoffice
fi
# Revoke LE
while :
do
SUBDOMAIN=$(input_box "Please enter the subdomain you are using for OnlyOffice, e.g: office.yourdomain.com")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "Please enter the subdomain you are using for OnlyOffice, e.g: office.yourdomain.com")
if [ -f "$CERTFILES/$SUBDOMAIN/cert.pem" ]
then
yes no | certbot revoke --cert-path "$CERTFILES/$SUBDOMAIN/cert.pem"
@ -136,14 +129,7 @@ then
# Remove docker image
docker_prune_this 'collabora/code'
# Revoke LE
while :
do
SUBDOMAIN=$(input_box "Please enter the subdomain you are using for Collabora, e.g: office.yourdomain.com")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "Please enter the subdomain you are using for Collabora, e.g: office.yourdomain.com")
if [ -f "$CERTFILES/$SUBDOMAIN/cert.pem" ]
then
yes no | certbot revoke --cert-path "$CERTFILES/$SUBDOMAIN/cert.pem"

View File

@ -81,41 +81,14 @@ If you really want to mount more, you can simply download the smb-mount script d
fi
# Enter SMB-server and Share-name
while :
do
SERVER_SHARE_NAME=$(input_box "Please enter the server and Share-name like this:\n//Server/Share\nor\n//IP-address/Share" "$SUBTITLE")
if ! yesno_box_yes "Is this correct? $SERVER_SHARE_NAME" "$SUBTITLE"
then
msg_box "It seems like your weren't satisfied by the PATH you entered. Please try again." "$SUBTITLE"
else
SERVER_SHARE_NAME=${SERVER_SHARE_NAME// /\\040}
break
fi
done
SERVER_SHARE_NAME=$(input_box_flow "Please enter the server and Share-name like this:\n//Server/Share\nor\n//IP-address/Share" "$SUBTITLE")
SERVER_SHARE_NAME=${SERVER_SHARE_NAME// /\\040}
# Enter the SMB-user
while :
do
SMB_USER=$(input_box "Please enter the username of the SMB-user" "$SUBTITLE")
if ! yesno_box_yes "Is this correct? $SMB_USER" "$SUBTITLE"
then
msg_box "It seems like your weren't satisfied by the SMB-user you entered. Please try again." "$SUBTITLE"
else
break
fi
done
SMB_USER=$(input_box_flow "Please enter the username of the SMB-user" "$SUBTITLE")
# Enter the password of the SMB-user
while :
do
SMB_PASSWORD=$(input_box "Please enter the password of the SMB-user $SMB_USER." "$SUBTITLE")
if ! yesno_box_yes "Is this correct? $SMB_PASSWORD" "$SUBTITLE"
then
msg_box "It seems like your weren't satisfied by the password for the SMB-user you entered. Please try again." "$SUBTITLE"
else
break
fi
done
SMB_PASSWORD=$(input_box_flow "Please enter the password of the SMB-user $SMB_USER." "$SUBTITLE")
# Write everything to /etc/fstab, mount and connect external storage
count=1
@ -371,45 +344,18 @@ case "$choice" in
*"Share"*)
clear
# Enter SMB-server and Share-name
while :
do
SERVER_SHARE_NAME=$(input_box "Please enter the server and Share-name like this:\n//Server/Share\nor\n//IP-address/Share" "$SUBTITLE")
if ! yesno_box_yes "Is this correct? $SERVER_SHARE_NAME" "$SUBTITLE"
then
msg_box "It seems like your weren't satisfied by the PATH you entered. Please try again." "$SUBTITLE"
else
SERVER_SHARE_NAME=${SERVER_SHARE_NAME// /\\040}
break
fi
done
SERVER_SHARE_NAME=$(input_box_flow "Please enter the server and Share-name like this:\n//Server/Share\nor\n//IP-address/Share" "$SUBTITLE")
SERVER_SHARE_NAME=${SERVER_SHARE_NAME// /\\040}
;;&
*"Username"*)
clear
# Enter the SMB-user
while :
do
SMB_USER=$(input_box "Please enter the username of the SMB-user" "$SUBTITLE")
if ! yesno_box_yes "Is this correct? $SMB_USER" "$SUBTITLE"
then
msg_box "It seems like your weren't satisfied by the SMB-user you entered. Please try again." "$SUBTITLE"
else
break
fi
done
SMB_USER=$(input_box_flow "Please enter the username of the SMB-user" "$SUBTITLE")
;;&
*"Password"*)
clear
# Enter the password of the SMB-user
while :
do
SMB_PASSWORD=$(input_box "Please enter the password of the SMB-user $SMB_USER." "$SUBTITLE")
if ! yesno_box_yes "Is this correct? $SMB_PASSWORD" "$SUBTITLE"
then
msg_box "It seems like your weren't satisfied by the password for the SMB-user you entered. Please try again." "$SUBTITLE"
else
break
fi
done
SMB_PASSWORD=$(input_box_flow "Please enter the password of the SMB-user $SMB_USER." "$SUBTITLE")
;;&
"")
return

View File

@ -94,15 +94,8 @@ ${NONO_PORTS[*]}"
if yesno_box_no "Do you want to change port?"
then
while :
do
# Ask for port
TURN_PORT=$(input_box "Please enter the port you will use for Nextcloud Talk")
if yesno_box_yes "Is this correct? $TURN_PORT"
then
break
fi
done
TURN_PORT=$(input_box_flow "Please enter the port you will use for Nextcloud Talk")
fi
containsElement () {

View File

@ -116,15 +116,8 @@ ${NONO_PORTS[*]}"
if yesno_box_no "Do you want to change port?"
then
while :
do
# Ask for port
TURN_PORT=$(input_box "Please enter the port you will use for Nextcloud Talk")
if yesno_box_yes "Is this correct? $TURN_PORT"
then
break
fi
done
TURN_PORT=$(input_box_flow "Please enter the port you will use for Nextcloud Talk")
fi
containsElement () {
@ -223,15 +216,7 @@ then
fi
# Ask for the domain for Talk
while :
do
# Talk Proxy URL
SUBDOMAIN=$(input_box "Talk Signaling Server subdomain e.g: talk.yourdomain.com\n\nNOTE: This domain must be different than your Nextcloud domain. They can however be hosted on the same server, but would require seperate DNS entries.")
if yesno_box_yes "Is this correct? $SUBDOMAIN"
then
break
fi
done
SUBDOMAIN=$(input_box_flow "Talk Signaling Server subdomain e.g: talk.yourdomain.com\n\nNOTE: This domain must be different than your Nextcloud domain. They can however be hosted on the same server, but would require seperate DNS entries.")
# curl the lib another time to get the correct https_conf
# shellcheck source=lib.sh

View File

@ -61,15 +61,8 @@ just type: sudo bash /var/scripts/activate-tls.sh"
exit
fi
while :
do
# Nextcloud Main Domain (activate-tls.sh)
TLSDOMAIN=$(input_box "Please enter the domain name you will use for Nextcloud.\n\nMake sure it looks like this:\nyourdomain.com, or cloud.yourdomain.com")
if yesno_box_yes "Is this correct? $TLSDOMAIN"
then
break
fi
done
TLSDOMAIN=$(input_box_flow "Please enter the domain name you will use for Nextcloud.\n\nMake sure it looks like this:\nyourdomain.com, or cloud.yourdomain.com")
# Curl the lib another time to get the correct https_conf
# shellcheck source=lib.sh

24
lib.sh
View File

@ -246,7 +246,7 @@ ask_yes_or_no() {
msg_box() {
[ -n "$2" ] && local SUBTITLE=" - $2"
whiptail --title "$TITLE$SUBTITLE" --msgbox "$1" "$WT_HEIGHT" "$WT_WIDTH"
whiptail --title "$TITLE$SUBTITLE" --msgbox "$1" "$WT_HEIGHT" "$WT_WIDTH" 3>&1 1>&2 2>&3
}
# TODO: delete in a few releases (e.g. NC20) since not needed anymore
@ -262,7 +262,7 @@ yesno_box() {
yesno_box_yes() {
[ -n "$2" ] && local SUBTITLE=" - $2"
if (whiptail --title "$TITLE$SUBTITLE" --yesno "$1" "$WT_HEIGHT" "$WT_WIDTH")
if (whiptail --title "$TITLE$SUBTITLE" --yesno "$1" "$WT_HEIGHT" "$WT_WIDTH" 3>&1 1>&2 2>&3)
then
return 0
else
@ -272,7 +272,7 @@ yesno_box_yes() {
yesno_box_no() {
[ -n "$2" ] && local SUBTITLE=" - $2"
if (whiptail --title "$TITLE$SUBTITLE" --defaultno --yesno "$1" "$WT_HEIGHT" "$WT_WIDTH")
if (whiptail --title "$TITLE$SUBTITLE" --defaultno --yesno "$1" "$WT_HEIGHT" "$WT_WIDTH" 3>&1 1>&2 2>&3)
then
return 0
else
@ -286,6 +286,24 @@ input_box() {
echo "$RESULT"
}
input_box_flow() {
local RESULT
while :
do
RESULT=$(input_box "$1" "$2")
if [ -z "$RESULT" ]
then
msg_box "Input is empty, please try again."
elif ! yesno_box_yes "Is this correct? $RESULT" "$2"
then
msg_box "OK, please try again." "$2"
else
break
fi
done
echo "$RESULT"
}
explainer_popup() {
msg_box "$SCRIPT_EXPLAINER"
if ! yesno_box_yes "Do you want to proceed with this script?"

View File

@ -56,55 +56,13 @@ then
fi
# Enter your Hostname
while :
do
HOSTNAME=$(input_box "Please enter the Host that you want to configure DDNS for.\nE.g. 'example.com'")
if ! yesno_box_yes "Is this correct? $HOSTNAME"
then
msg_box "OK, please try again."
else
if [ -z "$HOSTNAME" ]
then
msg_box "Please don't leave the inputbox empty."
else
break
fi
fi
done
HOSTNAME=$(input_box_flow "Please enter the Host that you want to configure DDNS for.\nE.g. 'example.com'")
# Enter your login
while :
do
LOGIN=$(input_box "Please enter the login for your DDNS provider.\nIt will be most likely the domain or registered email address depending on your DDNS Provider.\nE.g. 'example.com' or 'mail@example.com'\nIf you are not sure, please refer to the documentation of your DDNS provider.")
if ! yesno_box_yes "Is this correct? $LOGIN"
then
msg_box "OK, please try again."
else
if [ -z "$LOGIN" ]
then
msg_box "Please don't leave the inputbox empty."
else
break
fi
fi
done
LOGIN=$(input_box_flow "Please enter the login for your DDNS provider.\nIt will be most likely the domain or registered email address depending on your DDNS Provider.\nE.g. 'example.com' or 'mail@example.com'\nIf you are not sure, please refer to the documentation of your DDNS provider.")
# Enter your password
while :
do
PASSWORD=$(input_box "Please enter the password or api-key that you've got for DynDNS from your DDNS provider.\nIf you are not sure, please refer to the documentation of your DDNS provider.")
if ! yesno_box_yes "Is this correct? $PASSWORD"
then
msg_box "OK, please try again."
else
if [ -z "$PASSWORD" ]
then
msg_box "Please don't leave the inputbox empty."
else
break
fi
fi
done
PASSWORD=$(input_box_flow "Please enter the password or api-key that you've got for DynDNS from your DDNS provider.\nIf you are not sure, please refer to the documentation of your DDNS provider.")
# Get results and store in a variable:
RESULT="You will see now a list of all entered information. Please check that everything seems correct.\n\n"