From 0fcde7499d78e00e298a776af806a5e9c39ac433 Mon Sep 17 00:00:00 2001 From: nacho Date: Thu, 7 Sep 2017 22:36:35 +0200 Subject: [PATCH] refactor show_info(), make it only depend on variables --- changelog.md | 4 +++- etc/library.sh | 8 ++++--- etc/nextcloudpi-config.d/NFS.sh | 19 +++++++---------- etc/nextcloudpi-config.d/dnsmasq.sh | 9 +------- etc/nextcloudpi-config.d/letsencrypt.sh | 19 ++++++----------- etc/nextcloudpi-config.d/modsecurity.sh | 14 ++++--------- etc/nextcloudpi-config.d/nc-automount.sh | 14 +++---------- etc/nextcloudpi-config.d/nc-database.sh | 12 ++--------- etc/nextcloudpi-config.d/nc-datadir.sh | 11 ++-------- etc/nextcloudpi-config.d/nc-format-USB.sh | 15 ++++--------- etc/nextcloudpi-config.d/nc-forward-ports.sh | 12 +++-------- etc/nextcloudpi-config.d/nc-init.sh | 12 +++-------- etc/nextcloudpi-config.d/nc-nextcloud.sh | 13 ++++-------- etc/nextcloudpi-config.d/nc-ramlogs.sh | 12 +++-------- etc/nextcloudpi-config.d/nc-restore.sh | 13 +++--------- etc/nextcloudpi-config.d/nc-scan-auto.sh | 13 ++++-------- etc/nextcloudpi-config.d/nc-wifi.sh | 22 +++++++------------- etc/nextcloudpi-config.d/no-ip.sh | 11 ++-------- etc/nextcloudpi-config.d/samba.sh | 19 +++++++---------- 19 files changed, 74 insertions(+), 178 deletions(-) diff --git a/changelog.md b/changelog.md index fdfe6204e..4351ceb3c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ -[v0.26.17](https://github.com/nextcloud/nextcloudpi/commit/a7bfd17) (2017-09-07) ncp-web: link to changelog +[v0.26.18](https://github.com/nextcloud/nextcloudpi/commit/a4144dc) (2017-09-07) refactor show_info(), make it only depend on variables + +[v0.26.17](https://github.com/nextcloud/nextcloudpi/commit/0197f31) (2017-09-07) ncp-web: link to changelog [v0.26.16](https://github.com/nextcloud/nextcloudpi/commit/e3d07fb) (2017-09-06) added sendmail and mail configuration diff --git a/etc/library.sh b/etc/library.sh index 58101d223..ad4f00724 100755 --- a/etc/library.sh +++ b/etc/library.sh @@ -220,15 +220,17 @@ function launch_script() ) } +# show an info box for a script if the INFO variable is set in the script function info_script() { ( local SCRIPT=$1 cd /usr/local/etc/nextcloudpi-config.d/ || return 1 - unset show_info + unset show_info INFO INFOTITLE source ./"$SCRIPT" - [[ $( type -t show_info ) == function ]] || return 0 - [[ $( type -t show_info ) == function ]] && show_info + local INFOTITLE="${INFOTITLE:-Info}" + [[ "$INFO" == "" ]] && return 0 + whiptail --yesno --backtitle "NextCloudPi configuration" --title "$INFOTITLE" "$INFO" 20 90 ) } diff --git a/etc/nextcloudpi-config.d/NFS.sh b/etc/nextcloudpi-config.d/NFS.sh index 415a13cfc..e76c78c05 100644 --- a/etc/nextcloudpi-config.d/NFS.sh +++ b/etc/nextcloudpi-config.d/NFS.sh @@ -20,6 +20,13 @@ USER_=www-data GROUP_=www-data DESCRIPTION="NFS network file system server (for Linux LAN)" +INFOTITLE="Instructions for external synchronization" +INFO="If we intend to modify the data folder through NFS, +then we have to synchronize NextCloud to make it aware of the changes. + +This can be done manually or automatically using 'nc-scan' and 'nc-scan-auto' +from 'nextcloudpi-config'" + install() { apt-get update @@ -61,18 +68,6 @@ Alias=portmap EOF } -show_info() -{ - whiptail --yesno \ - --backtitle "NextCloudPi configuration" \ - --title "Instructions for external synchronization" \ -"If we intend to modify the data folder through NFS, -then we have to synchronize NextCloud to make it aware of the changes. \n -This can be done manually or automatically using 'nc-scan' and 'nc-scan-auto' -from 'nextcloudpi-config'" \ - 20 90 -} - configure() { [[ $ACTIVE_ != "yes" ]] && { diff --git a/etc/nextcloudpi-config.d/dnsmasq.sh b/etc/nextcloudpi-config.d/dnsmasq.sh index 3ae99301c..1528e4a65 100644 --- a/etc/nextcloudpi-config.d/dnsmasq.sh +++ b/etc/nextcloudpi-config.d/dnsmasq.sh @@ -19,14 +19,7 @@ DNSSERVER_=8.8.8.8 CACHESIZE_=150 DESCRIPTION="DNS server with cache" -show_info() -{ - whiptail --yesno \ - --backtitle "NextCloudPi configuration" \ - --title "Info" \ -"Remember to point your PC and devices DNS to your Raspberry Pi IP" \ - 20 90 -} +INFO="Remember to point your PC and devices DNS to your Raspberry Pi IP" install() { diff --git a/etc/nextcloudpi-config.d/letsencrypt.sh b/etc/nextcloudpi-config.d/letsencrypt.sh index 3c853ee1b..1491f54ea 100644 --- a/etc/nextcloudpi-config.d/letsencrypt.sh +++ b/etc/nextcloudpi-config.d/letsencrypt.sh @@ -22,6 +22,12 @@ VHOSTCFG=/etc/apache2/sites-available/nextcloud.conf VHOSTCFG2=/etc/apache2/sites-available/ncp.conf DESCRIPTION="Automatic signed SSL certificates" +INFOTITLE="Warning" +INFO="Internet access is required for this configuration to complete +Both ports 80 and 443 need to be accessible from the internet + +Your certificate will be automatically renewed every month" + install() { cd /etc || return 1 @@ -29,19 +35,6 @@ install() /etc/letsencrypt/letsencrypt-auto --help # do not actually run certbot, only install packages } -show_info() -{ - whiptail --yesno \ - --backtitle "NextCloudPi configuration" \ - --title "Warning" \ -"Internet access is required for this configuration to complete -Both ports 80 and 443 need to be accessible from the internet - -Your certificate will be automatically renewed every month -" \ - 20 90 -} - # tested with git version v0.11.0-71-g018a304 configure() { diff --git a/etc/nextcloudpi-config.d/modsecurity.sh b/etc/nextcloudpi-config.d/modsecurity.sh index 1610bf18c..81a9bd035 100644 --- a/etc/nextcloudpi-config.d/modsecurity.sh +++ b/etc/nextcloudpi-config.d/modsecurity.sh @@ -19,6 +19,10 @@ NCDIR=/var/www/nextcloud/ NCPWB=/var/www/ncp-web/ DESCRIPTION="Web Application Firewall for extra security (experimental)" +INFOTITLE="Experimental feature warning" +INFO="This feature is highly experimental and has only been tested with +a basic NextCloud installation. If a new App does not work disable it" + install() { apt-get update @@ -44,16 +48,6 @@ EOF EOF } -show_info() -{ - whiptail --yesno \ - --backtitle "NextCloudPi configuration" \ - --title "Experimental feature warning" \ -"This feature is highly experimental and has only been tested with -a basic NextCloud installation. If a new App does not work disable it" \ - 20 90 -} - configure() { cat > /etc/modsecurity/modsecurity_crs_99_whitelist.conf <>> If there are too many files this can greatly affect performance. <<<" \ - 20 90 -} +INFOTITLE="Instructions for auto synchronization" +INFO="Set the time in minutes in SCANINTERVAL. + +>>> If there are too many files this can greatly affect performance. <<<" install() { diff --git a/etc/nextcloudpi-config.d/nc-wifi.sh b/etc/nextcloudpi-config.d/nc-wifi.sh index ae99a6c32..cd6e0380a 100644 --- a/etc/nextcloudpi-config.d/nc-wifi.sh +++ b/etc/nextcloudpi-config.d/nc-wifi.sh @@ -17,6 +17,14 @@ ACTIVE_=no DESCRIPTION="Configure your Wi-Fi connection" +INFOTITLE="Instructions to configure Wi-Fi" +INFO="1) Select a Wi-Fi network +2) Press right arrow -> +3) Enter the passphrase for your Wi-Fi +4) Make sure to select 'connect automatically' +5) F10 to save +6) C to connect" + install() { apt-get update @@ -24,20 +32,6 @@ install() systemctl disable wicd } -show_info() -{ - whiptail --yesno \ - --backtitle "NextCloudPi configuration" \ - --title "Instructions to configure Wi-Fi" \ -"1) Select a Wi-Fi network -2) Press right arrow -> -3) Enter the passphrase for your Wi-Fi -4) Make sure to select 'connect automatically' -5) F10 to save -6) C to connect" \ - 20 90 -} - configure() { [[ $ACTIVE_ != "yes" ]] && { diff --git a/etc/nextcloudpi-config.d/no-ip.sh b/etc/nextcloudpi-config.d/no-ip.sh index 0e90ebc2b..c263621f7 100644 --- a/etc/nextcloudpi-config.d/no-ip.sh +++ b/etc/nextcloudpi-config.d/no-ip.sh @@ -21,15 +21,8 @@ DOMAIN_=mycloud.ownyourbits.com TIME_=30 DESCRIPTION="DDNS no-ip free provider (need account)" -show_info() -{ - whiptail --yesno \ - --backtitle "NextCloudPi configuration" \ - --title "Info" \ -"For this step to succeed, you need to register a noip account first. -Internet access is required for this configuration to complete." \ - 20 90 -} +INFO="For this step to succeed, you need to register a noip account first. +Internet access is required for this configuration to complete." install() { diff --git a/etc/nextcloudpi-config.d/samba.sh b/etc/nextcloudpi-config.d/samba.sh index 1493ee041..4e4c4e844 100644 --- a/etc/nextcloudpi-config.d/samba.sh +++ b/etc/nextcloudpi-config.d/samba.sh @@ -19,6 +19,13 @@ USER_=pi PWD_=raspberry DESCRIPTION="SMB/CIFS file server (for Mac/Linux/Windows)" +INFOTITLE="Instructions for external synchronization" +INFO="If we intend to modify the data folder through SAMBA, +then we have to synchronize NextCloud to make it aware of the changes. + +This can be done manually or automatically using 'nc-scan' and 'nc-scan-auto' +from 'nextcloudpi-config'" + install() { apt-get update @@ -32,18 +39,6 @@ install() grep -q SMB3 /etc/samba/smb.conf || sed -i '/\[global\]/aprotocol = SMB3' /etc/samba/smb.conf } -show_info() -{ - whiptail --yesno \ - --backtitle "NextCloudPi configuration" \ - --title "Instructions for external synchronization" \ -"If we intend to modify the data folder through SAMBA, -then we have to synchronize NextCloud to make it aware of the changes. \n -This can be done manually or automatically using 'nc-scan' and 'nc-scan-auto' -from 'nextcloudpi-config'" \ - 20 90 -} - configure() { [[ $ACTIVE_ != "yes" ]] && { service smbd stop; update-rc.d smbd disable; echo "SMB disabled"; return; }