Skip to content

Commit 0fcde74

Browse files
author
nacho
committed
refactor show_info(), make it only depend on variables
1 parent 0197f31 commit 0fcde74

19 files changed

+74
-178
lines changed

changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2-
[v0.26.17](https://github.com/nextcloud/nextcloudpi/commit/a7bfd17) (2017-09-07) ncp-web: link to changelog
2+
[v0.26.18](https://github.com/nextcloud/nextcloudpi/commit/a4144dc) (2017-09-07) refactor show_info(), make it only depend on variables
3+
4+
[v0.26.17](https://github.com/nextcloud/nextcloudpi/commit/0197f31) (2017-09-07) ncp-web: link to changelog
35

46
[v0.26.16](https://github.com/nextcloud/nextcloudpi/commit/e3d07fb) (2017-09-06) added sendmail and mail configuration
57

etc/library.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,17 @@ function launch_script()
220220
)
221221
}
222222

223+
# show an info box for a script if the INFO variable is set in the script
223224
function info_script()
224225
{
225226
(
226227
local SCRIPT=$1
227228
cd /usr/local/etc/nextcloudpi-config.d/ || return 1
228-
unset show_info
229+
unset show_info INFO INFOTITLE
229230
source ./"$SCRIPT"
230-
[[ $( type -t show_info ) == function ]] || return 0
231-
[[ $( type -t show_info ) == function ]] && show_info
231+
local INFOTITLE="${INFOTITLE:-Info}"
232+
[[ "$INFO" == "" ]] && return 0
233+
whiptail --yesno --backtitle "NextCloudPi configuration" --title "$INFOTITLE" "$INFO" 20 90
232234
)
233235
}
234236

etc/nextcloudpi-config.d/NFS.sh

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ USER_=www-data
2020
GROUP_=www-data
2121
DESCRIPTION="NFS network file system server (for Linux LAN)"
2222

23+
INFOTITLE="Instructions for external synchronization"
24+
INFO="If we intend to modify the data folder through NFS,
25+
then we have to synchronize NextCloud to make it aware of the changes.
26+
27+
This can be done manually or automatically using 'nc-scan' and 'nc-scan-auto'
28+
from 'nextcloudpi-config'"
29+
2330
install()
2431
{
2532
apt-get update
@@ -61,18 +68,6 @@ Alias=portmap
6168
EOF
6269
}
6370

64-
show_info()
65-
{
66-
whiptail --yesno \
67-
--backtitle "NextCloudPi configuration" \
68-
--title "Instructions for external synchronization" \
69-
"If we intend to modify the data folder through NFS,
70-
then we have to synchronize NextCloud to make it aware of the changes. \n
71-
This can be done manually or automatically using 'nc-scan' and 'nc-scan-auto'
72-
from 'nextcloudpi-config'" \
73-
20 90
74-
}
75-
7671
configure()
7772
{
7873
[[ $ACTIVE_ != "yes" ]] && {

etc/nextcloudpi-config.d/dnsmasq.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ DNSSERVER_=8.8.8.8
1919
CACHESIZE_=150
2020
DESCRIPTION="DNS server with cache"
2121

22-
show_info()
23-
{
24-
whiptail --yesno \
25-
--backtitle "NextCloudPi configuration" \
26-
--title "Info" \
27-
"Remember to point your PC and devices DNS to your Raspberry Pi IP" \
28-
20 90
29-
}
22+
INFO="Remember to point your PC and devices DNS to your Raspberry Pi IP"
3023

3124
install()
3225
{

etc/nextcloudpi-config.d/letsencrypt.sh

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,19 @@ VHOSTCFG=/etc/apache2/sites-available/nextcloud.conf
2222
VHOSTCFG2=/etc/apache2/sites-available/ncp.conf
2323
DESCRIPTION="Automatic signed SSL certificates"
2424

25+
INFOTITLE="Warning"
26+
INFO="Internet access is required for this configuration to complete
27+
Both ports 80 and 443 need to be accessible from the internet
28+
29+
Your certificate will be automatically renewed every month"
30+
2531
install()
2632
{
2733
cd /etc || return 1
2834
git clone https://github.com/letsencrypt/letsencrypt
2935
/etc/letsencrypt/letsencrypt-auto --help # do not actually run certbot, only install packages
3036
}
3137

32-
show_info()
33-
{
34-
whiptail --yesno \
35-
--backtitle "NextCloudPi configuration" \
36-
--title "Warning" \
37-
"Internet access is required for this configuration to complete
38-
Both ports 80 and 443 need to be accessible from the internet
39-
40-
Your certificate will be automatically renewed every month
41-
" \
42-
20 90
43-
}
44-
4538
# tested with git version v0.11.0-71-g018a304
4639
configure()
4740
{

etc/nextcloudpi-config.d/modsecurity.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ NCDIR=/var/www/nextcloud/
1919
NCPWB=/var/www/ncp-web/
2020
DESCRIPTION="Web Application Firewall for extra security (experimental)"
2121

22+
INFOTITLE="Experimental feature warning"
23+
INFO="This feature is highly experimental and has only been tested with
24+
a basic NextCloud installation. If a new App does not work disable it"
25+
2226
install()
2327
{
2428
apt-get update
@@ -44,16 +48,6 @@ EOF
4448
EOF
4549
}
4650

47-
show_info()
48-
{
49-
whiptail --yesno \
50-
--backtitle "NextCloudPi configuration" \
51-
--title "Experimental feature warning" \
52-
"This feature is highly experimental and has only been tested with
53-
a basic NextCloud installation. If a new App does not work disable it" \
54-
20 90
55-
}
56-
5751
configure()
5852
{
5953
cat > /etc/modsecurity/modsecurity_crs_99_whitelist.conf <<EOF

etc/nextcloudpi-config.d/nc-automount.sh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,14 @@
1717
ACTIVE_=no
1818
DESCRIPTION="Automount USB drives by plugging them in"
1919

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

3729
install()
3830
{

etc/nextcloudpi-config.d/nc-database.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,13 @@
1717
DBDIR_=/media/USBdrive/ncdatabase
1818
DESCRIPTION="Move your database to a new location, like a USB drive"
1919

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

3628
configure()
3729
{

etc/nextcloudpi-config.d/nc-datadir.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,8 @@
1717
DATADIR_=/media/USBdrive/ncdata
1818
DESCRIPTION="Change your data dir to a new location, like a USB drive"
1919

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

3023
configure()
3124
{

etc/nextcloudpi-config.d/nc-format-USB.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,11 @@
1616
LABEL_=myCloudDrive
1717
DESCRIPTION="Format an external USB drive as a ext4 partition (dangerous)"
1818

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

3225
configure()
3326
{

0 commit comments

Comments
 (0)