Skip to content

Commit

Permalink
refactor show_info(), make it only depend on variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nacho committed Sep 7, 2017
1 parent 0197f31 commit 0fcde74
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 178 deletions.
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 5 additions & 3 deletions etc/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down
19 changes: 7 additions & 12 deletions etc/nextcloudpi-config.d/NFS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" ]] && {
Expand Down
9 changes: 1 addition & 8 deletions etc/nextcloudpi-config.d/dnsmasq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
19 changes: 6 additions & 13 deletions etc/nextcloudpi-config.d/letsencrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,19 @@ 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
git clone https://github.com/letsencrypt/letsencrypt
/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()
{
Expand Down
14 changes: 4 additions & 10 deletions etc/nextcloudpi-config.d/modsecurity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <<EOF
Expand Down
14 changes: 3 additions & 11 deletions etc/nextcloudpi-config.d/nc-automount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,14 @@
ACTIVE_=no
DESCRIPTION="Automount USB drives by plugging them in"

show_info()
{
whiptail --yesno \
--backtitle "NextCloudPi configuration" \
--title "Automount notes" \
"Plugged in USB drives will be automounted under /media
INFOTITLE="Automount notes"
INFO="Plugged in USB drives will be automounted under /media
on boot or at the moment of insertion.
Format your drive as ext4 in order to move NC datafolder or database
VFAT or NTFS is not recommended for this task, as it does not suport permissions
Drives with multiple partitions are not supported
IMPORTANT: halt or umount the drive before extracting" \
20 90
}
IMPORTANT: halt or umount the drive before extracting"

install()
{
Expand Down
12 changes: 2 additions & 10 deletions etc/nextcloudpi-config.d/nc-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@
DBDIR_=/media/USBdrive/ncdatabase
DESCRIPTION="Move your database to a new location, like a USB drive"

show_info()
{
whiptail --yesno \
--backtitle "NextCloudPi configuration" \
--title "Info" \
"Note that non Unix filesystems such as NTFS are not supported
INFO="Note that non Unix filesystems such as NTFS are not supported
because they do not provide a compatible user/permissions system
You need to use a USB drive that is permanently on and is responsive
or the database will fail.
** If it ever fails with a white page, move the database back to the SD **
" \
20 90
}
** If it ever fails with a white page, move the database back to the SD **"

configure()
{
Expand Down
11 changes: 2 additions & 9 deletions etc/nextcloudpi-config.d/nc-datadir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@
DATADIR_=/media/USBdrive/ncdata
DESCRIPTION="Change your data dir to a new location, like a USB drive"

show_info()
{
whiptail --yesno \
--backtitle "NextCloudPi configuration" \
--title "Info" \
"Note that non Unix filesystems such as NTFS are not supported
because they do not provide a compatible user/permissions system" \
20 90
}
INFO="Note that non Unix filesystems such as NTFS are not supported
because they do not provide a compatible user/permissions system"

configure()
{
Expand Down
15 changes: 4 additions & 11 deletions etc/nextcloudpi-config.d/nc-format-USB.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@
LABEL_=myCloudDrive
DESCRIPTION="Format an external USB drive as a ext4 partition (dangerous)"

show_info()
{
whiptail --yesno \
--backtitle "NextCloudPi configuration" \
--title "Instructions for USB drive formatting" \
"Make sure that ONLY the USB drive that you want to format is plugged in.
Be careful, this will destroy any data in the USB drive
INFOTITLE="Instructions for USB drive formatting"
INFO="Make sure that ONLY the USB drive that you want to format is plugged in.
careful, this will destroy any data in the USB drive
** YOU WILL LOSE ALL YOUR USB DATA ** " \
20 90
}
** YOU WILL LOSE ALL YOUR USB DATA **"

configure()
{
Expand Down
12 changes: 3 additions & 9 deletions etc/nextcloudpi-config.d/nc-forward-ports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,13 @@ HTTPSPORT_=443
HTTPPORT_=80
DESCRIPTION="Set port forwarding to access from outside (UPnP)"

show_info()
{
whiptail --yesno \
--backtitle "NextCloudPi configuration" \
--title "Instructions for UPnP Port Forwarding" \
"For NextCloudPi to be able to setup your ports, UPnP must be activated
INFOTITLE="Instructions for UPnP Port Forwarding"
INFO="For NextCloudPi to be able to setup your ports, UPnP must be activated
in your router. Activate it now on your router admin webpage.
** UPnP is considered a security risk **
Don't forget to disable it afterwards" \
20 90
}
Don't forget to disable it afterwards"

install()
{
Expand Down
12 changes: 3 additions & 9 deletions etc/nextcloudpi-config.d/nc-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@ ADMINPASS_=ownyourbits
DBADMIN=ncadmin
DESCRIPTION="(Re)initiate Nextcloud to a clean configuration"

show_info()
{
whiptail --yesno \
--backtitle "NextCloudPi configuration" \
--title "Clean NextCloud configuration" \
"This action will configure NextCloud to NextCloudPi defaults.
INFOTITLE="Clean NextCloud configuration"
INFO="This action will configure NextCloud to NextCloudPi defaults.
** YOUR CONFIGURATION WILL BE LOST **
" \
20 90
}
"

configure()
{
Expand Down
13 changes: 4 additions & 9 deletions etc/nextcloudpi-config.d/nc-nextcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,16 @@ DESCRIPTION="Install any NextCloud version"

export DEBIAN_FRONTEND=noninteractive

show_info()
{
[ -d /var/www/nextcloud ] && \
whiptail --yesno \
--backtitle "NextCloudPi configuration" \
--title "NextCloud installation" \
"This new installation will cleanup current
[ -d /var/www/nextcloud ] && { # don't show this during image build
INFOTITLE="NextCloud installation"
INFO="This new installation will cleanup current
NextCloud instance, including files and database.
You can later use nc-init to configure to NextCloudPi defaults
** perform backup before proceding **
You can use nc-backup " \
20 90
You can use nc-backup "
}

install() { :; }
Expand Down
12 changes: 3 additions & 9 deletions etc/nextcloudpi-config.d/nc-ramlogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@
ACTIVE_=no
DESCRIPTION="mount logs in RAM to prevent SD degradation (faster, consumes more RAM)"

show_info()
{
whiptail --yesno \
--backtitle "NextCloudPi configuration" \
--title "Warning" \
"If you are installing software other than NextCloud
that creates folders under '/var/log/' disable this feature" \
20 90
}
INFOTITLE="Warning"
INFO="If you are installing software other than NextCloud
that creates folders under '/var/log/' disable this feature"

configure()
{
Expand Down
13 changes: 3 additions & 10 deletions etc/nextcloudpi-config.d/nc-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,13 @@ BASEDIR=/var/www
DBADMIN=ncadmin
DESCRIPTION="Restore a previously backuped NC instance"

show_info()
{
[ -d /var/www/nextcloud ] && \
whiptail --yesno \
--backtitle "NextCloudPi configuration" \
--title "Restore NextCloud backup" \
"This new installation will cleanup current
INFOTITLE="Restore NextCloud backup"
INFO="This new installation will cleanup current
NextCloud instance, including files and database.
** perform backup before proceding **
You can use nc-backup " \
20 90
}
You can use nc-backup"

configure()
{
Expand Down
13 changes: 4 additions & 9 deletions etc/nextcloudpi-config.d/nc-scan-auto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@ ACTIVE_=no
SCANINTERVAL_=60
DESCRIPTION="Periodically scan NC for externally modified files"

show_info()
{
whiptail --yesno \
--backtitle "NextCloudPi configuration" \
--title "Instructions for auto synchronization" \
"Set the time in minutes in SCANINTERVAL. \n
>>> 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()
{
Expand Down
Loading

0 comments on commit 0fcde74

Please sign in to comment.