Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Vagrantfile2
-rw-r--r--armbian.sh12
-rwxr-xr-xbin/ncp-config133
-rw-r--r--bin/ncp-diag3
-rw-r--r--bin/ncp-provisioning.sh12
-rw-r--r--bin/ncp-suggestions4
-rw-r--r--bin/ncp/BACKUPS/nc-backup-auto.sh (renamed from etc/ncp-config.d/nc-backup-auto.sh)15
-rw-r--r--bin/ncp/BACKUPS/nc-backup.sh (renamed from etc/ncp-config.d/nc-backup.sh)9
-rw-r--r--bin/ncp/BACKUPS/nc-export-ncp.sh43
-rw-r--r--bin/ncp/BACKUPS/nc-import-ncp.sh (renamed from etc/ncp-config.d/nc-import-ncp.sh)37
-rw-r--r--bin/ncp/BACKUPS/nc-restore.sh (renamed from etc/ncp-config.d/nc-restore.sh)14
-rw-r--r--bin/ncp/BACKUPS/nc-rsync-auto.sh (renamed from etc/ncp-config.d/nc-rsync-auto.sh)16
-rw-r--r--bin/ncp/BACKUPS/nc-rsync.sh (renamed from etc/ncp-config.d/nc-rsync.sh)8
-rw-r--r--bin/ncp/BACKUPS/nc-snapshot-auto.sh (renamed from etc/ncp-config.d/nc-snapshot-auto.sh)4
-rw-r--r--bin/ncp/BACKUPS/nc-snapshot-sync.sh (renamed from etc/ncp-config.d/nc-snapshot-sync.sh)29
-rw-r--r--bin/ncp/BACKUPS/nc-snapshot.sh (renamed from etc/ncp-config.d/nc-snapshot.sh)7
-rw-r--r--bin/ncp/CONFIG/nc-admin.sh (renamed from etc/ncp-config.d/nc-admin.sh)10
-rw-r--r--bin/ncp/CONFIG/nc-autoupdate-nc.sh (renamed from etc/ncp-config.d/nc-autoupdate-nc.sh)7
-rw-r--r--bin/ncp/CONFIG/nc-autoupdate-ncp.sh (renamed from etc/ncp-config.d/nc-autoupdate-ncp.sh)7
-rw-r--r--bin/ncp/CONFIG/nc-database.sh (renamed from etc/ncp-config.d/nc-database.sh)29
-rw-r--r--bin/ncp/CONFIG/nc-datadir.sh (renamed from etc/ncp-config.d/nc-datadir.sh)52
-rw-r--r--bin/ncp/CONFIG/nc-httpsonly.sh (renamed from etc/ncp-config.d/nc-httpsonly.sh)4
-rw-r--r--bin/ncp/CONFIG/nc-init.sh (renamed from etc/ncp-config.d/nc-init.sh)13
-rw-r--r--bin/ncp/CONFIG/nc-limits.sh (renamed from etc/ncp-config.d/nc-limits.sh)35
-rw-r--r--bin/ncp/CONFIG/nc-nextcloud.sh (renamed from etc/ncp-config.d/nc-nextcloud.sh)36
-rw-r--r--bin/ncp/CONFIG/nc-notify-updates.sh (renamed from etc/ncp-config.d/nc-notify-updates.sh)9
-rw-r--r--bin/ncp/CONFIG/nc-passwd.sh (renamed from etc/ncp-config.d/nc-passwd.sh)5
-rw-r--r--bin/ncp/CONFIG/nc-prettyURL.sh (renamed from etc/ncp-config.d/nc-prettyURL.sh)5
-rw-r--r--bin/ncp/CONFIG/nc-scan-auto.sh (renamed from etc/ncp-config.d/nc-scan-auto.sh)15
-rw-r--r--bin/ncp/CONFIG/nc-webui.sh (renamed from etc/ncp-config.d/nc-webui.sh)4
-rw-r--r--bin/ncp/NETWORKING/DDNS_duckDNS.sh (renamed from etc/ncp-config.d/DDNS_duckDNS.sh)12
-rw-r--r--bin/ncp/NETWORKING/DDNS_freeDNS.sh (renamed from etc/ncp-config.d/DDNS_freeDNS.sh)17
-rw-r--r--bin/ncp/NETWORKING/DDNS_no-ip.sh (renamed from etc/ncp-config.d/DDNS_no-ip.sh)17
-rw-r--r--bin/ncp/NETWORKING/DDNS_spDYN.sh (renamed from etc/ncp-config.d/DDNS_spDYN.sh)13
-rw-r--r--bin/ncp/NETWORKING/NFS.sh (renamed from etc/ncp-config.d/NFS.sh)24
-rw-r--r--bin/ncp/NETWORKING/SSH.sh (renamed from etc/ncp-config.d/SSH.sh)23
-rw-r--r--bin/ncp/NETWORKING/dnsmasq.sh (renamed from etc/ncp-config.d/dnsmasq.sh)20
-rw-r--r--bin/ncp/NETWORKING/letsencrypt.sh (renamed from etc/ncp-config.d/letsencrypt.sh)26
-rw-r--r--bin/ncp/NETWORKING/nc-forward-ports.sh (renamed from etc/ncp-config.d/nc-forward-ports.sh)19
-rw-r--r--bin/ncp/NETWORKING/nc-static-IP.sh (renamed from etc/ncp-config.d/nc-static-IP.sh)17
-rw-r--r--bin/ncp/NETWORKING/samba.sh (renamed from etc/ncp-config.d/samba.sh)13
-rw-r--r--bin/ncp/SECURITY/UFW.sh (renamed from etc/ncp-config.d/UFW.sh)14
-rw-r--r--bin/ncp/SECURITY/fail2ban.sh (renamed from etc/ncp-config.d/fail2ban.sh)23
-rw-r--r--bin/ncp/SECURITY/modsecurity.sh (renamed from etc/ncp-config.d/modsecurity.sh)12
-rw-r--r--bin/ncp/SECURITY/nc-audit.sh (renamed from etc/ncp-config.d/nc-audit.sh)1
-rw-r--r--bin/ncp/SYSTEM/nc-automount.sh (renamed from etc/ncp-config.d/nc-automount.sh)13
-rw-r--r--bin/ncp/SYSTEM/nc-hdd-monitor.sh (renamed from etc/ncp-config.d/nc-hdd-monitor.sh)15
-rw-r--r--bin/ncp/SYSTEM/nc-hdd-test.sh (renamed from etc/ncp-config.d/nc-hdd-test.sh)8
-rw-r--r--bin/ncp/SYSTEM/nc-info.sh (renamed from etc/ncp-config.d/nc-info.sh)1
-rw-r--r--bin/ncp/SYSTEM/nc-ramlogs.sh (renamed from etc/ncp-config.d/nc-ramlogs.sh)16
-rw-r--r--bin/ncp/SYSTEM/nc-swapfile.sh (renamed from etc/ncp-config.d/nc-swapfile.sh)13
-rw-r--r--bin/ncp/SYSTEM/nc-wifi.sh (renamed from etc/ncp-config.d/nc-wifi.sh)14
-rw-r--r--bin/ncp/SYSTEM/nc-zram.sh (renamed from etc/ncp-config.d/nc-zram.sh)4
-rw-r--r--bin/ncp/SYSTEM/unattended-upgrades.sh (renamed from etc/ncp-config.d/unattended-upgrades.sh)9
-rw-r--r--bin/ncp/TOOLS/nc-fix-permissions.sh (renamed from etc/ncp-config.d/nc-fix-permissions.sh)1
-rw-r--r--bin/ncp/TOOLS/nc-format-USB.sh (renamed from etc/ncp-config.d/nc-format-USB.sh)12
-rw-r--r--bin/ncp/TOOLS/nc-previews.sh (renamed from etc/ncp-config.d/nc-previews.sh)4
-rw-r--r--bin/ncp/TOOLS/nc-scan.sh (renamed from etc/ncp-config.d/nc-scan.sh)1
-rw-r--r--bin/ncp/TOOLS/nc-update-nextcloud.sh (renamed from etc/ncp-config.d/nc-update-nextcloud.sh)6
-rw-r--r--bin/ncp/TOOLS/nc-update.sh (renamed from etc/ncp-config.d/nc-update.sh)1
-rwxr-xr-xbuild-SD-rpi.sh12
-rw-r--r--docker-armhf/lamp/Dockerfile2
-rw-r--r--docker-armhf/nextcloud/Dockerfile11
-rw-r--r--docker-armhf/nextcloudpi/Dockerfile14
-rwxr-xr-xdocker-common/debian-ncp/run-parts.sh1
-rwxr-xr-xdocker-common/nextcloud/020nextcloud2
-rw-r--r--docker/lamp/Dockerfile2
-rw-r--r--docker/nextcloud/Dockerfile11
-rw-r--r--docker/nextcloudpi/Dockerfile14
-rw-r--r--etc/library.sh259
-rw-r--r--etc/ncp-config.d/DDNS_duckDNS.cfg26
-rw-r--r--etc/ncp-config.d/DDNS_freeDNS.cfg31
-rw-r--r--etc/ncp-config.d/DDNS_no-ip.cfg36
-rw-r--r--etc/ncp-config.d/DDNS_spDYN.cfg26
-rw-r--r--etc/ncp-config.d/NFS.cfg36
-rw-r--r--etc/ncp-config.d/SSH.cfg31
-rw-r--r--etc/ncp-config.d/UFW.cfg31
-rw-r--r--etc/ncp-config.d/dnsmasq.cfg31
-rw-r--r--etc/ncp-config.d/fail2ban.cfg42
-rw-r--r--etc/ncp-config.d/letsencrypt.cfg25
-rw-r--r--etc/ncp-config.d/modsecurity.cfg16
-rw-r--r--etc/ncp-config.d/nc-admin.cfg25
-rw-r--r--etc/ncp-config.d/nc-audit.cfg9
-rw-r--r--etc/ncp-config.d/nc-automount.cfg16
-rw-r--r--etc/ncp-config.d/nc-autoupdate-nc.cfg21
-rw-r--r--etc/ncp-config.d/nc-autoupdate-ncp.cfg21
-rw-r--r--etc/ncp-config.d/nc-backup-auto.cfg43
-rw-r--r--etc/ncp-config.d/nc-backup.cfg32
-rw-r--r--etc/ncp-config.d/nc-database.cfg15
-rw-r--r--etc/ncp-config.d/nc-datadir.cfg15
-rw-r--r--etc/ncp-config.d/nc-export-ncp.cfg15
-rw-r--r--etc/ncp-config.d/nc-export-ncp.sh58
-rw-r--r--etc/ncp-config.d/nc-fix-permissions.cfg9
-rw-r--r--etc/ncp-config.d/nc-format-USB.cfg15
-rw-r--r--etc/ncp-config.d/nc-forward-ports.cfg20
-rw-r--r--etc/ncp-config.d/nc-hdd-monitor.cfg26
-rw-r--r--etc/ncp-config.d/nc-hdd-test.cfg22
-rw-r--r--etc/ncp-config.d/nc-httpsonly.cfg16
-rw-r--r--etc/ncp-config.d/nc-import-ncp.cfg15
-rw-r--r--etc/ncp-config.d/nc-info.cfg9
-rw-r--r--etc/ncp-config.d/nc-init.cfg20
-rw-r--r--etc/ncp-config.d/nc-limits.cfg30
-rw-r--r--etc/ncp-config.d/nc-nextcloud.cfg36
-rw-r--r--etc/ncp-config.d/nc-notify-updates.cfg21
-rw-r--r--etc/ncp-config.d/nc-passwd.cfg20
-rw-r--r--etc/ncp-config.d/nc-prettyURL.cfg16
-rw-r--r--etc/ncp-config.d/nc-previews.cfg9
-rw-r--r--etc/ncp-config.d/nc-ramlogs.cfg16
-rw-r--r--etc/ncp-config.d/nc-restore.cfg15
-rw-r--r--etc/ncp-config.d/nc-rsync-auto.cfg26
-rw-r--r--etc/ncp-config.d/nc-rsync.cfg15
-rw-r--r--etc/ncp-config.d/nc-scan-auto.cfg21
-rw-r--r--etc/ncp-config.d/nc-scan.cfg9
-rw-r--r--etc/ncp-config.d/nc-snapshot-auto.cfg16
-rw-r--r--etc/ncp-config.d/nc-snapshot-sync.cfg37
-rw-r--r--etc/ncp-config.d/nc-snapshot.cfg15
-rw-r--r--etc/ncp-config.d/nc-static-IP.cfg21
-rw-r--r--etc/ncp-config.d/nc-swapfile.cfg20
-rw-r--r--etc/ncp-config.d/nc-update-nextcloud.cfg15
-rw-r--r--etc/ncp-config.d/nc-update.cfg9
-rw-r--r--etc/ncp-config.d/nc-webui.cfg16
-rw-r--r--etc/ncp-config.d/nc-wifi.cfg16
-rw-r--r--etc/ncp-config.d/nc-zram.cfg16
-rw-r--r--etc/ncp-config.d/samba.cfg21
-rw-r--r--etc/ncp-config.d/unattended-upgrades.cfg22
-rw-r--r--install.sh11
-rw-r--r--ncp-web/L10N.php9
-rw-r--r--ncp-web/css/ncp.css (renamed from ncp-web/ncp.css)72
-rw-r--r--ncp-web/elements.php154
-rw-r--r--ncp-web/img/files.svg1
-rw-r--r--ncp-web/index.php91
-rw-r--r--ncp-web/js/minified.js (renamed from ncp-web/minified.js)0
-rw-r--r--ncp-web/js/ncp.js (renamed from ncp-web/ncp.js)123
-rw-r--r--ncp-web/ncp-launcher.php289
-rw-r--r--ncp-web/ncp-output.php7
-rw-r--r--ncp-web/sidebar.php64
-rw-r--r--ncp.sh12
-rw-r--r--post-inst.sh8
-rwxr-xr-xupdate.sh119
139 files changed, 2160 insertions, 1287 deletions
diff --git a/Vagrantfile b/Vagrantfile
index 4915c5f4..6a0d4577 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -40,7 +40,7 @@ Vagrant.configure("2") do |config|
# cleanup
source etc/library.sh
- install_script post-inst.sh
+ run_app post-inst.sh
cd -
rm -r /tmp/nextcloudpi
systemctl disable sshd
diff --git a/armbian.sh b/armbian.sh
index e567f662..62953efb 100644
--- a/armbian.sh
+++ b/armbian.sh
@@ -29,12 +29,12 @@ cd /tmp/overlay
echo -e "\nInstalling NextCloudPi"
source etc/library.sh
-install_script lamp.sh
-install_script etc/ncp-config.d/nc-nextcloud.sh
-activate_script etc/ncp-config.d/nc-nextcloud.sh
-install_script ncp.sh
-activate_script etc/ncp-config.d/nc-init.sh
-install_script post-inst.sh
+install_app lamp.sh
+install_app etc/ncp-config.d/nc-nextcloud.sh
+run_app etc/ncp-config.d/nc-nextcloud.sh
+install_app ncp.sh
+run_app etc/ncp-config.d/nc-init.sh
+run_app post-inst.sh
cd -
diff --git a/bin/ncp-config b/bin/ncp-config
index 40b69b51..6dd36171 100755
--- a/bin/ncp-config
+++ b/bin/ncp-config
@@ -11,55 +11,96 @@
# More at https://ownyourbits.com/2017/03/13/nextcloudpi-gets-nextcloudpi-config/
#
+BINDIR=/usr/local/bin/ncp
+
source /usr/local/etc/library.sh
{
+ # ask for update if outdated
+ ncp-test-updates 2>/dev/null && {
+ [[ -f "$chlogfile" ]] && local changelog=$( head -4 "$chlogfile" )
+
+ whiptail --backtitle "$backtitle $ncpversion" \
+ --title "NextCloudPi update available" \
+ --clear --yesno "Update to $latest_ver?\n\n$changelog" \
+ 15 70
+
+ [[ $? -eq $dialog_ok ]] && ncp-update
+ }
+
+function generate_list()
+{
+ local dir="$1"
+ unset list
+ for item in "$dir"/*; do
+
+ # directories
+ [[ -d "$item" ]] && {
+ local dir="$( basename "$item" )"
+ list+=(" $dir" "")
+ continue
+ }
+
+ [[ "$item" =~ ".sh" ]] || continue
+
+ # regular ncp_apps
+ local app="$( basename "$item" .sh )"
+ local cfg="$cfgdir/$app".cfg
+
+ [[ -f "$cfg" ]] && local desc=$( jq -r .description "$cfg" ) || local desc="No description."
+ is_active_app "$app" "$dir" && local on="*" || local on=" "
-function nextcloud-config()
+ list+=( "$on $app" "$desc" )
+ done
+}
+
+function config_menu()
{
- local DIALOG_OK=0
- local VERFILE=/var/run/.ncp-latest-version
- local BACKTITLE="NextCloudPi configuration ver. "
- local CONFDIR=/usr/local/etc/ncp-config.d/
- local DESC
-
- # ask for update if outdated
- test -f /usr/local/etc/ncp-changelog && \
- local CHANGELOG=$( head -4 /usr/local/etc/ncp-changelog )
- ncp-test-updates 2>/dev/null && \
- whiptail --backtitle "$BACKTITLE $( cat /usr/local/etc/ncp-version )" \
- --title "NextCloudPi update available" \
- --clear --yesno "Update to $( cat $VERFILE )?\n\n$CHANGELOG" \
- 15 70
- [[ $? -eq $DIALOG_OK ]] && ncp-update
-
- while true; do
-
- # fill options
- local LIST=()
- for item in $CONFDIR/*.sh; do
- DESC=$( grep "DESCRIPTION=" "$item" | sed 's|^DESCRIPTION="||;s|"$||' )
- is_active_script "$item" &>/dev/null && local ON="*" || local ON=" "
- LIST+=( "$ON $( basename "$item" .sh )" "$DESC" )
- done
-
- # launch the selection menu
- local script
- script=$( whiptail --backtitle "$BACKTITLE $( cat /usr/local/etc/ncp-version )" \
- --title "NextCloudPi Software Configuration Tool (ncp-config)" \
- --cancel-button Finish --ok-button Select \
- --menu "Select program to configure and activate:" 20 105 10 \
- "${LIST[@]}" \
- 3>&1 1>&2 2>&3 )
-
- [[ $? -ne $DIALOG_OK ]] || [[ "$script" == "" ]] && return 0
-
- # remove ✓ and spaces
- script=$( sed 's=*\| ==g' <<< "$script" )
-
- # launch selected script
- info_script "$script".sh || continue;
- configure_script "$script".sh && { echo "Done. Press any key..."; read -r; }
- done
+ local dir="$1"
+ local backtitle="NextCloudPi configuration ver. "
+ local latest_ver="$(cat /var/run/.ncp-latest-version)"
+ local ncpversion="$(cat /usr/local/etc/ncp-version )"
+ local cfgdir=/usr/local/etc/ncp-config.d
+ local chlogfile=/usr/local/etc/ncp-changelog
+ local dialog_ok=0
+ local desc cfg ncp_app
+
+ while true; do
+
+ # menu items
+ generate_list "$dir"
+
+ # launch the selection menu
+ [[ "$dir" == "$BINDIR" ]] && local cancel_btn="Finish" || local cancel_btn="Back"
+ ncp_app=$( whiptail --backtitle "$backtitle $ncpversion" \
+ --title "NextCloudPi Configuration Tool (ncp-config)" \
+ --cancel-button $cancel_btn --ok-button Select \
+ --menu "Select ncp-app to configure or activate:" 20 105 10 \
+ "${list[@]}" \
+ 3>&1 1>&2 2>&3 )
+
+ [[ $? -ne $dialog_ok ]] || [[ "$ncp_app" == "" ]] && {
+ [[ "$dir" == "$BINDIR" ]] && return 0
+ dir="$(dirname "$dir")"
+ continue
+ }
+
+ # remove * and spaces
+ ncp_app=$( sed 's=*\| ==g' <<< "$ncp_app" )
+
+ # directory selection
+ [[ -d "$dir/$ncp_app" ]] && {
+ dir="$dir/$ncp_app"
+ config_menu "$dir"
+ return
+ }
+
+ # launch selected ncp_app
+ info_app "$ncp_app" || continue
+ configure_app "$ncp_app" || continue
+ run_app "$ncp_app"
+ echo "Done. Press any key..."
+ read -r
+ done
}
if [[ ${EUID} -ne 0 ]]; then
@@ -67,7 +108,7 @@ if [[ ${EUID} -ne 0 ]]; then
exit 1
fi
-nextcloud-config
+config_menu "$BINDIR"
exit $?
} # force to read the whole thing into memory, as its contents might change in update.sh
diff --git a/bin/ncp-diag b/bin/ncp-diag
index 4e646c0f..7e9e2a63 100644
--- a/bin/ncp-diag
+++ b/bin/ncp-diag
@@ -23,7 +23,8 @@ test -d "$DATADIR" || DIRINFO=" (doesn't exist)"
USBDEVS="$( lsblk -S -o NAME,TRAN | awk '{ if ( $2 == "usb" ) print $1; }' | tr '\n' ' ' )"
[[ "$USBDEVS" == "" ]] && USBDEVS="none"
-[[ -f /usr/local/etc/ncp-config.d/nc-automount.sh ]] && echo "automount|$( grep "^ACTIVE_" /usr/local/etc/ncp-config.d/nc-automount.sh | cut -d'=' -f2 )"
+am_cfg="/usr/local/etc/nc-automount.cfg"
+[[ -f "$am_cfg" ]] && [[ "$(jq -r ".params[0].value" "$am_cfg")" == "yes" ]] && echo "automount|yes" || echo "automount|no"
echo "USB devices|$USBDEVS"
echo "datadir|$DATADIR$DIRINFO"
[[ "$DIRINFO" == "" ]] && {
diff --git a/bin/ncp-provisioning.sh b/bin/ncp-provisioning.sh
index c905a01b..7316fa4b 100644
--- a/bin/ncp-provisioning.sh
+++ b/bin/ncp-provisioning.sh
@@ -5,7 +5,6 @@
## redis provisioning
CFG=/var/www/nextcloud/config/config.php
-CONFDIR=/usr/local/etc/ncp-config.d/
REDISPASS="$( grep "^requirepass" /etc/redis/redis.conf | cut -f2 -d' ' )"
### IF redis password is the default one, generate a new one
@@ -51,9 +50,7 @@ EOF
## nc.limits.sh (auto)adjustments: number of threads, memory limits...
source /usr/local/etc/library.sh
-cd "$CONFDIR" &>/dev/null
-activate_script nc-limits.sh
-cd - &>/dev/null
+run_app nc-limits
## Check for interrupted upgrades and rollback
BKP="$( ls -1t /var/www/nextcloud-bkp_*.tar.gz 2>/dev/null | head -1 )"
@@ -62,11 +59,4 @@ BKP="$( ls -1t /var/www/nextcloud-bkp_*.tar.gz 2>/dev/null | head -1 )"
ncp-restore "$BKP" && rm "$BKP"
}
-## Fix permissions on NCP folders. The main reason for this is to make devel docker container work
-[[ -e $CONFDIR ]] && {
- chown -R root:www-data "$CONFDIR"/*
- chmod 660 "$CONFDIR"/*
- chmod 750 "$CONFDIR"/l10n
-}
-
exit 0
diff --git a/bin/ncp-suggestions b/bin/ncp-suggestions
index 77559732..5f20bd85 100644
--- a/bin/ncp-suggestions
+++ b/bin/ncp-suggestions
@@ -14,12 +14,12 @@
OUT="$@"
-DNSMASQ_ON="$( grep "^ACTIVE_=" /usr/local/etc/ncp-config.d/dnsmasq.sh | cut -d'=' -f2 )"
+source /usr/local/etc/library.sh
grep -q "distribution|.*bian GNU/Linux 9,*" <<<"$OUT" || \
echo -e "You are using an unsupported distro release. Please upgrade to latest Debian/Raspbian"
-[[ $DNSMASQ_ON != "yes" ]] && \
+is_active_app dnsmasq && \
grep -q "NAT loopback|no" <<<"$OUT" && \
echo -e "\nYou should enable dnsmasq to use your domain inside home"
diff --git a/etc/ncp-config.d/nc-backup-auto.sh b/bin/ncp/BACKUPS/nc-backup-auto.sh
index 3c10d3d0..ef9c8a91 100644
--- a/etc/ncp-config.d/nc-backup-auto.sh
+++ b/bin/ncp/BACKUPS/nc-backup-auto.sh
@@ -7,18 +7,9 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-
-ACTIVE_=no
-DESTDIR_=/media/USBdrive/ncp-backups
-INCLUDEDATA_=no
-COMPRESS_=no
-BACKUPDAYS_=7
-BACKUPLIMIT_=4
-DESCRIPTION="Periodic backups"
-
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
rm -f /etc/cron.d/ncp-backup-auto
service cron restart
echo "automatic backups disabled"
@@ -28,12 +19,12 @@ configure()
cat > /usr/local/bin/ncp-backup-auto <<EOF
#!/bin/bash
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on
-/usr/local/bin/ncp-backup "$DESTDIR_" "$INCLUDEDATA_" "$COMPRESS_" "$BACKUPLIMIT_"
+/usr/local/bin/ncp-backup "$DESTDIR" "$INCLUDEDATA" "$COMPRESS" "$BACKUPLIMIT"
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off
EOF
chmod +x /usr/local/bin/ncp-backup-auto
- echo "0 3 */${BACKUPDAYS_} * * root /usr/local/bin/ncp-backup-auto" > /etc/cron.d/ncp-backup-auto
+ echo "0 3 */${BACKUPDAYS} * * root /usr/local/bin/ncp-backup-auto" > /etc/cron.d/ncp-backup-auto
service cron restart
echo "automatic backups enabled"
diff --git a/etc/ncp-config.d/nc-backup.sh b/bin/ncp/BACKUPS/nc-backup.sh
index fbe70677..09c36c4f 100644
--- a/etc/ncp-config.d/nc-backup.sh
+++ b/bin/ncp/BACKUPS/nc-backup.sh
@@ -7,13 +7,6 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-
-DESTDIR_=/media/USBdrive/ncp-backups
-INCLUDEDATA_=no
-COMPRESS_=no
-BACKUPLIMIT_=4
-DESCRIPTION="Backup this NC instance to a file"
-
install()
{
cat > /usr/local/bin/ncp-backup <<'EOF'
@@ -110,7 +103,7 @@ EOF
configure()
{
- ncp-backup "$DESTDIR_" "$INCLUDEDATA_" "$COMPRESS_" "$BACKUPLIMIT_"
+ ncp-backup "$DESTDIR" "$INCLUDEDATA" "$COMPRESS" "$BACKUPLIMIT"
}
# License
diff --git a/bin/ncp/BACKUPS/nc-export-ncp.sh b/bin/ncp/BACKUPS/nc-export-ncp.sh
new file mode 100644
index 00000000..ce2e9308
--- /dev/null
+++ b/bin/ncp/BACKUPS/nc-export-ncp.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# Export NextCloudPi configuration
+#
+#
+# Copyleft 2017 by Courtney Hicks
+# GPL licensed (see end of file) * Use at your own risk!
+#
+
+
+
+configure()
+{
+ [[ -d "$DIR" ]] || { echo "directory $DIR does not exist"; return 1; }
+
+ local destfile="$DIR"/ncp-config_$( date +"%Y%m%d" ).tar
+
+ tar -cf "$destfile" -C /usr/local/etc/ncp-config.d .
+ chmod 600 "$destfile"
+
+ cd $OLDPWD
+ rm -rf /tmp/ncp-export
+ echo -e "configuration exported to $destfile"
+}
+
+install() { :; }
+
+# License
+#
+# This script is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This script is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this script; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307 USA
diff --git a/etc/ncp-config.d/nc-import-ncp.sh b/bin/ncp/BACKUPS/nc-import-ncp.sh
index 97e9de99..7c83da24 100644
--- a/etc/ncp-config.d/nc-import-ncp.sh
+++ b/bin/ncp/BACKUPS/nc-import-ncp.sh
@@ -7,49 +7,30 @@
# GPL licensed (see end of file) * Use at your own risk!
#
-FILE_=/media/USBdrive/ncp-config_xxxxxx.cfg
-DESCRIPTION="Import NextCloudPi configuration from file"
+
+CFGDIR="/usr/local/etc/ncp-config.d"
configure()
{
- [[ -f "$FILE_" ]] || { echo "export file $FILE_ does not exist"; return 1; }
+ [[ -f "$FILE" ]] || { echo "export file $FILE does not exist"; return 1; }
source /usr/local/etc/library.sh || return 1
- cd /usr/local/etc/ncp-config.d || return 1
+ cd "$CFGDIR" || return 1
# extract export
- local TMP="/tmp/ncp-export"
- rm -rf "$TMP"
- mkdir -p "$TMP"
- tar -xf "$FILE_" -C "$TMP"
+ tar -xf "$FILE" -C "$CFGDIR"
# UGLY workaround to prevent apache from restarting upon activating some extras
# which leads to the operation appearing to fail in ncp-web
- echo "invalid_op" >> /etc/apache2/sites-available/000-default.conf
-
- # restore configuration and activate
- for file in /"$TMP"/*; do
- local SCRIPT="$( basename "$file" .cfg ).sh"
-
- # restore
- [ -f /usr/local/etc/ncp-config.d/"$SCRIPT" ] && {
- local VARS=( $( grep "^[[:alpha:]]\+=" "$file" | cut -d= -f1 ) )
- local VALS=( $( grep "^[[:alpha:]]\+=" "$file" | cut -d= -f2 ) )
- for i in $( seq 0 1 ${#VARS[@]} ); do
- sed -i "s|^${VARS[$i]}_=.*|${VARS[$i]}_=${VALS[$i]}|" "$SCRIPT"
- done
- }
+ #echo "invalid_op" >> /etc/apache2/sites-available/000-default.conf
- # activate
- grep -q "^ACTIVE_=yes" "$SCRIPT" && echo && activate_script "$SCRIPT"
- done
+ # activate
+ # TODO
# Fix invalid configuration
- sed -i "/^invalid_op/d" /etc/apache2/sites-available/000-default.conf
+ #sed -i "/^invalid_op/d" /etc/apache2/sites-available/000-default.conf
- # cleanup
- rm -rf "$TMP"
echo -e "\nconfiguration restored"
# delayed in bg so it does not kill the connection, and we get AJAX response
diff --git a/etc/ncp-config.d/nc-restore.sh b/bin/ncp/BACKUPS/nc-restore.sh
index 05de9db9..fff6aafa 100644
--- a/etc/ncp-config.d/nc-restore.sh
+++ b/bin/ncp/BACKUPS/nc-restore.sh
@@ -9,18 +9,6 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-
-BACKUPFILE_=/media/USBdrive/nextcloud-bkp_xxxxxxxx.tar
-DESCRIPTION="Restore a previously backuped NC instance"
-
-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"
-
install()
{
cat > /usr/local/bin/ncp-restore <<'EOF'
@@ -170,7 +158,7 @@ EOF
configure()
{
- ncp-restore "$BACKUPFILE_"
+ ncp-restore "$BACKUPFILE"
}
# License
diff --git a/etc/ncp-config.d/nc-rsync-auto.sh b/bin/ncp/BACKUPS/nc-rsync-auto.sh
index becf806e..a1da426d 100644
--- a/etc/ncp-config.d/nc-rsync-auto.sh
+++ b/bin/ncp/BACKUPS/nc-rsync-auto.sh
@@ -8,14 +8,6 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-ACTIVE_=no
-DESTINATION_=user@ip:/path/to/sync
-SYNCDAYS_=3
-DESCRIPTION="Periodically sync Nextcloud data through rsync"
-
-INFO="DESTINATION can be a regular path for local sync
-'user' needs SSH autologin from the NCP 'root' user at 'ip'"
-
install()
{
apt-get update
@@ -24,7 +16,7 @@ install()
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
rm -f /etc/cron.d/ncp-rsync-auto
echo "automatic rsync disabled"
return 0
@@ -36,13 +28,13 @@ configure()
return 1;
}
- [[ "$DESTINATION_" =~ : ]] && {
- local NET="$( sed 's|:.*||' <<<"$DESTINATION_" )"
+ [[ "$DESTINATION" =~ : ]] && {
+ local NET="$( sed 's|:.*||' <<<"$DESTINATION" )"
local SSH=( ssh -o "BatchMode=yes" "$NET" )
${SSH[@]} : || { echo "SSH non-interactive not properly configured"; return 1; }
}
- echo "0 5 */${SYNCDAYS_} * * root /usr/bin/rsync -ax --delete \"$DATADIR\" \"$DESTINATION_\"" > /etc/cron.d/ncp-rsync-auto
+ echo "0 5 */${SYNCDAYS} * * root /usr/bin/rsync -ax --delete \"$DATADIR\" \"$DESTINATION\"" > /etc/cron.d/ncp-rsync-auto
service cron restart
echo "automatic rsync enabled"
diff --git a/etc/ncp-config.d/nc-rsync.sh b/bin/ncp/BACKUPS/nc-rsync.sh
index d75e7453..4b1fef96 100644
--- a/etc/ncp-config.d/nc-rsync.sh
+++ b/bin/ncp/BACKUPS/nc-rsync.sh
@@ -8,12 +8,6 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-DESTINATION_=user@ip:/path/to/sync
-DESCRIPTION="Sync Nextcloud data through rsync"
-
-INFO="'user' needs SSH autologin from the NCP 'root' user at 'ip'
-if we are launching from ncp-web"
-
BASEDIR=/var/www
install()
@@ -32,7 +26,7 @@ configure()
return 1;
}
- rsync -ax --delete "$DATADIR" "$DESTINATION_"
+ rsync -ax --delete "$DATADIR" "$DESTINATION"
sudo -u www-data php "$BASEDIR"/nextcloud/occ maintenance:mode --off
}
diff --git a/etc/ncp-config.d/nc-snapshot-auto.sh b/bin/ncp/BACKUPS/nc-snapshot-auto.sh
index 03eb25ae..2f12cd46 100644
--- a/etc/ncp-config.d/nc-snapshot-auto.sh
+++ b/bin/ncp/BACKUPS/nc-snapshot-auto.sh
@@ -9,8 +9,6 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-ACTIVE_=no
-DESCRIPTION="Scheduled datadir BTRFS snapshots"
install()
{
@@ -20,7 +18,7 @@ install()
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
rm -f /etc/cron.hourly/btrfs-snp
echo "automatic snapshots disabled"
return 0
diff --git a/etc/ncp-config.d/nc-snapshot-sync.sh b/bin/ncp/BACKUPS/nc-snapshot-sync.sh
index 7eccd93f..fb43ffd7 100644
--- a/etc/ncp-config.d/nc-snapshot-sync.sh
+++ b/bin/ncp/BACKUPS/nc-snapshot-sync.sh
@@ -8,17 +8,6 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-ACTIVE_=no
-SNAPDIR_=/media/USBdrive/ncp-snapshots
-DESTINATION_=/media/myBackupDrive/ncp-snapshots
-COMPRESSION_=no
-SYNCDAYS_=1
-DESCRIPTION="Sync BTRFS snapshots to USBdrive or remote machine"
-
-INFO="Use format user@ip:/path/to/snapshots for remote sync
-'user' needs permissions for the 'btrfs' command at 'ip'
-'user' needs SSH autologin from the NCP 'root' user at 'ip'
-Only use compression for internet transfer, because it uses many resources"
install()
{
@@ -31,7 +20,7 @@ install()
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
rm -f /etc/cron.d/ncp-snapsync-auto
service cron restart
echo "snapshot sync disabled"
@@ -39,22 +28,22 @@ configure()
}
# checks
- [[ -d "$SNAPDIR_" ]] || { echo "$SNAPDIR_ does not exist"; return 1; }
+ [[ -d "$SNAPDIR" ]] || { echo "$SNAPDIR does not exist"; return 1; }
- [[ "$DESTINATION_" =~ : ]] && {
- local NET="$( sed 's|:.*||' <<<"$DESTINATION_" )"
- local DST="$( sed 's|.*:||' <<<"$DESTINATION_" )"
+ [[ "$DESTINATION" =~ : ]] && {
+ local NET="$( sed 's|:.*||' <<<"$DESTINATION" )"
+ local DST="$( sed 's|.*:||' <<<"$DESTINATION" )"
local SSH=( ssh -o "BatchMode=yes" "$NET" )
${SSH[@]} : || { echo "SSH non-interactive not properly configured"; return 1; }
- } || DST="$DESTINATION_"
+ } || DST="$DESTINATION"
[[ "$( ${SSH[@]} stat -fc%T "$DST" )" != "btrfs" ]] && {
- echo "$DESTINATION_ is not in a BTRFS filesystem"
+ echo "$DESTINATION is not in a BTRFS filesystem"
return 1
}
- [[ "$COMPRESSION_" == "yes" ]] && ZIP="-z"
+ [[ "$COMPRESSION" == "yes" ]] && ZIP="-z"
- echo "30 4 */${SYNCDAYS_} * * root /usr/local/bin/btrfs-sync -qd $ZIP \"$SNAPDIR_\" \"$DESTINATION_\"" > /etc/cron.d/ncp-snapsync-auto
+ echo "30 4 */${SYNCDAYS} * * root /usr/local/bin/btrfs-sync -qd $ZIP \"$SNAPDIR\" \"$DESTINATION\"" > /etc/cron.d/ncp-snapsync-auto
service cron restart
echo "snapshot sync enabled"
}
diff --git a/etc/ncp-config.d/nc-snapshot.sh b/bin/ncp/BACKUPS/nc-snapshot.sh
index 607bc47e..df3bdfac 100644
--- a/etc/ncp-config.d/nc-snapshot.sh
+++ b/bin/ncp/BACKUPS/nc-snapshot.sh
@@ -8,11 +8,6 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-LIMIT_=4
-DESCRIPTION="Create BTRFS snapshot of the datadir"
-
-INFO="Snapshots take up very little space because only the differences from one
-to the next are saved. This requires the datadir to be in a BTRFS filesystem"
BASEDIR=/var/www
@@ -39,7 +34,7 @@ configure()
return 1
}
- btrfs-snp $MOUNTPOINT manual $LIMIT_ 0 ../ncp-snapshots
+ btrfs-snp $MOUNTPOINT manual $LIMIT 0 ../ncp-snapshots
sudo -u www-data php "$BASEDIR"/nextcloud/occ maintenance:mode --off
}
diff --git a/etc/ncp-config.d/nc-admin.sh b/bin/ncp/CONFIG/nc-admin.sh
index 10ffff15..2bdf9128 100644
--- a/etc/ncp-config.d/nc-admin.sh
+++ b/bin/ncp/CONFIG/nc-admin.sh
@@ -8,19 +8,15 @@
# More at: https://ownyourbits.com
#
-USER_=ncp
-PASSWORD_=ownyourbits
-CONFIRM_=ownyourbits
-DESCRIPTION="Change password for the Nextcloud admin user"
configure()
{
- [[ "$PASSWORD_" == "$CONFIRM_" ]] || { echo "passwords do not match"; return 1; }
+ [[ "$PASSWORD" == "$CONFIRM" ]] || { echo "passwords do not match"; return 1; }
- OC_PASS="$PASSWORD_" \
+ OC_PASS="$PASSWORD" \
sudo -E -u www-data php /var/www/nextcloud/occ \
- user:resetpassword --password-from-env "$USER_"
+ user:resetpassword --password-from-env "$USER"
}
install() { :; }
diff --git a/etc/ncp-config.d/nc-autoupdate-nc.sh b/bin/ncp/CONFIG/nc-autoupdate-nc.sh
index 1f6d5d18..2e90b533 100644
--- a/etc/ncp-config.d/nc-autoupdate-nc.sh
+++ b/bin/ncp/CONFIG/nc-autoupdate-nc.sh
@@ -8,16 +8,13 @@
# More at: https://ownyourbits.com
#
-ACTIVE_=no
-NOTIFYUSER_=ncp
-DESCRIPTION="Automatically apply Nextcloud updates"
# just change this value and re-activate in update.sh to upgrade users
VERSION=14.0.4
configure()
{
- [[ "$ACTIVE_" != "yes" ]] && {
+ [[ "$ACTIVE" != "yes" ]] && {
rm -f /etc/cron.daily/ncp-autoupdate-nc
echo "automatic Nextcloud updates disabled"
return 0
@@ -34,7 +31,7 @@ if [[ \${PIPESTATUS[0]} -eq 0 ]]; then
VER="\$( sudo -u www-data php /var/www/nextcloud/occ status | grep "version:" | awk '{ print \$3 }' )"
sudo -u www-data php /var/www/nextcloud/occ notification:generate \
- "$NOTIFYUSER_" "NextCloudPi" -l "Nextcloud was updated to \$VER"
+ "$NOTIFYUSER" "NextCloudPi" -l "Nextcloud was updated to \$VER"
fi
echo "" >> /var/log/ncp.log
EOF
diff --git a/etc/ncp-config.d/nc-autoupdate-ncp.sh b/bin/ncp/CONFIG/nc-autoupdate-ncp.sh
index fbbee1b3..d7b9a13f 100644
--- a/etc/ncp-config.d/nc-autoupdate-ncp.sh
+++ b/bin/ncp/CONFIG/nc-autoupdate-ncp.sh
@@ -8,13 +8,10 @@
# More at: https://ownyourbits.com
#
-ACTIVE_=no
-NOTIFYUSER_=ncp
-DESCRIPTION="Automatically apply NextCloudPi updates"
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
rm -f /etc/cron.daily/ncp-autoupdate
echo "automatic NextCloudPi updates disabled"
return 0
@@ -25,7 +22,7 @@ configure()
if /usr/local/bin/ncp-test-updates; then
/usr/local/bin/ncp-update || exit 1
sudo -u www-data php /var/www/nextcloud/occ notification:generate \
- "$NOTIFYUSER_" "NextCloudPi" \
+ "$NOTIFYUSER" "NextCloudPi" \
-l "NextCloudPi was updated to \$( cat /usr/local/etc/ncp-version )"
fi
EOF
diff --git a/etc/ncp-config.d/nc-database.sh b/bin/ncp/CONFIG/nc-database.sh
index 9e8f8204..26a53663 100644
--- a/etc/ncp-config.d/nc-database.sh
+++ b/bin/ncp/CONFIG/nc-database.sh
@@ -8,19 +8,6 @@
# More at https://ownyourbits.com/
#
-DBDIR_=/media/USBdrive/ncdatabase
-DESCRIPTION="Move your database to a new location, like a USB drive"
-
-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.
-
-Please note that the default location, when first installed is /var/lib/mysql/.
-Move it to the desired location by editing the DBDIR= field, the one shown is an example.
-
-** If it ever fails with a white page, move the database back to the SD **"
is_active()
{
@@ -33,15 +20,15 @@ configure()
local SRCDIR=$( grep datadir /etc/mysql/mariadb.conf.d/90-ncp.cnf | awk -F "= " '{ print $2 }' )
[ -d "$SRCDIR" ] || { echo -e "database directory $SRCDIR not found"; return 1; }
- [ -d "$DBDIR_" ] && {
- [[ $( find "$DBDIR_" -maxdepth 0 -empty | wc -l ) == 0 ]] && {
- echo "$DBDIR_ is not empty"
+ [ -d "$DBDIR" ] && {
+ [[ $( find "$DBDIR" -maxdepth 0 -empty | wc -l ) == 0 ]] && {
+ echo "$DBDIR is not empty"
return 1
}
- rmdir "$DBDIR_"
+ rmdir "$DBDIR"
}
- local BASEDIR=$( dirname "$DBDIR_" )
+ local BASEDIR=$( dirname "$DBDIR" )
mkdir -p "$BASEDIR"
grep -q -e ext -e btrfs <( stat -fc%T "$BASEDIR" ) || { echo -e "Only ext/btrfs filesystems can hold the data directory"; return 1; }
@@ -54,10 +41,10 @@ configure()
cd /var/www/nextcloud
sudo -u www-data php occ maintenance:mode --on
- echo "moving database to $DBDIR_..."
+ echo "moving database to $DBDIR..."
service mysql stop
- mv "$SRCDIR" "$DBDIR_" && \
- sed -i "s|^datadir.*|datadir = $DBDIR_|" /etc/mysql/mariadb.conf.d/90-ncp.cnf
+ mv "$SRCDIR" "$DBDIR" && \
+ sed -i "s|^datadir.*|datadir = $DBDIR|" /etc/mysql/mariadb.conf.d/90-ncp.cnf
service mysql start
sudo -u www-data php occ maintenance:mode --off
diff --git a/etc/ncp-config.d/nc-datadir.sh b/bin/ncp/CONFIG/nc-datadir.sh
index a79b45d4..f64861b9 100644
--- a/etc/ncp-config.d/nc-datadir.sh
+++ b/bin/ncp/CONFIG/nc-datadir.sh
@@ -8,13 +8,6 @@
# More at https://ownyourbits.com/2017/03/13/nextcloudpi-gets-nextcloudpi-config/
#
-DATADIR_=/media/USBdrive/ncdata
-DESCRIPTION="Change your data dir to a new location, like a USB drive"
-
-INFO="Note that non Unix filesystems such as NTFS are not supported
-because they do not provide a compatible user/permissions system.
-Also please note that the default location, when first installed is /var/www/nextcloud/data.
-Move it to the desired location by editing the DATADIR= field, the PATH shown is an example."
PHPVER=7.2
@@ -41,17 +34,16 @@ configure()
}
[ -d "$SRCDIR" ] || { echo -e "data directory $SRCDIR not found"; return 1; }
- [[ "$SRCDIR" == "$DATADIR_" ]] && { echo -e "INFO: data already there"; return 0; }
+ [[ "$SRCDIR" == "$DATADIR" ]] && { echo -e "INFO: data already there"; return 0; }
# checks
- local BASEDIR=$( dirname "$DATADIR_" )
+ local BASEDIR=$( dirname "$DATADIR" )
[ -d "$BASEDIR" ] || { echo "$BASEDIR does not exist"; return 1; }
# If the user chooses the root of the mountpoint, force a folder
- mountpoint -q "$DATADIR_" && {
- BASEDIR="$DATADIR_"
- DATADIR_="$DATADIR_/ncdata"
+ mountpoint -q "$DATADIR" && {
+ BASEDIR="$DATADIR"
}
grep -q -e ext -e btrfs <( stat -fc%T "$BASEDIR" ) || {
@@ -70,10 +62,10 @@ configure()
}
# backup possibly existing datadir
- [ -d $DATADIR_ ] && {
- local BKP="${DATADIR_}-$( date "+%m-%d-%y" )"
- echo "INFO: $DATADIR_ is not empty. Creating backup $BKP"
- mv "$DATADIR_" "$BKP"
+ [ -d $DATADIR ] && {
+ local BKP="${DATADIR}-$( date "+%m-%d-%y" )"
+ echo "INFO: $DATADIR is not empty. Creating backup $BKP"
+ mv "$DATADIR" "$BKP"
}
@@ -81,34 +73,34 @@ configure()
cd /var/www/nextcloud
sudo -u www-data php occ maintenance:mode --on
- echo "moving data dir from $SRCDIR to $DATADIR_..."
+ echo "moving data dir from $SRCDIR to $DATADIR..."
# use subvolumes, if BTRFS
[[ "$( stat -fc%T "$BASEDIR" )" == "btrfs" ]] && {
echo "BTRFS filesystem detected"
- btrfs subvolume create "$DATADIR_" || return 1
+ btrfs subvolume create "$DATADIR" || return 1
}
- cp --reflink=auto -raT "$SRCDIR" "$DATADIR_" || return 1
- chown www-data:www-data "$DATADIR_"
+ cp --reflink=auto -raT "$SRCDIR" "$DATADIR" || return 1
+ chown www-data:www-data "$DATADIR"
# tmp upload dir
- mkdir -p "$DATADIR_/tmp"
- chown www-data:www-data "$DATADIR_/tmp"
- sudo -u www-data php occ config:system:set tempdirectory --value "$DATADIR_/tmp"
- sed -i "s|^;\?upload_tmp_dir =.*$|upload_tmp_dir = $DATADIR_/tmp|" /etc/php/${PHPVER}/cli/php.ini
- sed -i "s|^;\?upload_tmp_dir =.*$|upload_tmp_dir = $DATADIR_/tmp|" /etc/php/${PHPVER}/fpm/php.ini
- sed -i "s|^;\?sys_temp_dir =.*$|sys_temp_dir = $DATADIR_/tmp|" /etc/php/${PHPVER}/fpm/php.ini
+ mkdir -p "$DATADIR/tmp"
+ chown www-data:www-data "$DATADIR/tmp"
+ sudo -u www-data php occ config:system:set tempdirectory --value "$DATADIR/tmp"
+ sed -i "s|^;\?upload_tmp_dir =.*$|uploadtmp_dir = $DATADIR/tmp|" /etc/php/${PHPVER}/cli/php.ini
+ sed -i "s|^;\?upload_tmp_dir =.*$|upload_tmp_dir = $DATADIR/tmp|" /etc/php/${PHPVER}/fpm/php.ini
+ sed -i "s|^;\?sys_temp_dir =.*$|sys_temp_dir = $DATADIR/tmp|" /etc/php/${PHPVER}/fpm/php.ini
# opcache dir
- sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$DATADIR_/.opcache|" /etc/php/${PHPVER}/mods-available/opcache.ini
+ sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$DATADIR/.opcache|" /etc/php/${PHPVER}/mods-available/opcache.ini
# update fail2ban logpath
- sed -i "s|logpath =.*nextcloud.log|logpath = $DATADIR_/nextcloud.log|" /etc/fail2ban/jail.conf
+ sed -i "s|logpath =.*nextcloud.log|logpath = $DATADIR/nextcloud.log|" /etc/fail2ban/jail.conf
# datadir
- sudo -u www-data php occ config:system:set datadirectory --value="$DATADIR_"
- sudo -u www-data php occ config:system:set logfile --value="$DATADIR_/nextcloud.log"
+ sudo -u www-data php occ config:system:set datadirectory --value="$DATADIR"
+ sudo -u www-data php occ config:system:set logfile --value="$DATADIR/nextcloud.log"
sudo -u www-data php occ maintenance:mode --off
}
diff --git a/etc/ncp-config.d/nc-httpsonly.sh b/bin/ncp/CONFIG/nc-httpsonly.sh
index 9e544897..cb30b2bd 100644
--- a/etc/ncp-config.d/nc-httpsonly.sh
+++ b/bin/ncp/CONFIG/nc-httpsonly.sh
@@ -8,12 +8,10 @@
# More at https://ownyourbits.com/2017/03/13/nextcloudpi-gets-nextcloudpi-config/
#
-ACTIVE_=yes
-DESCRIPTION="Force HTTPS"
configure()
{
- [[ $ACTIVE_ == "no" ]] && local OPT=Off || local OPT=On
+ [[ $ACTIVE == "no" ]] && local OPT=Off || local OPT=On
sed -i "s|RewriteEngine .*|RewriteEngine $OPT|" /etc/apache2/sites-available/000-default.conf
echo "Forcing HTTPS $OPT"
diff --git a/etc/ncp-config.d/nc-init.sh b/bin/ncp/CONFIG/nc-init.sh
index 961b1c94..64c85c67 100644
--- a/etc/ncp-config.d/nc-init.sh
+++ b/bin/ncp/CONFIG/nc-init.sh
@@ -8,18 +8,7 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-ADMINUSER_=ncp
-ADMINPASS_=ownyourbits
DBADMIN=ncadmin
-DESCRIPTION="(Re)initiate Nextcloud to a clean configuration"
-
-INFOTITLE="Clean NextCloud configuration"
-INFO="This action will configure NextCloud to NextCloudPi defaults.
-
-** YOUR CONFIGURATION WILL BE LOST **
-
-"
-
PHPVER=7.2
configure()
@@ -83,7 +72,7 @@ EOF
rm -f config/config.php
sudo -u www-data php occ maintenance:install --database \
"mysql" --database-name "nextcloud" --database-user "$DBADMIN" --database-pass \
- "$DBPASSWD" --admin-user "$ADMINUSER_" --admin-pass "$ADMINPASS_"
+ "$DBPASSWD" --admin-user "$ADMINUSER" --admin-pass "$ADMINPASS"
# cron jobs
sudo -u www-data php occ background:cron
diff --git a/etc/ncp-config.d/nc-limits.sh b/bin/ncp/CONFIG/nc-limits.sh
index 545aa5b1..ec198707 100644
--- a/etc/ncp-config.d/nc-limits.sh
+++ b/bin/ncp/CONFIG/nc-limits.sh
@@ -8,14 +8,8 @@
# More at https://ownyourbits.com/2017/03/13/nextcloudpi-gets-nextcloudpi-config/
#
-MAXFILESIZE_=10G
-MEMORYLIMIT_=0
-PHPTHREADS_=0
-REDISMEM_=0
PHPVER=7.2
-DESCRIPTION="Configure system limits for NextCloudPi"
-INFO="Examples: 200M or 2G. Write 0 for autoconfig"
configure()
{
@@ -26,36 +20,35 @@ configure()
# MAX FILESIZE
local CONF=/var/www/nextcloud/.user.ini
local CURRENT_FILE_SIZE="$( grep "^upload_max_filesize" "$CONF" | sed 's|.*=||' )"
- [[ "$MAXFILESIZE_" == "0" ]] && MAXFILESIZE_=10G
+ [[ "$MAXFILESIZE" == "0" ]] && MAXFILESIZE=10G
# MAX PHP MEMORY
local CONF=/var/www/nextcloud/.user.ini
local CURRENT_PHP_MEM="$( grep "^memory_limit" "$CONF" | sed 's|.*=||' )"
- [[ "$MEMORYLIMIT_" == "0" ]] && MEMORYLIMIT_=$AUTOMEM && echo "Using ${AUTOMEM}B for PHP"
- sed -i "s/^post_max_size=.*/post_max_size=$MAXFILESIZE_/" "$CONF"
- sed -i "s/^upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE_/" "$CONF"
- sed -i "s/^memory_limit=.*/memory_limit=$MEMORYLIMIT_/" "$CONF"
+ [[ "$MEMORYLIMIT" == "0" ]] && MEMORYLIMIT=$AUTOMEM && echo "Using ${AUTOMEM}B for PHP"
+ sed -i "s/^post_max_size=.*/post_max_size=$MAXFILESIZE/" "$CONF"
+ sed -i "s/^upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE/" "$CONF"
+ sed -i "s/^memory_limit=.*/memory_limit=$MEMORYLIMIT/" "$CONF"
# MAX PHP THREADS
local CONF=/etc/php/${PHPVER}/fpm/pool.d/www.conf
local CURRENT_THREADS=$( grep "^pm.max_children" "$CONF" | awk '{ print $3 }' )
- [[ "$PHPTHREADS_" == "0" ]] && PHPTHREADS_=$( nproc ) && echo "Using $PHPTHREADS_ PHP threads"
- sed -i "s|^pm.max_children =.*|pm.max_children = $PHPTHREADS_|" "$CONF"
- sed -i "s|^pm.max_spare_servers =.*|pm.max_spare_servers = $PHPTHREADS_|" "$CONF"
- sed -i "s|^pm.start_servers =.*|pm.start_servers = $PHPTHREADS_|" "$CONF"
+ [[ "$PHPTHREADS" == "0" ]] && PHPTHREADS=$( nproc ) && echo "Using $PHPTHREADS PHP threads"
+ sed -i "s|^pm.max_children =.*|pm.max_children = $PHPTHREADS|" "$CONF"
+ sed -i "s|^pm.max_spare_servers =.*|pm.max_spare_servers = $PHPTHREADS|" "$CONF"
+ sed -i "s|^pm.start_servers =.*|pm.start_servers = $PHPTHREADS|" "$CONF"
# RESTART PHP
- [[ "$PHPTHREADS_" != "$CURRENT_THREADS" ]] || \
- [[ "$MEMORYLIMIT" != "$CURRENT_PHP_MEM" ]] || \
- [[ "$MAXFILESIZE_" != "$CURRENT_FILE_SIZE" ]] && \
+ [[ "$PHPTHREADS" != "$CURRENT_THREADS" ]] || \
+ [[ "$MEMORYLIMIT" != "$CURRENT_PHP_MEM" ]] || \
+ [[ "$MAXFILESIZE" != "$CURRENT_FILE_SIZE" ]] && \
bash -c "sleep 3; service php${PHPVER}-fpm restart" &>/dev/null &
# redis max memory
local CONF=/etc/redis/redis.conf
local CURRENT_REDIS_MEM=$( grep "^maxmemory" "$CONF" | awk '{ print $2 }' )
- [[ "$REDISMEM_" == "0" ]] && REDISMEM_=$AUTOMEM && echo "Using ${AUTOMEM}B for Redis"
- [[ "$REDISMEM_" != "$CURRENT_REDIS_MEM" ]] && {
- sed -i "s|^maxmemory .*|maxmemory $REDISMEM_|" "$CONF"
+ [[ "$REDISMEM" != "$CURRENT_REDIS_MEM" ]] && {
+ sed -i "s|^maxmemory .*|maxmemory $REDISMEM|" "$CONF"
service redis-server restart
}
}
diff --git a/etc/ncp-config.d/nc-nextcloud.sh b/bin/ncp/CONFIG/nc-nextcloud.sh
index af39bcb7..960e5a4b 100644
--- a/etc/ncp-config.d/nc-nextcloud.sh
+++ b/bin/ncp/CONFIG/nc-nextcloud.sh
@@ -8,31 +8,13 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-VER_=14.0.4
-BETA_=no
-MAXFILESIZE_=2G
-MEMORYLIMIT_=768M
-MAXTRANSFERTIME_=3600
DBADMIN=ncadmin
REDIS_MEM=3gb
PHPVER=7.2
-DESCRIPTION="Install any NextCloud version"
APTINSTALL="apt-get install -y --no-install-recommends"
export DEBIAN_FRONTEND=noninteractive
-[ -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 "
-}
-
install()
{
# During build, this step is run before ncp.sh. Avoid executing twice
@@ -99,20 +81,20 @@ EOF
configure()
{
## IF BETA SELECTED ADD "pre" to DOWNLOAD PATH
- [[ "$BETA_" == yes ]] && local PREFIX="pre"
+ [[ "$BETA" == yes ]] && local PREFIX="pre"
## DOWNLOAD AND (OVER)WRITE NEXTCLOUD
cd /var/www/
- local URL="https://download.nextcloud.com/server/${PREFIX}releases/nextcloud-$VER_.tar.bz2"
- echo "Downloading Nextcloud $VER_..."
+ local URL="https://download.nextcloud.com/server/${PREFIX}releases/nextcloud-$VER.tar.bz2"
+ echo "Downloading Nextcloud $VER..."
wget -q "$URL" -O nextcloud.tar.bz2 || {
echo "couldn't download $URL"
return 1
}
rm -rf nextcloud
- echo "Installing Nextcloud $VER_..."
+ echo "Installing Nextcloud $VER..."
tar -xf nextcloud.tar.bz2
rm nextcloud.tar.bz2
@@ -231,13 +213,13 @@ EOF
echo "Setting up system..."
## SET LIMITS
- sed -i "s/post_max_size=.*/post_max_size=$MAXFILESIZE_/" /var/www/nextcloud/.user.ini
- sed -i "s/upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE_/" /var/www/nextcloud/.user.ini
- sed -i "s/memory_limit=.*/memory_limit=$MEMORYLIMIT_/" /var/www/nextcloud/.user.ini
+ sed -i "s/post_max_size=.*/post_max_size=$MAXFILESIZE/" /var/www/nextcloud/.user.ini
+ sed -i "s/upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE/" /var/www/nextcloud/.user.ini
+ sed -i "s/memory_limit=.*/memory_limit=$MEMORYLIMIT/" /var/www/nextcloud/.user.ini
# slow transfers will be killed after this time
- cat >> /var/www/nextcloud/.user.ini <<< "max_execution_time=$MAXTRANSFERTIME_"
- cat >> /var/www/nextcloud/.user.ini <<< "max_input_time=$MAXTRANSFERTIME_"
+ cat >> /var/www/nextcloud/.user.ini <<< "max_execution_time=$MAXTRANSFERTIME"
+ cat >> /var/www/nextcloud/.user.ini <<< "max_input_time=$MAXTRANSFERTIME"
## SET CRON
echo "*/15 * * * * php -f /var/www/nextcloud/cron.php" > /tmp/crontab_http
diff --git a/etc/ncp-config.d/nc-notify-updates.sh b/bin/ncp/CONFIG/nc-notify-updates.sh
index c66c9ddf..b61a8311 100644
--- a/etc/ncp-config.d/nc-notify-updates.sh
+++ b/bin/ncp/CONFIG/nc-notify-updates.sh
@@ -8,10 +8,7 @@
# More at: https://ownyourbits.com
#
-ACTIVE_=yes
-USER_=ncp
-DESCRIPTION="Notify in NC when a NextCloudPi update is available"
# check every hour
CHECKINTERVAL=1
@@ -19,7 +16,7 @@ NCDIR=/var/www/nextcloud
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
rm -f /etc/cron.d/ncp-notify-updates
service cron restart
echo "update web notifications disabled"
@@ -47,7 +44,7 @@ IFACE=\$( ip r | grep "default via" | awk '{ print \$5 }' | head -1 )
IP=\$( ip a show dev "\$IFACE" | grep global | grep -oP '\d{1,3}(\.\d{1,3}){3}' | head -1 )
sudo -u www-data php /var/www/nextcloud/occ notification:generate \
- $USER_ "NextCloudPi update" \
+ $USER "NextCloudPi update" \
-l "Update from \$( cat \$VERFILE ) to \$( cat \$LATEST ) is available. Update from https://\$IP:4443"
cat \$LATEST > \$NOTIFIED
@@ -78,7 +75,7 @@ echo -e "Packages automatically upgraded: \$PKGS\\n"
# notify
sudo -u www-data php /var/www/nextcloud/occ notification:generate \
- $USER_ "NextCloudPi Unattended Upgrades" \
+ $USER "NextCloudPi Unattended Upgrades" \
-l "Packages automatically upgraded \$PKGS"
EOF
chmod +x /usr/local/bin/ncp-notify-unattended-upgrade
diff --git a/etc/ncp-config.d/nc-passwd.sh b/bin/ncp/CONFIG/nc-passwd.sh
index 1cb54775..dd3c1ac6 100644
--- a/etc/ncp-config.d/nc-passwd.sh
+++ b/bin/ncp/CONFIG/nc-passwd.sh
@@ -8,15 +8,12 @@
# More at: https://ownyourbits.com
#
-PASSWORD_=ownyourbits
-CONFIRM_=ownyourbits
-DESCRIPTION="Change password for the NextCloudPi Panel"
configure()
{
# update password
- echo -e "$PASSWORD_\n$CONFIRM_" | passwd ncp &>/dev/null && \
+ echo -e "$PASSWORD\n$CONFIRM" | passwd ncp &>/dev/null && \
echo "password updated successfully" || \
{ echo "passwords do not match"; return 1; }
diff --git a/etc/ncp-config.d/nc-prettyURL.sh b/bin/ncp/CONFIG/nc-prettyURL.sh
index 0039f5f3..14d65bfb 100644
--- a/etc/ncp-config.d/nc-prettyURL.sh
+++ b/bin/ncp/CONFIG/nc-prettyURL.sh
@@ -7,9 +7,6 @@
# GPL licensed (see end of file) * Use at your own risk!
-ACTIVE_=no
-DESCRIPTION="Set pretty URLs (no index.php in URL)"
-INFOTITLE="PrettyURL notes"
NCDIR=/var/www/nextcloud
OCC="$NCDIR/occ"
@@ -29,7 +26,7 @@ configure()
local URL="$(ncc config:system:get overwrite.cli.url)"
[[ "${URL: -1}" != "/" ]] && ncc config:system:set overwrite.cli.url --value="${URL}/"
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
sudo -u www-data php "$OCC" config:system:set htaccess.RewriteBase --value=""
sudo -u www-data php "$OCC" maintenance:update:htaccess
[[ $? -ne 0 ]] && {
diff --git a/etc/ncp-config.d/nc-scan-auto.sh b/bin/ncp/CONFIG/nc-scan-auto.sh
index 0d30f84f..9dc397a4 100644
--- a/etc/ncp-config.d/nc-scan-auto.sh
+++ b/bin/ncp/CONFIG/nc-scan-auto.sh
@@ -8,18 +8,11 @@
# More at: https://ownyourbits.com
#
-ACTIVE_=no
-SCANINTERVAL_=60
-DESCRIPTION="Periodically scan NC for externally modified files"
-INFOTITLE="Instructions for auto synchronization"
-INFO="Set the time in minutes in SCANINTERVAL.
-
->>> If there are too many files this can greatly affect performance. <<<"
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
rm -f /etc/cron.d/ncp-scan-auto
service cron restart
echo "automatic scans disabled"
@@ -28,13 +21,13 @@ configure()
# set crontab
local DAYS HOURS MINS
- DAYS=$(( SCANINTERVAL_ / 1440 ))
+ DAYS=$(( SCANINTERVAL / 1440 ))
if [[ "$DAYS" != "0" ]]; then
DAYS="*/$DAYS" HOUR="1" MINS="15"
else
DAYS="*"
- HOUR=$(( SCANINTERVAL_ / 60 ))
- MINS=$(( SCANINTERVAL_ % 60 ))
+ HOUR=$(( SCANINTERVAL / 60 ))
+ MINS=$(( SCANINTERVAL % 60 ))
MINS="*/$MINS"
[[ $HOUR == 0 ]] && HOUR="*" || { HOUR="*/$HOUR" MINS="15"; }
fi
diff --git a/etc/ncp-config.d/nc-webui.sh b/bin/ncp/CONFIG/nc-webui.sh
index ef22ea3a..7b5ff637 100644
--- a/etc/ncp-config.d/nc-webui.sh
+++ b/bin/ncp/CONFIG/nc-webui.sh
@@ -8,8 +8,6 @@
# More at: https://ownyourbits.com
#
-ACTIVE_=no
-DESCRIPTION="Enable or disable the NCP web interface"
is_active()
{
@@ -18,7 +16,7 @@ is_active()
configure()
{
- if [[ $ACTIVE_ != "yes" ]]; then
+ if [[ $ACTIVE != "yes" ]]; then
a2dissite ncp
echo "ncp-web disabled"
else
diff --git a/etc/ncp-config.d/DDNS_duckDNS.sh b/bin/ncp/NETWORKING/DDNS_duckDNS.sh
index 4f6edd3e..6425eaac 100644
--- a/etc/ncp-config.d/DDNS_duckDNS.sh
+++ b/bin/ncp/NETWORKING/DDNS_duckDNS.sh
@@ -7,25 +7,21 @@
# GPL licensed (see end of file) * Use at your own risk!
#
-ACTIVE_=no
-DOMAIN_=mycloud.duckdns.org
-TOKEN_=your-duckdns-token
INSTALLDIR=duckdns
INSTALLPATH=/usr/local/etc/$INSTALLDIR
CRONFILE=/etc/cron.d/duckdns
-DESCRIPTION="Free Dynamic DNS provider (need account from https://duckdns.org)"
configure()
{
- local DOMAIN="$( sed 's|.duckdns.org||' <<<"$DOMAIN_" )"
- if [[ $ACTIVE_ == "yes" ]]; then
+ local DOMAIN="$( sed 's|.duckdns.org||' <<<"$DOMAIN" )"
+ if [[ $ACTIVE == "yes" ]]; then
mkdir -p "$INSTALLPATH"
# Creates duck.sh script that checks for updates to DNS records
touch "$INSTALLPATH"/duck.sh
touch "$INSTALLPATH"/duck.log
- echo -e "echo url=\"https://www.duckdns.org/update?domains=$DOMAIN&token=$TOKEN_&ip=\" | curl -k -o "$INSTALLPATH"/duck.log -K -" > "$INSTALLPATH"/duck.sh
+ echo -e "echo url=\"https://www.duckdns.org/update?domains=$DOMAIN&token=$TOKEN&ip=\" | curl -k -o "$INSTALLPATH"/duck.log -K -" > "$INSTALLPATH"/duck.sh
# Adds file to cron to run script for DNS record updates and change permissions
touch $CRONFILE
@@ -46,7 +42,7 @@ configure()
fi
# Removes config files and cron job if ACTIVE_ is set to no
- elif [[ $ACTIVE_ == "no" ]]; then
+ elif [[ $ACTIVE == "no" ]]; then
rm -f "$CRONFILE"
rm -f "$INSTALLPATH"/duck.sh
rm -f "$INSTALLPATH"/duck.log
diff --git a/etc/ncp-config.d/DDNS_freeDNS.sh b/bin/ncp/NETWORKING/DDNS_freeDNS.sh
index 15ea4612..8bd42afc 100644
--- a/etc/ncp-config.d/DDNS_freeDNS.sh
+++ b/bin/ncp/NETWORKING/DDNS_freeDNS.sh
@@ -6,14 +6,9 @@
# GPL licensed (see end of file) * Use at your own risk!
#
-ACTIVE_=no
-UPDATEHASH_=abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567
-DOMAIN_=mynextcloud.example.com
-UPDATEINTERVAL_=30
-DESCRIPTION="DDNS FreeDNS client (need account)"
UPDATEURL=https://freedns.afraid.org/dynamic/update.php
-URL="${UPDATEURL}?${UPDATEHASH_}"
+URL="${UPDATEURL}?${UPDATEHASH}"
install()
{
@@ -23,7 +18,7 @@ install()
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
rm -f /etc/cron.d/freeDNS
service cron restart
echo "FreeDNS client is disabled"
@@ -34,7 +29,7 @@ configure()
#!/bin/bash
echo "FreeDNS client started"
echo "${URL}"
-registeredIP=$(dig +short "$DOMAIN_"|tail -n1)
+registeredIP=$(dig +short "$DOMAIN"|tail -n1)
currentIP=\$(wget -q -O - http://checkip.dyndns.org|sed s/[^0-9.]//g)
[ "\$currentIP" != "\$registeredIP" ] && {
wget -q -O /dev/null ${URL}
@@ -43,12 +38,12 @@ echo "Registered IP: \$registeredIP | Current IP: \$currentIP"
EOF
chmod +744 /usr/local/bin/freedns.sh
- echo "*/${UPDATEINTERVAL_} * * * * root /bin/bash /usr/local/bin/freedns.sh" > /etc/cron.d/freeDNS
+ echo "*/${UPDATEINTERVAL} * * * * root /bin/bash /usr/local/bin/freedns.sh" > /etc/cron.d/freeDNS
service cron restart
cd /var/www/nextcloud
- sudo -u www-data php occ config:system:set trusted_domains 3 --value="$DOMAIN_"
- sudo -u www-data php occ config:system:set overwrite.cli.url --value=https://"$DOMAIN_"/
+ sudo -u www-data php occ config:system:set trusted_domains 3 --value="$DOMAIN"
+ sudo -u www-data php occ config:system:set overwrite.cli.url --value=https://"$DOMAIN"/
echo "FreeDNS client is enabled"
}
diff --git a/etc/ncp-config.d/DDNS_no-ip.sh b/bin/ncp/NETWORKING/DDNS_no-ip.sh
index 0e5b0478..2043d7eb 100644
--- a/etc/ncp-config.d/DDNS_no-ip.sh
+++ b/bin/ncp/NETWORKING/DDNS_no-ip.sh
@@ -8,15 +8,6 @@
# More at https://ownyourbits.com/2017/03/05/dynamic-dns-for-raspbian-with-no-ip-org-installer/
#
-ACTIVE_=no
-USER_=my-noip-user@email.com
-PASS_=noip-pass
-DOMAIN_=mycloud.ownyourbits.com
-TIME_=30
-DESCRIPTION="DDNS no-ip free provider (need account)"
-
-INFO="For this step to succeed, you need to register a noip account first.
-Internet access is required for this configuration to complete."
install()
{
@@ -83,19 +74,19 @@ EOF
configure()
{
service noip2 stop
- [[ $ACTIVE_ != "yes" ]] && { update-rc.d noip2 disable; return 0; }
+ [[ $ACTIVE != "yes" ]] && { update-rc.d noip2 disable; return 0; }
local IF=$( ip -br l | awk '{ if ( $2 == "UP" ) print $1 }' | head -1 )
[[ "$IF" != "" ]] && IF="-I $IF"
- /usr/local/bin/noip2 -C -c /usr/local/etc/no-ip2.conf $IF -U "$TIME_" -u "$USER_" -p "$PASS_" 2>&1 | tee >(cat - >&2) \
+ /usr/local/bin/noip2 -C -c /usr/local/etc/no-ip2.conf $IF -U "$TIME" -u "$USER" -p "$PASS" 2>&1 | tee >(cat - >&2) \
| grep -q "New configuration file .* created" || return 1
update-rc.d noip2 enable
service noip2 restart
cd /var/www/nextcloud
- sudo -u www-data php occ config:system:set trusted_domains 3 --value="$DOMAIN_"
- sudo -u www-data php occ config:system:set overwrite.cli.url --value=https://"$DOMAIN_"/
+ sudo -u www-data php occ config:system:set trusted_domains 3 --value="$DOMAIN"
+ sudo -u www-data php occ config:system:set overwrite.cli.url --value=https://"$DOMAIN"/
echo "noip DDNS enabled"
}
diff --git a/etc/ncp-config.d/DDNS_spDYN.sh b/bin/ncp/NETWORKING/DDNS_spDYN.sh
index 380b136e..961712fa 100644
--- a/etc/ncp-config.d/DDNS_spDYN.sh
+++ b/bin/ncp/NETWORKING/DDNS_spDYN.sh
@@ -9,15 +9,10 @@
# GPL licensed (see end of file) * Use at your own risk!
#
-ACTIVE_=no
-DOMAIN_=mycloud.spdns.de
-TOKEN_=your-spdns-token
-IPv6_=no
INSTALLDIR=spdnsupdater
INSTALLPATH=/usr/local/etc/$INSTALLDIR
CRONFILE=/etc/cron.d/spdnsupdater
-DESCRIPTION="Free Dynamic DNS provider (need account from spdyn.de)"
install()
{
@@ -101,20 +96,20 @@ EOF
configure()
{
- if [[ $ACTIVE_ == "yes" ]]; then
+ if [[ $ACTIVE == "yes" ]]; then
# Adds file to cron to run script for DNS record updates and change permissions
touch $CRONFILE
- echo "*/5 * * * * root $INSTALLPATH/spdnsUpdater.sh $DOMAIN_ $TOKEN_ $IPv6_ >/dev/null 2>&1" > "$CRONFILE"
+ echo "10 * * * * root $INSTALLPATH/spdnsUpdater.sh $DOMAIN $TOKEN $IPv6 >/dev/null 2>&1" > "$CRONFILE"
chmod +x "$CRONFILE"
# First-time execution of update script and print response from spdns.de server
- "$INSTALLPATH"/spdnsUpdater.sh "$DOMAIN_" "$TOKEN_" "$IPv6_"
+ "$INSTALLPATH"/spdnsUpdater.sh "$DOMAIN" "$TOKEN" "$IPv6"
echo -e "\nspdnsUpdater is now enabled"
# Removes config files and cron job if ACTIVE_ is set to no
- elif [[ $ACTIVE_ == "no" ]]; then
+ elif [[ $ACTIVE == "no" ]]; then
echo "... removing cronfile: $CRONFILE"
rm -f "$CRONFILE"
echo -e "\nspdnsUpdater is now disabled"
diff --git a/etc/ncp-config.d/NFS.sh b/bin/ncp/NETWORKING/NFS.sh
index db9d4336..24e133c2 100644
--- a/etc/ncp-config.d/NFS.sh
+++ b/bin/ncp/NETWORKING/NFS.sh
@@ -8,18 +8,6 @@
# More at: https://ownyourbits.com
#
-ACTIVE_=no
-DIR_=/media/USBdrive/ncdata/admin/files
-SUBNET_=192.168.1.0/24
-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'"
install()
{
@@ -34,7 +22,7 @@ install()
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
service nfs-kernel-server stop
systemctl disable nfs-kernel-server
echo -e "NFS disabled"
@@ -43,16 +31,16 @@ configure()
# CHECKS
################################
- id "$USER_" &>/dev/null || { echo "user USER_ does not exist" ; return 1; }
- id -g "$GROUP_" &>/dev/null || { echo "group GROUP_ does not exist"; return 1; }
- [ -d "$DIR_" ] || { echo -e "INFO: directory $DIR_ does not exist. Creating"; mkdir -p "$DIR_"; }
- [[ $( stat -fc%d / ) == $( stat -fc%d $DIR_ ) ]] && \
+ id "$USER" &>/dev/null || { echo "user $USER does not exist" ; return 1; }
+ id -g "$GROUP" &>/dev/null || { echo "group $GROUP does not exist"; return 1; }
+ [ -d "$DIR" ] || { echo -e "INFO: directory $DIR does not exist. Creating"; mkdir -p "$DIR"; }
+ [[ $( stat -fc%d / ) == $( stat -fc%d $DIR ) ]] && \
echo -e "INFO: mounting a in the SD card\nIf you want to use an external mount, make sure it is properly set up"
# CONFIG
################################
cat > /etc/exports <<EOF
-$DIR_ $SUBNET_(rw,sync,all_squash,anonuid=$(id -u $USER_),anongid=$(id -g $GROUP_),no_subtree_check)
+$DIR $SUBNET(rw,sync,all_squash,anonuid=$(id -u $USER),anongid=$(id -g $GROUP),no_subtree_check)
EOF
systemctl enable rpcbind
diff --git a/etc/ncp-config.d/SSH.sh b/bin/ncp/NETWORKING/SSH.sh
index 0693753f..9d8d812f 100644
--- a/etc/ncp-config.d/SSH.sh
+++ b/bin/ncp/NETWORKING/SSH.sh
@@ -7,17 +7,6 @@
# GPL licensed (see end of file) * Use at your own risk!
#
-ACTIVE_=no
-USER_=root
-PASS_=1234
-CONFIRM_=1234
-
-DESCRIPTION="Activate or deactivate SSH"
-INFOTITLE="SSH notes"
-INFO="In order to enable SSH, the password for user 'pi' can NOT remain set to the default raspberry.
-You HAVE to create a NEW password for 'pi' if you want this program to enable SSH, it will fail if you dont!
-The same will happen with user 'root' and password '1234'
-Note: Use normal AlphaNumeric, the only special characters allowed are .,@-_/"
install() { :; }
@@ -28,7 +17,7 @@ is_active()
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
systemctl stop ssh
systemctl disable ssh
echo "SSH disabled"
@@ -36,18 +25,18 @@ configure()
}
# Check for bad ideas
- [[ "$USER_" == "pi" ]] && [[ "$PASS_" == "raspberry" ]] && {
+ [[ "$USER" == "pi" ]] && [[ "$PASS" == "raspberry" ]] && {
echo "Refusing to use the default Raspbian user and password. It's insecure"
return 1
}
- [[ "$USER_" == "root" ]] && [[ "$PASS_" == "1234" ]] && {
+ [[ "$USER" == "root" ]] && [[ "$PASS" == "1234" ]] && {
echo "Refusing to use the default Armbian user and password. It's insecure"
return 1
}
# Change credentials
- id "$USER_" &>/dev/null || { echo "$USER_ doesn't exist"; return 1; }
- echo -e "$PASS_\n$CONFIRM_" | passwd "$USER_" || return 1
+ id "$USER" &>/dev/null || { echo "$USER doesn't exist"; return 1; }
+ echo -e "$PASS\n$CONFIRM" | passwd "$USER" || return 1
# Check for insecure default pi password ( taken from old jessie method )
local SHADOW="$( grep -E '^pi:' /etc/shadow )"
@@ -84,7 +73,7 @@ configure()
}
# Enable
- chage -d 0 "$USER_"
+ chage -d 0 "$USER"
systemctl enable ssh
systemctl start ssh
echo "SSH enabled"
diff --git a/etc/ncp-config.d/dnsmasq.sh b/bin/ncp/NETWORKING/dnsmasq.sh
index 553bb402..3f75c6d8 100644
--- a/etc/ncp-config.d/dnsmasq.sh
+++ b/bin/ncp/NETWORKING/dnsmasq.sh
@@ -8,14 +8,6 @@
# More at: https://ownyourbits.com/2017/03/09/dnsmasq-as-dns-cache-server-for-nextcloudpi-and-raspbian/
#
-ACTIVE_=no
-DOMAIN_=mycloud.ownyourbits.com
-DNSSERVER_=8.8.8.8
-CACHESIZE_=150
-DESCRIPTION="DNS server with cache"
-
-INFO="Remember to point your PC and devices DNS or
-you router DNS to your Raspberry Pi IP"
install()
{
@@ -48,7 +40,7 @@ EOF
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
service dnsmasq stop
update-rc.d dnsmasq disable
echo "dnmasq disabled"
@@ -66,9 +58,9 @@ domain-needed # Never forward plain names (without a dot or domain part)
bogus-priv # Never forward addresses in the non-routed address spaces.
no-poll # Don't poll for changes in /etc/resolv.conf
no-resolv # Don't use /etc/resolv.conf or any other file
-cache-size=$CACHESIZE_
-server=$DNSSERVER_
-address=/$DOMAIN_/$IP # This is optional if we add it to /etc/hosts
+cache-size=$CACHESIZE
+server=$DNSSERVER
+address=/$DOMAIN/$IP # This is optional if we add it to /etc/hosts
EOF
# required to run in container
@@ -80,8 +72,8 @@ EOF
update-rc.d dnsmasq enable
service dnsmasq restart
cd /var/www/nextcloud
- sudo -u www-data php occ config:system:set trusted_domains 2 --value=$DOMAIN_
- sudo -u www-data php occ config:system:set overwrite.cli.url --value=https://"$DOMAIN_"/
+ sudo -u www-data php occ config:system:set trusted_domains 2 --value=$DOMAIN
+ sudo -u www-data php occ config:system:set overwrite.cli.url --value=https://"$DOMAIN"/
echo "dnsmasq enabled"
}
diff --git a/etc/ncp-config.d/letsencrypt.sh b/bin/ncp/NETWORKING/letsencrypt.sh
index 87467d00..5b138d20 100644
--- a/etc/ncp-config.d/letsencrypt.sh
+++ b/bin/ncp/NETWORKING/letsencrypt.sh
@@ -7,21 +7,11 @@
#
# More at https://ownyourbits.com/2017/03/17/lets-encrypt-installer-for-apache/
-DOMAIN_=mycloud.ownyourbits.com
-EMAIL_=mycloud@ownyourbits.com
-NOTIFYUSER_=ncp
NCDIR=/var/www/nextcloud
OCC="$NCDIR/occ"
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"
is_active()
{
@@ -52,15 +42,15 @@ EOF
# tested with certbot 0.10.2
configure()
{
- local DOMAIN_LOWERCASE="${DOMAIN_,,}"
+ local DOMAIN_LOWERCASE="${DOMAIN,,}"
# Configure Apache
grep -q ServerName $VHOSTCFG && \
- sed -i "s|ServerName .*|ServerName $DOMAIN_|" $VHOSTCFG || \
- sed -i "/DocumentRoot/aServerName $DOMAIN_" $VHOSTCFG
+ sed -i "s|ServerName .*|ServerName $DOMAIN|" $VHOSTCFG || \
+ sed -i "/DocumentRoot/aServerName $DOMAIN" $VHOSTCFG
# Do it
- letsencrypt certonly -n --no-self-upgrade --webroot -w $NCDIR --hsts --agree-tos -m $EMAIL_ -d $DOMAIN_ && {
+ letsencrypt certonly -n --no-self-upgrade --webroot -w $NCDIR --hsts --agree-tos -m $EMAIL -d $DOMAIN && {
# Set up auto-renewal
cat > /etc/cron.weekly/letsencrypt-ncp <<EOF
@@ -69,13 +59,13 @@ configure()
# renew and notify
/usr/bin/certbot renew --quiet --renew-hook '
sudo -u www-data php $OCC notification:generate \
- $NOTIFYUSER_ "SSL renewal" \
+ $NOTIFYUSER "SSL renewal" \
-l "Your SSL certificate(s) \$RENEWED_DOMAINS has been renewed for another 90 days"
'
# notify if fails
[[ \$? -ne 0 ]] && sudo -u www-data php $OCC notification:generate \
- $NOTIFYUSER_ "SSL renewal error" \
+ $NOTIFYUSER "SSL renewal error" \
-l "SSL certificate renewal failed. See /var/log/letsencrypt/letsencrypt.log"
# cleanup
@@ -91,8 +81,8 @@ EOF
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/letsencrypt/live/$DOMAIN_LOWERCASE/privkey.pem|" $VHOSTCFG2
# Configure Nextcloud
- sudo -u www-data php $OCC config:system:set trusted_domains 4 --value=$DOMAIN_
- sudo -u www-data php $OCC config:system:set overwrite.cli.url --value=https://"$DOMAIN_"/
+ sudo -u www-data php $OCC config:system:set trusted_domains 4 --value=$DOMAIN
+ sudo -u www-data php $OCC config:system:set overwrite.cli.url --value=https://"$DOMAIN"/
# delayed in bg so it does not kill the connection, and we get AJAX response
bash -c "sleep 2 && service apache2 reload" &>/dev/null &
diff --git a/etc/ncp-config.d/nc-forward-ports.sh b/bin/ncp/NETWORKING/nc-forward-ports.sh
index 70560434..f404941c 100644
--- a/etc/ncp-config.d/nc-forward-ports.sh
+++ b/bin/ncp/NETWORKING/nc-forward-ports.sh
@@ -8,17 +8,6 @@
# More at: https://ownyourbits.com
#
-HTTPSPORT_=443
-HTTPPORT_=80
-DESCRIPTION="Set port forwarding to access from outside (UPnP)"
-
-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"
install()
{
@@ -30,11 +19,11 @@ configure()
{
local IFACE=$( ip r | grep "default via" | awk '{ print $5 }' | head -1 )
local IP=$( ip a show dev "$IFACE" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 )
- upnpc -d "$HTTPSPORT_" TCP
- upnpc -d "$HTTPPORT_" TCP
- upnpc -a "$IP" 443 "$HTTPSPORT_" TCP | tee >(cat - >&2) | grep -q "is redirected to internal" || \
+ upnpc -d "$HTTPSPORT" TCP
+ upnpc -d "$HTTPPORT" TCP
+ upnpc -a "$IP" 443 "$HTTPSPORT" TCP | tee >(cat - >&2) | grep -q "is redirected to internal" || \
{ echo -e "\nCould not forward ports automatically.\nDo it manually, or activate UPnP in your router and try again"; return 1; }
- upnpc -a "$IP" 80 "$HTTPPORT_" TCP | tee >(cat - >&2) | grep -q "is redirected to internal" || \
+ upnpc -a "$IP" 80 "$HTTPPORT" TCP | tee >(cat - >&2) | grep -q "is redirected to internal" || \
{ echo -e "\nCould not forward ports automatically.\nDo it manually, or activate UPnP in your router and try again"; return 1; }
}
diff --git a/etc/ncp-config.d/nc-static-IP.sh b/bin/ncp/NETWORKING/nc-static-IP.sh
index 7598f63e..0a25d7f4 100644
--- a/etc/ncp-config.d/nc-static-IP.sh
+++ b/bin/ncp/NETWORKING/nc-static-IP.sh
@@ -8,10 +8,7 @@
# More at: https://ownyourbits.com
#
-ACTIVE_=no
-IP_=192.168.1.130
-DESCRIPTION="Set up a static IP address (ACTIVE=yes), or DHCP (ACTIVE=no)"
configure()
{
@@ -27,7 +24,7 @@ configure()
grep -q "^# NextCloudPi autogenerated" /etc/dhcpcd.conf && \
sed -i '/^# NextCloudPi autogenerated/,+6d' /etc/dhcpcd.conf
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
systemctl restart dhcpcd
echo "DHCP enabled"
return
@@ -37,7 +34,7 @@ configure()
# NextCloudPi autogenerated
# don't modify! better use ncp-config
interface $IFACE
-static ip_address=$IP_/24
+static ip_address=$IP/24
static routers=$GW
static domain_name_servers=$DNS
@@ -52,7 +49,7 @@ EOF
cp -n /etc/network/interfaces /etc/network/interfaces-ncp-backup-orig
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
cat > /etc/network/interfaces <<EOF
# Wired adapter #1
allow-hotplug $IFACE
@@ -81,7 +78,7 @@ iface lo inet loopback
auto $IFACE
allow-hotplug $IFACE
iface $IFACE inet static
- address $IP_
+ address $IP
netmask 255.255.255.0
gateway $GW
dns-nameservers $DNS 8.8.8.8
@@ -89,9 +86,9 @@ EOF
systemctl restart networking
}
- sudo -u www-data php /var/www/nextcloud/occ config:system:set trusted_domains 1 --value="$IP_"
- sudo -u www-data php /var/www/nextcloud/occ config:system:set overwrite.cli.url --value=https://"$IP_"/
- echo "Static IP set to $IP_"
+ sudo -u www-data php /var/www/nextcloud/occ config:system:set trusted_domains 1 --value="$IP"
+ sudo -u www-data php /var/www/nextcloud/occ config:system:set overwrite.cli.url --value=https://"$IP"/
+ echo "Static IP set to $IP"
}
install() { :; }
diff --git a/etc/ncp-config.d/samba.sh b/bin/ncp/NETWORKING/samba.sh
index aac737dd..0b781a54 100644
--- a/etc/ncp-config.d/samba.sh
+++ b/bin/ncp/NETWORKING/samba.sh
@@ -8,15 +8,6 @@
# More at: https://ownyourbits.com
#
-ACTIVE_=no
-PWD_=ownyourbits
-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'"
install()
{
@@ -42,7 +33,7 @@ EOF
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
service smbd stop
update-rc.d smbd disable
update-rc.d nmbd disable
@@ -99,7 +90,7 @@ EOF
## create user with no login if it doesn't exist
id "$user" &>/dev/null || adduser --disabled-password --force-badname --gecos "" "$user" || return 1
- echo -e "$PWD_\n$PWD_" | smbpasswd -s -a $user
+ echo -e "$PWD\n$PWD" | smbpasswd -s -a $user
usermod -aG www-data $user
sudo chmod g+w $DIR
diff --git a/etc/ncp-config.d/UFW.sh b/bin/ncp/SECURITY/UFW.sh
index 3676e338..791a4b1f 100644
--- a/etc/ncp-config.d/UFW.sh
+++ b/bin/ncp/SECURITY/UFW.sh
@@ -8,13 +8,7 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-ACTIVE_=no
-HTTP_=80
-HTTPS_=443
-SSH_=22
-DESCRIPTION="Uncomplicated Firewall"
-INFO="Beware of blocking the SSH port you are using!"
install()
{
@@ -28,7 +22,7 @@ install()
configure()
{
- [[ "$ACTIVE_" != yes ]] && {
+ [[ "$ACTIVE" != yes ]] && {
ufw --force reset
systemctl disable ufw
systemctl stop ufw
@@ -40,12 +34,12 @@ configure()
systemctl start ufw
echo -e "\n# web server rules"
- ufw allow $HTTP_/tcp
- ufw allow $HTTPS_/tcp
+ ufw allow $HTTP/tcp
+ ufw allow $HTTPS/tcp
ufw allow 4443/tcp
echo -e "\n# SSH rules"
- ufw allow $SSH_
+ ufw allow $SSH
echo -e "\n# DNS rules"
ufw allow dns
diff --git a/etc/ncp-config.d/fail2ban.sh b/bin/ncp/SECURITY/fail2ban.sh
index b89b411f..e58a2dac 100644
--- a/etc/ncp-config.d/fail2ban.sh
+++ b/bin/ncp/SECURITY/fail2ban.sh
@@ -8,25 +8,18 @@
# More at: https://ownyourbits.com/2017/02/24/nextcloudpi-fail2ban-installer/
#
-ACTIVE_=no
# time to ban an IP that exceeded attempts
-BANTIME_=600
# cooldown time for incorrect passwords
-FINDTIME_=600
# bad attempts before banning an IP
-MAXRETRY_=6
# Option to activate email notifications
-MAILALERTS_=no
# email to send notifications to
-EMAIL_=optional@email.com
-DESCRIPTION="Brute force protection for SSH and NextCloud"
install()
{
@@ -70,7 +63,7 @@ EOF
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
service fail2ban stop
update-rc.d fail2ban disable
echo "fail2ban disabled"
@@ -100,7 +93,7 @@ failregex = Login failed.*Remote IP.*'<HOST>'
ignoreregex =
EOF
- [[ "$MAILALERTS_" == "yes" ]] && local ACTION=action_mwl || local ACTION=action_
+ [[ "$MAILALERTS" == "yes" ]] && local ACTION=action_mwl || local ACTION=action_
cat > /etc/fail2ban/jail.conf <<EOF
# The DEFAULT allows a global definition of the options. They can be overridden
@@ -113,12 +106,12 @@ EOF
ignoreip = 127.0.0.1/8
# "bantime" is the number of seconds that a host is banned.
-bantime = $BANTIME_
+bantime = $BANTIME
# A host is banned if it has generated "maxretry" during the last "findtime"
# seconds.
-findtime = $FINDTIME_
-maxretry = $MAXRETRY_
+findtime = $FINDTIME
+maxretry = $MAXRETRY
#
# ACTIONS
@@ -128,7 +121,7 @@ protocol = tcp
chain = INPUT
action_ = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
- sendmail-whois-lines[name=%(__name__)s, dest=$EMAIL_, sender=ncp-fail2ban@ownyourbits.com]
+ sendmail-whois-lines[name=%(__name__)s, dest=$EMAIL, sender=ncp-fail2ban@ownyourbits.com]
action = %($ACTION)s
#
@@ -141,7 +134,7 @@ enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
-maxretry = $MAXRETRY_
+maxretry = $MAXRETRY
#
# HTTP servers
@@ -153,7 +146,7 @@ enabled = true
port = http,https
filter = nextcloud
logpath = $NCLOG
-maxretry = $MAXRETRY_
+maxretry = $MAXRETRY
EOF
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
update-rc.d fail2ban defaults
diff --git a/etc/ncp-config.d/modsecurity.sh b/bin/ncp/SECURITY/modsecurity.sh
index 86d239e8..067404cd 100644
--- a/etc/ncp-config.d/modsecurity.sh
+++ b/bin/ncp/SECURITY/modsecurity.sh
@@ -8,14 +8,8 @@
# More at ownyourbits.com
#
-ACTIVE_=no
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()
{
@@ -93,10 +87,10 @@ configure()
</Directory>
EOF
- [[ $ACTIVE_ == "yes" ]] && local STATE=On || local STATE=Off
+ [[ $ACTIVE == "yes" ]] && local STATE=On || local STATE=Off
sed -i "s|SecRuleEngine .*|SecRuleEngine $STATE|" /etc/modsecurity/modsecurity.conf
- [[ $ACTIVE_ == "yes" ]] && echo "Enabling module security2" || echo "Disabling module security2"
- [[ $ACTIVE_ == "yes" ]] && a2enmod security2 &>/dev/null || a2dismod security2 &>/dev/null
+ [[ $ACTIVE == "yes" ]] && echo "Enabling module security2" || echo "Disabling module security2"
+ [[ $ACTIVE == "yes" ]] && a2enmod security2 &>/dev/null || a2dismod security2 &>/dev/null
# delayed in bg so it does not kill the connection, and we get AJAX response
bash -c "sleep 2 && service apache2 reload" &>/dev/null &
diff --git a/etc/ncp-config.d/nc-audit.sh b/bin/ncp/SECURITY/nc-audit.sh
index 5b032527..0668ecdb 100644
--- a/etc/ncp-config.d/nc-audit.sh
+++ b/bin/ncp/SECURITY/nc-audit.sh
@@ -8,7 +8,6 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-DESCRIPTION="Perform a security audit with lynis and debsecan"
install()
{
diff --git a/etc/ncp-config.d/nc-automount.sh b/bin/ncp/SYSTEM/nc-automount.sh
index 14c5437b..fd3bde8b 100644
--- a/etc/ncp-config.d/nc-automount.sh
+++ b/bin/ncp/SYSTEM/nc-automount.sh
@@ -8,17 +8,6 @@
# More at https://ownyourbits.com/
#
-ACTIVE_=no
-DESCRIPTION="Automount USB drives by plugging them in"
-
-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
-
-IMPORTANT: halt or umount the drive before extracting"
install()
{
@@ -99,7 +88,7 @@ EOF
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
systemctl stop nc-automount
systemctl stop nc-automount-links
systemctl disable nc-automount
diff --git a/etc/ncp-config.d/nc-hdd-monitor.sh b/bin/ncp/SYSTEM/nc-hdd-monitor.sh
index d6f2e60a..83b5f91d 100644
--- a/etc/ncp-config.d/nc-hdd-monitor.sh
+++ b/bin/ncp/SYSTEM/nc-hdd-monitor.sh
@@ -8,11 +8,7 @@
# More at https://ownyourbits.com
#
-ACTIVE_=no
-NOTIFYUSER_=ncp
-EMAIL_=optional@email.com
-DESCRIPTION="Monitor HDD health automatically"
is_active()
{
@@ -25,10 +21,9 @@ configure()
[[ ${#DRIVES[@]} == 0 ]] && {
echo "no drives detected. Disabling.."
- ACTIVE_=no
}
- [[ "$ACTIVE_" != yes ]] && {
+ [[ "$ACTIVE" != yes ]] && {
systemctl disable smartd
systemctl stop smartd
echo "HDD monitor disabled"
@@ -37,16 +32,16 @@ configure()
cat > /etc/smartd.conf <<EOF
# short scan every day at 1am, long one on sundays at 2am
-DEVICESCAN -a -m $EMAIL_ -M exec /usr/local/etc/ncp-hdd-notif.sh -s (S/../.././01|L/../../7/02)
+DEVICESCAN -a -m $EMAIL -M exec /usr/local/etc/ncp-hdd-notif.sh -s (S/../.././01|L/../../7/02)
EOF
cat > /usr/local/etc/ncp-hdd-notif.sh <<EOF
#!/bin/bash
EOF
- [[ "$EMAIL_" != "" ]] && {
+ [[ "$EMAIL" != "" ]] && {
cat >> /usr/local/etc/ncp-hdd-notif.sh <<EOF
-sendmail "$EMAIL_" <<EOFMAIL
+sendmail "$EMAIL" <<EOFMAIL
Subject: Hard drive problems found
"\$SMARTD_MESSAGE"
@@ -57,7 +52,7 @@ EOF
cat >> /usr/local/etc/ncp-hdd-notif.sh <<EOF
wall "\$SMARTD_MESSAGE"
sudo -u www-data php /var/www/nextcloud/occ notification:generate \
- $NOTIFYUSER_ "NextCloudPi HDD health \$SMARTD_FAILTYPE" \
+ $NOTIFYUSER "NextCloudPi HDD health \$SMARTD_FAILTYPE" \
-l "\$SMARTD_MESSAGE"
EOF
chmod +x /usr/local/etc/ncp-hdd-notif.sh
diff --git a/etc/ncp-config.d/nc-hdd-test.sh b/bin/ncp/SYSTEM/nc-hdd-test.sh
index 8490b40f..857d5878 100644
--- a/etc/ncp-config.d/nc-hdd-test.sh
+++ b/bin/ncp/SYSTEM/nc-hdd-test.sh
@@ -8,11 +8,7 @@
# More at https://ownyourbits.com
#
-SHORTTEST_=yes
-LONGTEST_=no
-DESCRIPTION="Check HDD health"
-INFO="Running no test will display test results"
install()
{
@@ -33,11 +29,11 @@ configure()
for dr in "${DRIVES[@]}"; do
smartctl --smart=on /dev/${dr} | sed 1,2d
- if [[ "$SHORTTEST_" == yes ]]; then
+ if [[ "$SHORTTEST" == yes ]]; then
echo "* Starting test on $dr. Check results later"
smartctl -X "/dev/$dr" &>/dev/null
smartctl -t short "/dev/$dr" | sed 1,2d
- elif [[ "$LONGTEST_" == yes ]]; then
+ elif [[ "$LONGTEST" == yes ]]; then
echo "* Starting test on $dr. Check results later"
smartctl -X "/dev/$dr" &>/dev/null
smartctl -t long "/dev/$dr" | sed 1,2d
diff --git a/etc/ncp-config.d/nc-info.sh b/bin/ncp/SYSTEM/nc-info.sh
index d03c53c1..db01118b 100644
--- a/etc/ncp-config.d/nc-info.sh
+++ b/bin/ncp/SYSTEM/nc-info.sh
@@ -8,7 +8,6 @@
# More at: https://ownyourbits.com
#
-DESCRIPTION="Print NextCloudPi system info"
install()
{
diff --git a/etc/ncp-config.d/nc-ramlogs.sh b/bin/ncp/SYSTEM/nc-ramlogs.sh
index cbca9a82..f34f3f74 100644
--- a/etc/ncp-config.d/nc-ramlogs.sh
+++ b/bin/ncp/SYSTEM/nc-ramlogs.sh
@@ -8,11 +8,7 @@
# More at https://ownyourbits.com/
#
-ACTIVE_=no
-DESCRIPTION="mount logs in RAM to prevent SD degradation (faster, consumes more RAM)"
-INFOTITLE="Warning"
-INFO="You need to reboot for this change to take effect"
is_active()
{
@@ -51,15 +47,9 @@ install()
configure()
{
- find_unit_name
- if [[ -z "$UNIT_NAME" ]]
- then
- echo "ERROR: log2ram service not found!"
- fi
-
- [[ $ACTIVE_ != "yes" ]] && {
- systemctl disable "$UNIT_NAME"
- systemctl stop "$UNIT_NAME"
+ [[ $ACTIVE != "yes" ]] && {
+ systemctl disable log2ram
+ systemctl stop log2ram
echo "Logs in SD. Reboot to take effect"
return
}
diff --git a/etc/ncp-config.d/nc-swapfile.sh b/bin/ncp/SYSTEM/nc-swapfile.sh
index e2799235..f74813f8 100644
--- a/etc/ncp-config.d/nc-swapfile.sh
+++ b/bin/ncp/SYSTEM/nc-swapfile.sh
@@ -8,9 +8,6 @@
# More at https://ownyourbits.com/
#
-SWAPFILE_=/media/USBdrive/swap
-SWAPSIZE_=1024
-DESCRIPTION="Move and resize your swapfile. Recommended to move to a permanent USB drive"
is_active()
{
@@ -21,9 +18,9 @@ is_active()
configure()
{
local ORIG="$( swapon | tail -1 | awk '{ print $1 }' )"
- local DSTDIR="$( dirname "$SWAPFILE_" )"
- [[ "$ORIG" == "$SWAPFILE_" ]] && { echo "nothing to do"; return 0; }
- [[ -d "$SWAPFILE_" ]] && { echo "$SWAPFILE_ is a directory. Abort"; return 1; }
+ local DSTDIR="$( dirname "$SWAPFILE" )"
+ [[ "$ORIG" == "$SWAPFILE" ]] && { echo "nothing to do"; return 0; }
+ [[ -d "$SWAPFILE" ]] && { echo "$SWAPFILE is a directory. Abort"; return 1; }
[[ -d "$DSTDIR" ]] || { echo "$DSTDIR Doesn't exist. Abort"; return 1; }
[[ "$( stat -fc%T "$DSTDIR" )" == "btrfs" ]] && {
@@ -34,8 +31,8 @@ configure()
[[ $( stat -fc%d / ) == $( stat -fc%d "$DSTDIR" ) ]] && \
echo -e "INFO: moving swapfile to another place in the same SD card\nIf you want to use an external mount, make sure it is properly set up"
- sed -i "s|#\?CONF_SWAPFILE=.*|CONF_SWAPFILE=$SWAPFILE_|" /etc/dphys-swapfile
- sed -i "s|#\?CONF_SWAPSIZE=.*|CONF_SWAPSIZE=$SWAPSIZE_|" /etc/dphys-swapfile
+ sed -i "s|#\?CONF_SWAPFILE=.*|CONF_SWAPFILE=$SWAPFILE|" /etc/dphys-swapfile
+ sed -i "s|#\?CONF_SWAPSIZE=.*|CONF_SWAPSIZE=$SWAPSIZE|" /etc/dphys-swapfile
grep -q vm.swappiness /etc/sysctl.conf || echo "vm.swappiness = 10" >> /etc/sysctl.conf && sysctl --load &>/dev/null
dphys-swapfile setup && dphys-swapfile swapon && {
diff --git a/etc/ncp-config.d/nc-wifi.sh b/bin/ncp/SYSTEM/nc-wifi.sh
index 18e52bd3..9c88239a 100644
--- a/etc/ncp-config.d/nc-wifi.sh
+++ b/bin/ncp/SYSTEM/nc-wifi.sh
@@ -8,18 +8,6 @@
# More at https://ownyourbits.com/
#
-ACTIVE_=no
-DESCRIPTION="Configure your Wi-Fi connection"
-
-INFOTITLE="Instructions to configure Wi-Fi"
-INFO="
-0) Write 'yes' to activate wifi, and 'no' to disable it
-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()
{
@@ -30,7 +18,7 @@ install()
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
systemctl stop wicd
systemctl disable wicd
systemctl start dhcpcd
diff --git a/etc/ncp-config.d/nc-zram.sh b/bin/ncp/SYSTEM/nc-zram.sh
index a7d57037..c8b47660 100644
--- a/etc/ncp-config.d/nc-zram.sh
+++ b/bin/ncp/SYSTEM/nc-zram.sh
@@ -8,8 +8,6 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-ACTIVE_=no
-DESCRIPTION="Enable compressed RAM to improve swap performance"
install()
{
@@ -65,7 +63,7 @@ chmod +x /usr/local/bin/ncp-zram
configure()
{
- [[ $ACTIVE_ != "yes" ]] && {
+ [[ $ACTIVE != "yes" ]] && {
systemctl stop zram
systemctl disable zram
echo "ZRAM disabled"
diff --git a/etc/ncp-config.d/unattended-upgrades.sh b/bin/ncp/SYSTEM/unattended-upgrades.sh
index eba93a5d..7f7405e0 100644
--- a/etc/ncp-config.d/unattended-upgrades.sh
+++ b/bin/ncp/SYSTEM/unattended-upgrades.sh
@@ -8,9 +8,6 @@
# More at: ownyourbits.com
#
-ACTIVE_=yes
-AUTOREBOOT_=yes
-DESCRIPTION="Automatic installation of security updates. Keep your cloud safe"
install()
{
@@ -21,8 +18,8 @@ install()
configure()
{
- [[ $ACTIVE_ == "yes" ]] && local AUTOUPGRADE=1 || local AUTOUPGRADE=0
- [[ $AUTOREBOOT_ == "yes" ]] && local AUTOREBOOT=true || local AUTOREBOOT=false
+ [[ $ACTIVE == "yes" ]] && local AUTOUPGRADE=1 || local AUTOUPGRADE=0
+ [[ $AUTOREBOOT == "yes" ]] && local AUTOREBOOT=true || local AUTOREBOOT=false
# Raspbian case
grep -q Raspbian /etc/issue && {
@@ -63,7 +60,7 @@ Dpkg::Options {
};
EOF
}
- echo "Unattended upgrades active: $ACTIVE_ (autoreboot $AUTOREBOOT_)"
+ echo "Unattended upgrades active: $ACTIVE (autoreboot $AUTOREBOOT)"
}
# License
diff --git a/etc/ncp-config.d/nc-fix-permissions.sh b/bin/ncp/TOOLS/nc-fix-permissions.sh
index d1cb578e..fc26bef2 100644
--- a/etc/ncp-config.d/nc-fix-permissions.sh
+++ b/bin/ncp/TOOLS/nc-fix-permissions.sh
@@ -8,7 +8,6 @@
# More at: https://ownyourbits.com
#
-DESCRIPTION="Fix permissions for NC data files, in case they were copied externally"
configure()
{
diff --git a/etc/ncp-config.d/nc-format-USB.sh b/bin/ncp/TOOLS/nc-format-USB.sh
index dcd2a926..587cc946 100644
--- a/etc/ncp-config.d/nc-format-USB.sh
+++ b/bin/ncp/TOOLS/nc-format-USB.sh
@@ -8,14 +8,6 @@
# More at: https://ownyourbits.com
#
-LABEL_=myCloudDrive
-DESCRIPTION="Format an external USB drive as a BTRFS partition (dangerous)"
-
-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 **"
configure()
{
@@ -47,12 +39,12 @@ configure()
parted /dev/"$NAME" --script -- mklabel gpt || return 2
parted /dev/"$NAME" --script -- mkpart primary 0% 100% || return 3
sleep 0.5
- mkfs.btrfs -q /dev/"${NAME}1" -f -L "$LABEL_"
+ mkfs.btrfs -q /dev/"${NAME}1" -f -L "$LABEL"
local RET=$?
# enable nc-automount if enabled
killall -CONT udiskie 2>/dev/null
- [ $RET -eq 0 ] && echo "Drive $NAME formatted successfuly and labeled $LABEL_"
+ [ $RET -eq 0 ] && echo "Drive $NAME formatted successfuly and labeled $LABEL"
return $RET
}
diff --git a/etc/ncp-config.d/nc-previews.sh b/bin/ncp/TOOLS/nc-previews.sh
index ef325a75..97388eb0 100644
--- a/etc/ncp-config.d/nc-previews.sh
+++ b/bin/ncp/TOOLS/nc-previews.sh
@@ -8,10 +8,6 @@
# More at nextcloudpi.com
#
-DESCRIPTION="Generate previews for the gallery"
-
-INFO="This will make browsing the gallery much more smooth.
-For big collections, this can take a LONG time, depending on your hardware"
configure()
{
diff --git a/etc/ncp-config.d/nc-scan.sh b/bin/ncp/TOOLS/nc-scan.sh
index 70b7570a..b8b40507 100644
--- a/etc/ncp-config.d/nc-scan.sh
+++ b/bin/ncp/TOOLS/nc-scan.sh
@@ -8,7 +8,6 @@
# More at: https://ownyourbits.com
#
-DESCRIPTION="Scan NC for externally modified files"
install()
{
diff --git a/etc/ncp-config.d/nc-update-nextcloud.sh b/bin/ncp/TOOLS/nc-update-nextcloud.sh
index 664baad6..eb5cbbed 100644
--- a/etc/ncp-config.d/nc-update-nextcloud.sh
+++ b/bin/ncp/TOOLS/nc-update-nextcloud.sh
@@ -8,15 +8,11 @@
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
-VERSION_=0
LATEST=14.0.4
-DESCRIPTION="Update current instance to a new Nextcloud version"
-INFO="Set to 0 to update to the latest avaliable version"
configure()
{
- [[ "$VERSION_" == "0" ]] && VERSION_="$LATEST"
- bash /usr/local/bin/ncp-update-nc "$VERSION_"
+ bash /usr/local/bin/ncp-update-nc "$VERSION"
}
install() { :; }
diff --git a/etc/ncp-config.d/nc-update.sh b/bin/ncp/TOOLS/nc-update.sh
index 6f297dd3..7394c833 100644
--- a/etc/ncp-config.d/nc-update.sh
+++ b/bin/ncp/TOOLS/nc-update.sh
@@ -8,7 +8,6 @@
# More at https://ownyourbits.com/
#
-DESCRIPTION="Update NextCloudPi"
configure()
{
diff --git a/build-SD-rpi.sh b/build-SD-rpi.sh
index 6dcb5bea..8d88f4f5 100755
--- a/build-SD-rpi.sh
+++ b/build-SD-rpi.sh
@@ -57,12 +57,12 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
# install everything
cd /tmp/ncp-build || exit 1
source etc/library.sh
- install_script lamp.sh
- install_script etc/ncp-config.d/nc-nextcloud.sh
- activate_script etc/ncp-config.d/nc-nextcloud.sh
- install_script ncp.sh
- activate_script etc/ncp-config.d/nc-init.sh
- install_script post-inst.sh
+ install_app lamp.sh
+ install_app etc/ncp-config.d/nc-nextcloud.sh
+ run_app etc/ncp-config.d/nc-nextcloud.sh
+ install_app ncp.sh
+ run_app etc/ncp-config.d/nc-init.sh
+ run_app post-inst.sh
# harden SSH further for Raspbian
sed -i 's|^#PermitRootLogin .*|PermitRootLogin no|' /etc/ssh/sshd_config
diff --git a/docker-armhf/lamp/Dockerfile b/docker-armhf/lamp/Dockerfile
index 93d7056b..bc3b68fe 100644
--- a/docker-armhf/lamp/Dockerfile
+++ b/docker-armhf/lamp/Dockerfile
@@ -13,7 +13,7 @@ RUN \
# installation
source /usr/local/etc/library.sh; \
set +x; \
-install_script /usr/local/etc/lamp.sh; \
+install_app /usr/local/etc/lamp.sh; \
# stop mysqld
mysqladmin -u root shutdown; \
diff --git a/docker-armhf/nextcloud/Dockerfile b/docker-armhf/nextcloud/Dockerfile
index fc6cf447..b923ea2b 100644
--- a/docker-armhf/nextcloud/Dockerfile
+++ b/docker-armhf/nextcloud/Dockerfile
@@ -7,7 +7,8 @@ SHELL ["/bin/bash", "-c"]
ENV DOCKERBUILD 1
COPY etc/library.sh /usr/local/etc/
-COPY etc/ncp-config.d/nc-init.sh etc/ncp-config.d/nc-nextcloud.sh /
+COPY bin/ncp/CONFIG/nc-nextcloud.sh /
+COPY etc/ncp-config.d/nc-nextcloud.cfg /usr/local/etc/ncp-config.d/
RUN \
@@ -16,11 +17,11 @@ touch /.ncp-image; \
# installation ( /var/www/nextcloud -> /data/app which will be in a volume )
apt-get update; \
-apt-get install --no-install-recommends -y wget ca-certificates sudo; \
+apt-get install --no-install-recommends -y wget ca-certificates sudo jq; \
source /usr/local/etc/library.sh; \
set +x; \
-install_script /nc-nextcloud.sh; \
-activate_script /nc-nextcloud.sh; \
+install_app /nc-nextcloud.sh; \
+run_app_unsafe /nc-nextcloud.sh; \
mv /var/www/nextcloud /data-ro/app; \
ln -s /data-ro/app /var/www/nextcloud; \
@@ -38,7 +39,7 @@ rm -f /var/log/alternatives.log /var/log/apt/*; \
# specific cleanup
apt-get purge -y wget ca-certificates; \
-rm /nc-nextcloud.sh; \
+rm /nc-nextcloud.sh /usr/local/etc/ncp-config.d/nc-nextcloud.cfg; \
rm /.ncp-image;
COPY docker-common/nextcloud/020nextcloud /etc/services-enabled.d/
diff --git a/docker-armhf/nextcloudpi/Dockerfile b/docker-armhf/nextcloudpi/Dockerfile
index b5ce45ef..7d7dd96c 100644
--- a/docker-armhf/nextcloudpi/Dockerfile
+++ b/docker-armhf/nextcloudpi/Dockerfile
@@ -7,7 +7,7 @@ SHELL ["/bin/bash", "-c"]
ENV DOCKERBUILD 1
RUN mkdir -p /tmp/ncp-build
-COPY bin/* /tmp/ncp-build/bin/
+COPY bin/ /tmp/ncp-build/bin/
COPY etc /tmp/ncp-build/etc/
COPY ncp.sh update.sh /tmp/ncp-build/
COPY ncp-web /tmp/ncp-build/ncp-web/
@@ -31,19 +31,18 @@ apt-get install --no-install-recommends -y wget ca-certificates; \
source /usr/local/etc/library.sh; \
set +x; \
cd /tmp/ncp-build/; \
-install_script ncp.sh; \
+install_app ncp.sh; \
# fix default paths
-sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup.sh; \
+sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup.cfg; \
# specific cleanup
-rm -r /tmp/ncp-build; \
+cd /; rm -r /tmp/ncp-build; \
rm /.ncp-image; \
# cleanup all NCP extras
source /usr/local/etc/library.sh; \
-cd /usr/local/etc/ncp-config.d/; \
-for script in *.sh; do cleanup_script $script; done; \
+find /usr/local/bin/ncp -name '*.sh' | while read l; do cleanup_script $l; done; \
# should be cleaned up in no-ip.sh, but breaks udiskie.
# safe to do it here since no automount in docker
@@ -60,6 +59,9 @@ rm -f /var/log/alternatives.log /var/log/apt/*; \
rm /var/cache/debconf/*-old;
COPY docker-common/nextcloudpi/000ncp /etc/services-enabled.d/
+COPY bin/ncp/CONFIG/nc-init.sh /
+COPY etc/ncp-config.d/nc-init.cfg /usr/local/etc/ncp-config.d/
+
# 4443 - ncp-web
EXPOSE 80 443 4443
diff --git a/docker-common/debian-ncp/run-parts.sh b/docker-common/debian-ncp/run-parts.sh
index c2a04b79..ad4ac6ff 100755
--- a/docker-common/debian-ncp/run-parts.sh
+++ b/docker-common/debian-ncp/run-parts.sh
@@ -1,6 +1,5 @@
#!/bin/bash
-
cleanup()
{
for file in $( ls -1rv /etc/services-enabled.d ); do
diff --git a/docker-common/nextcloud/020nextcloud b/docker-common/nextcloud/020nextcloud
index 3521b789..ae1429af 100755
--- a/docker-common/nextcloud/020nextcloud
+++ b/docker-common/nextcloud/020nextcloud
@@ -36,7 +36,7 @@ postfix start
test -f /data/app/config/config.php || {
echo "Uninitialized instance, running nc-init..."
source /usr/local/etc/library.sh
- activate_script /nc-init.sh
+ run_app_unsafe /nc-init.sh
mv /index.php /var/www/nextcloud/ # restore this file after init
}
diff --git a/docker/lamp/Dockerfile b/docker/lamp/Dockerfile
index 2736b11f..b92b1435 100644
--- a/docker/lamp/Dockerfile
+++ b/docker/lamp/Dockerfile
@@ -13,7 +13,7 @@ RUN \
# installation
source /usr/local/etc/library.sh; \
set +x; \
-install_script /usr/local/etc/lamp.sh; \
+install_app /usr/local/etc/lamp.sh; \
# stop mysqld
mysqladmin -u root shutdown; \
diff --git a/docker/nextcloud/Dockerfile b/docker/nextcloud/Dockerfile
index a9c71f76..49f1675d 100644
--- a/docker/nextcloud/Dockerfile
+++ b/docker/nextcloud/Dockerfile
@@ -7,7 +7,8 @@ SHELL ["/bin/bash", "-c"]
ENV DOCKERBUILD 1
COPY etc/library.sh /usr/local/etc/
-COPY etc/ncp-config.d/nc-init.sh etc/ncp-config.d/nc-nextcloud.sh /
+COPY bin/ncp/CONFIG/nc-nextcloud.sh /
+COPY etc/ncp-config.d/nc-nextcloud.cfg /usr/local/etc/ncp-config.d/
RUN \
@@ -16,11 +17,11 @@ touch /.ncp-image; \
# installation ( /var/www/nextcloud -> /data/app which will be in a volume )
apt-get update; \
-apt-get install --no-install-recommends -y wget ca-certificates sudo; \
+apt-get install --no-install-recommends -y wget ca-certificates sudo jq; \
source /usr/local/etc/library.sh; \
set +x; \
-install_script /nc-nextcloud.sh; \
-activate_script /nc-nextcloud.sh; \
+install_app /nc-nextcloud.sh; \
+run_app_unsafe /nc-nextcloud.sh; \
mv /var/www/nextcloud /data-ro/app; \
ln -s /data-ro/app /var/www/nextcloud; \
@@ -38,7 +39,7 @@ rm -f /var/log/alternatives.log /var/log/apt/*; \
# specific cleanup
apt-get purge -y wget ca-certificates; \
-rm /nc-nextcloud.sh; \
+rm /nc-nextcloud.sh /usr/local/etc/ncp-config.d/nc-nextcloud.cfg; \
rm /.ncp-image;
COPY docker-common/nextcloud/020nextcloud /etc/services-enabled.d/
diff --git a/docker/nextcloudpi/Dockerfile b/docker/nextcloudpi/Dockerfile
index 1458cd9d..0583ebc4 100644
--- a/docker/nextcloudpi/Dockerfile
+++ b/docker/nextcloudpi/Dockerfile
@@ -7,7 +7,7 @@ SHELL ["/bin/bash", "-c"]
ENV DOCKERBUILD 1
RUN mkdir -p /tmp/ncp-build
-COPY bin/* /tmp/ncp-build/bin/
+COPY bin/ /tmp/ncp-build/bin/
COPY etc /tmp/ncp-build/etc/
COPY ncp.sh update.sh /tmp/ncp-build/
COPY ncp-web /tmp/ncp-build/ncp-web/
@@ -31,19 +31,18 @@ apt-get install --no-install-recommends -y wget ca-certificates; \
source /usr/local/etc/library.sh; \
set +x; \
cd /tmp/ncp-build/; \
-install_script ncp.sh; \
+install_app ncp.sh; \
# fix default paths
-sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup.sh; \
+sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup.cfg; \
# specific cleanup
-rm -r /tmp/ncp-build; \
+cd /; rm -r /tmp/ncp-build; \
rm /.ncp-image; \
# cleanup all NCP extras
source /usr/local/etc/library.sh; \
-cd /usr/local/etc/ncp-config.d/; \
-for script in *.sh; do cleanup_script $script; done; \
+find /usr/local/bin/ncp -name '*.sh' | while read l; do cleanup_script $l; done; \
# should be cleaned up in no-ip.sh, but breaks udiskie.
# safe to do it here since no automount in docker
@@ -60,6 +59,9 @@ rm -f /var/log/alternatives.log /var/log/apt/*; \
rm /var/cache/debconf/*-old;
COPY docker-common/nextcloudpi/000ncp /etc/services-enabled.d/
+COPY bin/ncp/CONFIG/nc-init.sh /
+COPY etc/ncp-config.d/nc-init.cfg /usr/local/etc/ncp-config.d/
+
# 4443 - ncp-web
EXPOSE 80 443 4443
diff --git a/etc/library.sh b/etc/library.sh
index abf30697..0282b9e7 100644
--- a/etc/library.sh
+++ b/etc/library.sh
@@ -8,172 +8,211 @@
# More at ownyourbits.com
#
+CFGDIR=/usr/local/etc/ncp-config.d
+BINDIR=/usr/local/bin/ncp
-# Initializes $INSTALLATION_CODE
-function config()
+function configure_app()
{
- local INSTALL_SCRIPT="$1"
- local BACKTITLE="NextCloudPi installer configuration"
+ local ncp_app="$1"
+ local cfg_file="$CFGDIR/$ncp_app.cfg"
+ local backtitle="NextCloudPi installer configuration"
+ local ret=1
+ # checks
type dialog &>/dev/null || { echo "please, install dialog for interactive configuration"; return 1; }
-
- test -f "$INSTALL_SCRIPT" || { echo "file $INSTALL_SCRIPT not found"; return 1; }
- local VARS=( $( grep "^[[:alpha:]]\+_=" "$INSTALL_SCRIPT" | sed 's|_=.*$||' ) )
- local VALS=( $( grep "^[[:alpha:]]\+_=" "$INSTALL_SCRIPT" | sed 's|^.*_=||' ) )
-
- [[ "$NO_CONFIG" == "1" ]] || test ${#VARS[@]} -eq 0 && { INSTALLATION_CODE="$( cat "$INSTALL_SCRIPT" )"; return; }
-
- for i in $( seq 1 1 ${#VARS[@]} ); do
- local PARAM+="${VARS[$((i-1))]} $i 1 ${VALS[$((i-1))]} $i 15 60 120 "
+ [[ -f "$cfg_file" ]] || return 0;
+
+ local cfg="$( cat "$cfg_file" )"
+ local len="$(jq '.params | length' <<<"$cfg")"
+ [[ $len -eq 0 ]] && return
+
+ # read cfg parameters
+ for (( i = 0 ; i < len ; i++ )); do
+ local var="$(jq -r ".params[$i].id" <<<"$cfg")"
+ local val="$(jq -r ".params[$i].value" <<<"$cfg")"
+ local vars+=("$var")
+ local vals+=("$val")
+ local idx=$((i+1))
+ local parameters+="$var $idx 1 $val $idx 15 60 120 "
done
+ # dialog
local DIALOG_OK=0
local DIALOG_CANCEL=1
local DIALOG_ERROR=254
local DIALOG_ESC=255
- local RET=0
+ local res=0
- while test $RET != 1 && test $RET != 250; do
+ while test $res != 1 && test $res != 250; do
local value
value="$( dialog --ok-label "Start" \
- --no-lines --backtitle "$BACKTITLE" \
- --form "Enter configuration for $( basename "$INSTALL_SCRIPT" .sh )" \
- 20 70 0 $PARAM \
+ --no-lines --backtitle "$backtitle" \
+ --form "Enter configuration for $ncp_app" \
+ 20 70 0 $parameters \
3>&1 1>&2 2>&3 )"
- RET=$?
- case $RET in
+ res=$?
+
+ case $res in
$DIALOG_CANCEL)
- return 1
+ break
;;
$DIALOG_OK)
- local RET_VALS=()
- while read l; do RET_VALS+=("$l"); done < <( echo -e "$value" )
-
- for i in $( seq 0 1 $(( ${#RET_VALS[@]} - 1 )) ); do
+ while read val; do local ret_vals+=("$val"); done <<<"$value"
+ for (( i = 0 ; i < len ; i++ )); do
# check for invalid characters
- grep -q "[&[:space:]]" <<< "${RET_VALS[$i]}" && { echo "Invalid characters in field ${VARS[$i]}"; return 1; }
+ grep -q "[;&[:space:]]" <<< "${ret_vals[$i]}" && { echo "Invalid characters in field ${vars[$i]}"; break; }
- local SEDRULE+="s|^${VARS[$i]}_=.*|${VARS[$i]}_=${RET_VALS[$i]}|;"
+ cfg="$(jq ".params[$i].value = \"${ret_vals[$i]}\"" <<<"$cfg")"
done
+ ret=0
break
;;
$DIALOG_ERROR)
echo "ERROR!$value"
- return 1
+ break
;;
$DIALOG_ESC)
echo "ESC pressed."
- return 1
+ break
;;
*)
- echo "Return code was $RET"
- return 1
+ echo "Return code was $res"
+ break
;;
esac
done
- INSTALLATION_CODE="$( sed "$SEDRULE" "$INSTALL_SCRIPT" )"
+ echo "$cfg" > "$cfg_file"
+ printf '\033[2J' && tput cup 0 0 # clear screen, don't clear scroll, cursor on top
+ return $ret
}
-function install_script()
+function run_app()
{
- (
- local SCRIPT=$1
- source ./"$SCRIPT"
- echo -e "Installing $( basename "$SCRIPT" .sh )"
- set +x
- install
- )
-}
+ local ncp_app=$1
+ local script="$(find "$BINDIR" -name $ncp_app.sh)"
-function activate_script()
-{
- local SCRIPT=$1
- echo -e "Activating $( basename "$SCRIPT" .sh )"
- launch_script "$SCRIPT"
-}
+ [[ -f "$script" ]] || { echo "file $script not found"; return 1; }
-function is_active_script()
-{
- (
- local SCRIPT=$1
- unset is_active
- source "$SCRIPT"
- [[ $( type -t is_active ) == function ]] && {
- is_active
- return $?
- }
- grep -q "^ACTIVE_=yes" "$SCRIPT" && return 0
- )
+ run_app_unsafe "$script"
}
-function run_and_log()
+# receives a script file, no security checks
+function run_app_unsafe()
{
- local SCRIPT=$1
- touch /var/log/ncp.log
- chmod 640 /var/log/ncp.log
- chown root:www-data /var/log/ncp.log
- echo -e "[ $( basename "$SCRIPT" .sh ) ]" >> /var/log/ncp.log
- configure 2>&1 | tee -a /var/log/ncp.log
- local RET="${PIPESTATUS[0]}"
- echo "" >> /var/log/ncp.log
- return "$RET"
+ local script=$1
+ local ncp_app="$(basename "$script" .sh)"
+ local cfg_file="$CFGDIR/$ncp_app.cfg"
+ local log=/var/log/ncp.log
+
+ [[ -f "$script" ]] || { echo "file $script not found"; return 1; }
+
+ touch $log
+ chmod 640 $log
+ chown root:www-data $log
+
+ echo "Running $ncp_app"
+ echo "[ $ncp_app ]" >> $log
+
+ # read script
+ unset configure
+ source "$script"
+
+ # read cfg parameters
+ [[ -f "$cfg_file" ]] && {
+ local cfg="$( cat "$cfg_file" )"
+ local len="$(jq '.params | length' <<<"$cfg")"
+ for (( i = 0 ; i < len ; i++ )); do
+ local var="$(jq -r ".params[$i].id" <<<"$cfg")"
+ local val="$(jq -r ".params[$i].value" <<<"$cfg")"
+ eval "$var=$val"
+ done
+ }
+
+ # run
+ configure 2>&1 | tee -a $log
+ local ret="${PIPESTATUS[0]}"
+
+ echo "" >> $log
+
+ return "$ret"
}
-function launch_script()
+function is_active_app()
{
- (
- local SCRIPT=$1
- source ./"$SCRIPT"
- set +x
- run_and_log "$SCRIPT"
- )
+ local ncp_app=$1
+ local bin_dir=${2:-.}
+ local script="$bin_dir/$ncp_app.sh"
+ local cfg_file="$CFGDIR/$ncp_app.cfg"
+
+ [[ -f "$script" ]] || local script="$(find "$BINDIR" -name $ncp_app.sh)"
+ [[ -f "$script" ]] || { echo "file $script not found"; return 1; }
+
+ # function
+ unset is_active
+ source "$script"
+ [[ $( type -t is_active ) == function ]] && { is_active; return $?; }
+
+ # config
+ [[ -f "$cfg_file" ]] || return 1
+
+ local cfg="$( cat "$cfg_file" )"
+ [[ "$(jq -r ".params[0].id" <<<"$cfg")" == "ACTIVE" ]] && \
+ [[ "$(jq -r ".params[0].value" <<<"$cfg")" == "yes" ]] && \
+ return 0
}
# show an info box for a script if the INFO variable is set in the script
-function info_script()
+function info_app()
{
- (
- local SCRIPT=$1
- cd /usr/local/etc/ncp-config.d/ || return 1
- unset show_info INFO INFOTITLE
- source ./"$SCRIPT"
- local INFOTITLE="${INFOTITLE:-Info}"
- [[ "$INFO" == "" ]] && return 0
- whiptail --yesno --backtitle "NextCloudPi configuration" --title "$INFOTITLE" "$INFO" 20 90
- )
+ local ncp_app=$1
+ local cfg_file="$CFGDIR/$ncp_app.cfg"
+
+ local cfg="$( cat "$cfg_file" 2>/dev/null )"
+ local info=$( jq -r .info <<<"$cfg" )
+ local infotitle=$( jq -r .infotitle <<<"$cfg" )
+
+ [[ "$info" == "" ]] || [[ "$info" == "null" ]] && return 0
+ [[ "$infotitle" == "" ]] || [[ "$infotitle" == "null" ]] && infotitle="Info"
+
+ whiptail --yesno \
+ --backtitle "NextCloudPi configuration" \
+ --title "$infotitle" \
+ --yes-button "I understand" \
+ --no-button "Go back" \
+ "$info" 20 90
}
-function configure_script()
+function install_app()
{
- (
- local SCRIPT=$1
- cd /usr/local/etc/ncp-config.d/ || return 1
- config "$SCRIPT" || return 1 # writes "$INSTALLATION_CODE"
- echo -e "$INSTALLATION_CODE" > "$SCRIPT" # save configuration
- source ./"$SCRIPT" # load configuration
- printf '\033[2J' && tput cup 0 0 # clear screen, don't clear scroll, cursor on top
- echo -e "Launching $( basename "$SCRIPT" .sh )"
- set +x
- run_and_log "$SCRIPT"
- return 0
- )
+ local ncp_app=$1
+
+ # $1 can be either an installed app name or an app script
+ if [[ -f "$ncp_app" ]]; then
+ local script="$ncp_app"
+ local ncp_app="$(basename "$script" .sh)"
+ else
+ local script="$(find "$BINDIR" -name $ncp_app.sh)"
+ fi
+
+ # do it
+ unset install
+ source "$script"
+ echo "Installing $ncp_app"
+ (install)
}
function cleanup_script()
{
- (
- local SCRIPT=$1
- cd /usr/local/etc/ncp-config.d/ || return 1
- unset cleanup
- source ./"$SCRIPT"
- if [[ $( type -t cleanup ) == function ]]; then
- cleanup
- return $?
- fi
- return 0
- )
+ local script=$1
+ unset cleanup
+ source "$script"
+ if [[ $( type -t cleanup ) == function ]]; then
+ cleanup
+ return $?
+ fi
+ return 0
}
function persistent_cfg()
diff --git a/etc/ncp-config.d/DDNS_duckDNS.cfg b/etc/ncp-config.d/DDNS_duckDNS.cfg
new file mode 100644
index 00000000..2341691a
--- /dev/null
+++ b/etc/ncp-config.d/DDNS_duckDNS.cfg
@@ -0,0 +1,26 @@
+{
+ "id": "DDNS_duckDNS",
+ "name": "DDNS_duckDNS",
+ "title": "DDNS_duckDNS",
+ "description": "Free Dynamic DNS provider (need account from https://duckdns.org)",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "DOMAIN",
+ "name": "DOMAIN",
+ "value": "mycloud.duckdns.org"
+ },
+ {
+ "id": "TOKEN",
+ "name": "TOKEN",
+ "value": "your-duckdns-token"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/DDNS_freeDNS.cfg b/etc/ncp-config.d/DDNS_freeDNS.cfg
new file mode 100644
index 00000000..fc2f6fc0
--- /dev/null
+++ b/etc/ncp-config.d/DDNS_freeDNS.cfg
@@ -0,0 +1,31 @@
+{
+ "id": "DDNS_freeDNS",
+ "name": "DDNS_freeDNS",
+ "title": "DDNS_freeDNS",
+ "description": "DDNS FreeDNS client (need account)",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "UPDATEHASH",
+ "name": "UPDATEHASH",
+ "value": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567"
+ },
+ {
+ "id": "DOMAIN",
+ "name": "DOMAIN",
+ "value": "mynextcloud.example.com"
+ },
+ {
+ "id": "UPDATEINTERVAL",
+ "name": "UPDATEINTERVAL",
+ "value": "30"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/DDNS_no-ip.cfg b/etc/ncp-config.d/DDNS_no-ip.cfg
new file mode 100644
index 00000000..df7e04b4
--- /dev/null
+++ b/etc/ncp-config.d/DDNS_no-ip.cfg
@@ -0,0 +1,36 @@
+{
+ "id": "DDNS_no-ip",
+ "name": "DDNS_no-ip",
+ "title": "DDNS_no-ip",
+ "description": "DDNS no-ip free provider (need account)",
+ "info": "For this step to succeed, you need to register a noip account first.\nInternet access is required for this configuration to complete.",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "USER",
+ "name": "USER",
+ "value": "my-noip-user@email.com"
+ },
+ {
+ "id": "PASS",
+ "name": "PASS",
+ "value": "noip-pass"
+ },
+ {
+ "id": "DOMAIN",
+ "name": "DOMAIN",
+ "value": "mycloud.ownyourbits.com"
+ },
+ {
+ "id": "TIME",
+ "name": "TIME",
+ "value": "30"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/DDNS_spDYN.cfg b/etc/ncp-config.d/DDNS_spDYN.cfg
new file mode 100644
index 00000000..130b6494
--- /dev/null
+++ b/etc/ncp-config.d/DDNS_spDYN.cfg
@@ -0,0 +1,26 @@
+{
+ "id": "DDNS_spDYN",
+ "name": "DDNS_spDYN",
+ "title": "DDNS_spDYN",
+ "description": "Free Dynamic DNS provider (need account from spdyn.de)",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "DOMAIN",
+ "name": "DOMAIN",
+ "value": "mycloud.spdns.de"
+ },
+ {
+ "id": "TOKEN",
+ "name": "TOKEN",
+ "value": "your-spdns-token"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/NFS.cfg b/etc/ncp-config.d/NFS.cfg
new file mode 100644
index 00000000..38298e74
--- /dev/null
+++ b/etc/ncp-config.d/NFS.cfg
@@ -0,0 +1,36 @@
+{
+ "id": "NFS",
+ "name": "NFS",
+ "title": "NFS",
+ "description": "NFS network file system server (for Linux LAN)",
+ "info": "If we intend to modify the data folder through NFS,\nthen we have to synchronize NextCloud to make it aware of the changes.\n\nThis can be done manually or automatically using 'nc-scan' and 'nc-scan-auto'",
+ "infotitle": "Instructions for external synchronization",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "DIR",
+ "name": "DIR",
+ "value": "/media/USBdrive/ncdata/admin/files"
+ },
+ {
+ "id": "SUBNET",
+ "name": "SUBNET",
+ "value": "192.168.1.0/24"
+ },
+ {
+ "id": "USER",
+ "name": "USER",
+ "value": "www-data"
+ },
+ {
+ "id": "GROUP",
+ "name": "GROUP",
+ "value": "www-data"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/SSH.cfg b/etc/ncp-config.d/SSH.cfg
new file mode 100644
index 00000000..947faed5
--- /dev/null
+++ b/etc/ncp-config.d/SSH.cfg
@@ -0,0 +1,31 @@
+{
+ "id": "SSH",
+ "name": "SSH",
+ "title": "SSH",
+ "description": "Activate or deactivate SSH",
+ "info": "In order to enable SSH, the password for user 'pi' can NOT remain set to the default raspberry. \nYou HAVE to create a NEW password for 'pi' if you want this program to enable SSH, it will fail if you dont!\nThe same will happen with user 'root' and password '1234'\nNote: Use normal AlphaNumeric, the only special characters allowed are .,@-_/",
+ "infotitle": "SSH notes",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "USER",
+ "name": "USER",
+ "value": "root"
+ },
+ {
+ "id": "PASS",
+ "name": "PASS",
+ "value": "1234"
+ },
+ {
+ "id": "CONFIRM",
+ "name": "CONFIRM",
+ "value": "1234"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/UFW.cfg b/etc/ncp-config.d/UFW.cfg
new file mode 100644
index 00000000..0bf29a86
--- /dev/null
+++ b/etc/ncp-config.d/UFW.cfg
@@ -0,0 +1,31 @@
+{
+ "id": "UFW",
+ "name": "UFW",
+ "title": "UFW",
+ "description": "Uncomplicated Firewall",
+ "info": "Beware of blocking the SSH port you are using!",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "HTTP",
+ "name": "HTTP",
+ "value": "80"
+ },
+ {
+ "id": "HTTPS",
+ "name": "HTTPS",
+ "value": "443"
+ },
+ {
+ "id": "SSH",
+ "name": "SSH",
+ "value": "22"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/dnsmasq.cfg b/etc/ncp-config.d/dnsmasq.cfg
new file mode 100644
index 00000000..8a66d38d
--- /dev/null
+++ b/etc/ncp-config.d/dnsmasq.cfg
@@ -0,0 +1,31 @@
+{
+ "id": "dnsmasq",
+ "name": "dnsmasq",
+ "title": "dnsmasq",
+ "description": "DNS server with cache",
+ "info": "Remember to point your PC and devices DNS or\nyou router DNS to your Raspberry Pi IP",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "DOMAIN",
+ "name": "DOMAIN",
+ "value": "mycloud.ownyourbits.com"
+ },
+ {
+ "id": "DNSSERVER",
+ "name": "DNSSERVER",
+ "value": "8.8.8.8"
+ },
+ {
+ "id": "CACHESIZE",
+ "name": "CACHESIZE",
+ "value": "150"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/fail2ban.cfg b/etc/ncp-config.d/fail2ban.cfg
new file mode 100644
index 00000000..cfaaad19
--- /dev/null
+++ b/etc/ncp-config.d/fail2ban.cfg
@@ -0,0 +1,42 @@
+{
+ "id": "fail2ban",
+ "name": "fail2ban",
+ "title": "fail2ban",
+ "description": "Brute force protection for SSH and NextCloud",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "BANTIME",
+ "name": "BANTIME",
+ "value": "600"
+ },
+ {
+ "id": "FINDTIME",
+ "name": "FINDTIME",
+ "value": "600"
+ },
+ {
+ "id": "MAXRETRY",
+ "name": "MAXRETRY",
+ "value": "6"
+ },
+ {
+ "id": "MAILALERTS",
+ "name": "MAILALERTS",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "EMAIL",
+ "name": "EMAIL",
+ "value": "optional@email.com"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/letsencrypt.cfg b/etc/ncp-config.d/letsencrypt.cfg
new file mode 100644
index 00000000..4c3a56f9
--- /dev/null
+++ b/etc/ncp-config.d/letsencrypt.cfg
@@ -0,0 +1,25 @@
+{
+ "id": "letsencrypt",
+ "name": "letsencrypt",
+ "title": "letsencrypt",
+ "description": "Automatic signed SSL certificates",
+ "info": "Internet access is required for this configuration to complete\nBoth ports 80 and 443 need to be accessible from the internet\n \nYour certificate will be automatically renewed every month",
+ "infotitle": "Warning",
+ "params": [
+ {
+ "id": "DOMAIN",
+ "name": "DOMAIN",
+ "value": "mycloud.ownyourbits.com"
+ },
+ {
+ "id": "EMAIL",
+ "name": "EMAIL",
+ "value": "mycloud@ownyourbits.com"
+ },
+ {
+ "id": "NOTIFYUSER",
+ "name": "NOTIFYUSER",
+ "value": "ncp"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/modsecurity.cfg b/etc/ncp-config.d/modsecurity.cfg
new file mode 100644
index 00000000..504147e9
--- /dev/null
+++ b/etc/ncp-config.d/modsecurity.cfg
@@ -0,0 +1,16 @@
+{
+ "id": "modsecurity",
+ "name": "modsecurity",
+ "title": "modsecurity",
+ "description": "Web Application Firewall for extra security (experimental)",
+ "info": "This feature is highly experimental and has only been tested with\na basic NextCloud installation. If a new App does not work disable it",
+ "infotitle": "Experimental feature warning",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-admin.cfg b/etc/ncp-config.d/nc-admin.cfg
new file mode 100644
index 00000000..d2d97e81
--- /dev/null
+++ b/etc/ncp-config.d/nc-admin.cfg
@@ -0,0 +1,25 @@
+{
+ "id": "nc-admin",
+ "name": "nc-admin",
+ "title": "nc-admin",
+ "description": "Change password for the Nextcloud admin user",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "USER",
+ "name": "USER",
+ "value": "ncp"
+ },
+ {
+ "id": "PASSWORD",
+ "name": "PASSWORD",
+ "value": "ownyourbits"
+ },
+ {
+ "id": "CONFIRM",
+ "name": "CONFIRM",
+ "value": "ownyourbits"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-audit.cfg b/etc/ncp-config.d/nc-audit.cfg
new file mode 100644
index 00000000..b02a62cb
--- /dev/null
+++ b/etc/ncp-config.d/nc-audit.cfg
@@ -0,0 +1,9 @@
+{
+ "id": "nc-audit",
+ "name": "nc-audit",
+ "title": "nc-audit",
+ "description": "Perform a security audit with lynis and debsecan",
+ "info": "",
+ "infotitle": "",
+ "params": []
+}
diff --git a/etc/ncp-config.d/nc-automount.cfg b/etc/ncp-config.d/nc-automount.cfg
new file mode 100644
index 00000000..7a25c5a4
--- /dev/null
+++ b/etc/ncp-config.d/nc-automount.cfg
@@ -0,0 +1,16 @@
+{
+ "id": "nc-automount",
+ "name": "nc-automount",
+ "title": "nc-automount",
+ "description": "Automount USB drives by plugging them in",
+ "info": "Plugged in USB drives will be automounted under /media\non boot or at the moment of insertion.\n\nFormat your drive as ext4 in order to move NC datafolder or database\nVFAT or NTFS is not recommended for this task, as it does not suport permissions\n\nIMPORTANT: halt or umount the drive before extracting",
+ "infotitle": "Automount notes",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-autoupdate-nc.cfg b/etc/ncp-config.d/nc-autoupdate-nc.cfg
new file mode 100644
index 00000000..35f4eb60
--- /dev/null
+++ b/etc/ncp-config.d/nc-autoupdate-nc.cfg
@@ -0,0 +1,21 @@
+{
+ "id": "nc-autoupdate-nc",
+ "name": "nc-autoupdate-nc",
+ "title": "nc-autoupdate-nc",
+ "description": "Automatically apply Nextcloud updates",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "NOTIFYUSER",
+ "name": "NOTIFYUSER",
+ "value": "ncp"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-autoupdate-ncp.cfg b/etc/ncp-config.d/nc-autoupdate-ncp.cfg
new file mode 100644
index 00000000..a22878ce
--- /dev/null
+++ b/etc/ncp-config.d/nc-autoupdate-ncp.cfg
@@ -0,0 +1,21 @@
+{
+ "id": "nc-autoupdate-ncp",
+ "name": "nc-autoupdate-ncp",
+ "title": "nc-autoupdate-ncp",
+ "description": "Automatically apply NextCloudPi updates",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "NOTIFYUSER",
+ "name": "NOTIFYUSER",
+ "value": "ncp"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-backup-auto.cfg b/etc/ncp-config.d/nc-backup-auto.cfg
new file mode 100644
index 00000000..69bcad8c
--- /dev/null
+++ b/etc/ncp-config.d/nc-backup-auto.cfg
@@ -0,0 +1,43 @@
+{
+ "id": "nc-backup-auto",
+ "name": "nc-backup-auto",
+ "title": "nc-backup-auto",
+ "description": "Periodic backups",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "DESTDIR",
+ "name": "DESTDIR",
+ "value": "/media/USBdrive/ncp-backups"
+ },
+ {
+ "id": "INCLUDEDATA",
+ "name": "INCLUDEDATA",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "COMPRESS",
+ "name": "COMPRESS",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "BACKUPDAYS",
+ "name": "BACKUPDAYS",
+ "value": "7"
+ },
+ {
+ "id": "BACKUPLIMIT",
+ "name": "BACKUPLIMIT",
+ "value": "4"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-backup.cfg b/etc/ncp-config.d/nc-backup.cfg
new file mode 100644
index 00000000..9734c1db
--- /dev/null
+++ b/etc/ncp-config.d/nc-backup.cfg
@@ -0,0 +1,32 @@
+{
+ "id": "nc-backup",
+ "name": "nc-backup",
+ "title": "nc-backup",
+ "description": "Backup this NC instance to a file",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "DESTDIR",
+ "name": "DESTDIR",
+ "value": "/media/USBdrive/ncp-backups"
+ },
+ {
+ "id": "INCLUDEDATA",
+ "name": "INCLUDEDATA",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "COMPRESS",
+ "name": "COMPRESS",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "BACKUPLIMIT",
+ "name": "BACKUPLIMIT",
+ "value": "4"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-database.cfg b/etc/ncp-config.d/nc-database.cfg
new file mode 100644
index 00000000..232b3f18
--- /dev/null
+++ b/etc/ncp-config.d/nc-database.cfg
@@ -0,0 +1,15 @@
+{
+ "id": "nc-database",
+ "name": "nc-database",
+ "title": "nc-database",
+ "description": "Move your database to a new location, like a USB drive",
+ "info": "Note that non Unix filesystems such as NTFS are not supported\nbecause they do not provide a compatible user/permissions system.\n\nYou need to use a USB drive that is permanently on and is responsive \nor the database will fail.\n\nPlease note that the default location, when first installed is /var/lib/mysql/. \nMove it to the desired location by editing the DBDIR= field, the one shown is an example.\n\n** If it ever fails with a white page, move the database back to the SD **",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "DBDIR",
+ "name": "DBDIR",
+ "value": "/media/USBdrive/ncdatabase"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-datadir.cfg b/etc/ncp-config.d/nc-datadir.cfg
new file mode 100644
index 00000000..bea782b2
--- /dev/null
+++ b/etc/ncp-config.d/nc-datadir.cfg
@@ -0,0 +1,15 @@
+{
+ "id": "nc-datadir",
+ "name": "nc-datadir",
+ "title": "nc-datadir",
+ "description": "Change your data dir to a new location, like a USB drive",
+ "info": "Note that non Unix filesystems such as NTFS are not supported\nbecause they do not provide a compatible user/permissions system.\nAlso please note that the default location, when first installed is /var/www/nextcloud/data. \nMove it to the desired location by editing the DATADIR= field, the PATH shown is an example.",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "DATADIR",
+ "name": "DATADIR",
+ "value": "/media/USBdrive/ncdata"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-export-ncp.cfg b/etc/ncp-config.d/nc-export-ncp.cfg
new file mode 100644
index 00000000..4009a9e7
--- /dev/null
+++ b/etc/ncp-config.d/nc-export-ncp.cfg
@@ -0,0 +1,15 @@
+{
+ "id": "nc-export-ncp",
+ "name": "nc-export-ncp",
+ "title": "nc-export-ncp",
+ "description": "Export NextCloudPi configuration",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "DIR",
+ "name": "DIR",
+ "value": "/media/USBdrive/"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-export-ncp.sh b/etc/ncp-config.d/nc-export-ncp.sh
deleted file mode 100644
index ca1548e1..00000000
--- a/etc/ncp-config.d/nc-export-ncp.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/bash
-
-# Export NextCloudPi configuration
-#
-#
-# Copyleft 2017 by Courtney Hicks
-# GPL licensed (see end of file) * Use at your own risk!
-#
-
-DIR_=/media/USBdrive/
-
-DESCRIPTION="Export NextCloudPi configuration"
-
-configure()
-{
- [[ -d "$DIR_" ]] || { echo "directory $DIR_ does not exist"; return 1; }
-
- local DESTFILE="$DIR_"/ncp-config_$( date +"%Y%m%d" ).tar
- rm -rf /tmp/ncp-export
- mkdir -p /tmp/ncp-export
- cd /tmp/ncp-export || return 1
-
- for file in /usr/local/etc/ncp-config.d/*; do
- VARS=( $( grep "^[[:alpha:]]\+_=" "$file" | cut -d= -f1 | sed 's|_$||' ) )
- VALS=( $( grep "^[[:alpha:]]\+_=" "$file" | cut -d= -f2 ) )
- local CONFIG=""
- for i in $( seq 0 1 $(( ${#VARS[@]} - 1 )) ); do
- CONFIG+="${VARS[$i]}=${VALS[$i]}\n"
- done
- echo -e "$CONFIG" > "$( basename "$file" .sh ).cfg"
- done
-
- tar -cf "$DESTFILE" *
- chmod 600 "$DESTFILE"
-
- cd $OLDPWD
- rm -rf /tmp/ncp-export
- echo -e "configuration exported to $DESTFILE"
-}
-
-install() { :; }
-
-# License
-#
-# This script is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This script is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this script; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-# Boston, MA 02111-1307 USA
diff --git a/etc/ncp-config.d/nc-fix-permissions.cfg b/etc/ncp-config.d/nc-fix-permissions.cfg
new file mode 100644
index 00000000..2737c2cd
--- /dev/null
+++ b/etc/ncp-config.d/nc-fix-permissions.cfg
@@ -0,0 +1,9 @@
+{
+ "id": "nc-fix-permissions",
+ "name": "nc-fix-permissions",
+ "title": "nc-fix-permissions",
+ "description": "Fix permissions for NC data files, in case they were copied externally",
+ "info": "",
+ "infotitle": "",
+ "params": []
+}
diff --git a/etc/ncp-config.d/nc-format-USB.cfg b/etc/ncp-config.d/nc-format-USB.cfg
new file mode 100644
index 00000000..7169520f
--- /dev/null
+++ b/etc/ncp-config.d/nc-format-USB.cfg
@@ -0,0 +1,15 @@
+{
+ "id": "nc-format-USB",
+ "name": "nc-format-USB",
+ "title": "nc-format-USB",
+ "description": "Format an external USB drive as a BTRFS partition (dangerous)",
+ "info": "Make sure that ONLY the USB drive that you want to format is plugged in.\ncareful, this will destroy any data in the USB drive\n\n** YOU WILL LOSE ALL YOUR USB DATA **",
+ "infotitle": "Instructions for USB drive formatting",
+ "params": [
+ {
+ "id": "LABEL",
+ "name": "LABEL",
+ "value": "myCloudDrive"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-forward-ports.cfg b/etc/ncp-config.d/nc-forward-ports.cfg
new file mode 100644
index 00000000..5491c1eb
--- /dev/null
+++ b/etc/ncp-config.d/nc-forward-ports.cfg
@@ -0,0 +1,20 @@
+{
+ "id": "nc-forward-ports",
+ "name": "nc-forward-ports",
+ "title": "nc-forward-ports",
+ "description": "Set port forwarding to access from outside (UPnP)",
+ "info": "For NextCloudPi to be able to setup your ports, UPnP must be activated\nin your router. Activate it now on your router admin webpage.\n\n** UPnP is considered a security risk **\n\nDon't forget to disable it afterwards",
+ "infotitle": "Instructions for UPnP Port Forwarding",
+ "params": [
+ {
+ "id": "HTTPSPORT",
+ "name": "HTTPSPORT",
+ "value": "443"
+ },
+ {
+ "id": "HTTPPORT",
+ "name": "HTTPPORT",
+ "value": "80"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-hdd-monitor.cfg b/etc/ncp-config.d/nc-hdd-monitor.cfg
new file mode 100644
index 00000000..045baccf
--- /dev/null
+++ b/etc/ncp-config.d/nc-hdd-monitor.cfg
@@ -0,0 +1,26 @@
+{
+ "id": "nc-hdd-monitor",
+ "name": "nc-hdd-monitor",
+ "title": "nc-hdd-monitor",
+ "description": "Monitor HDD health automatically",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "NOTIFYUSER",
+ "name": "NOTIFYUSER",
+ "value": "ncp"
+ },
+ {
+ "id": "EMAIL",
+ "name": "EMAIL",
+ "value": "optional@email.com"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-hdd-test.cfg b/etc/ncp-config.d/nc-hdd-test.cfg
new file mode 100644
index 00000000..8514d019
--- /dev/null
+++ b/etc/ncp-config.d/nc-hdd-test.cfg
@@ -0,0 +1,22 @@
+{
+ "id": "nc-hdd-test",
+ "name": "nc-hdd-test",
+ "title": "nc-hdd-test",
+ "description": "Check HDD health",
+ "info": "Running no test will display test results",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "SHORTTEST",
+ "name": "SHORTTEST",
+ "value": "yes",
+ "type": "bool"
+ },
+ {
+ "id": "LONGTEST",
+ "name": "LONGTEST",
+ "value": "no",
+ "type": "bool"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-httpsonly.cfg b/etc/ncp-config.d/nc-httpsonly.cfg
new file mode 100644
index 00000000..e1eb831e
--- /dev/null
+++ b/etc/ncp-config.d/nc-httpsonly.cfg
@@ -0,0 +1,16 @@
+{
+ "id": "nc-httpsonly",
+ "name": "nc-httpsonly",
+ "title": "nc-httpsonly",
+ "description": "Force HTTPS",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "yes",
+ "type": "bool"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-import-ncp.cfg b/etc/ncp-config.d/nc-import-ncp.cfg
new file mode 100644
index 00000000..01a8ab2d
--- /dev/null
+++ b/etc/ncp-config.d/nc-import-ncp.cfg
@@ -0,0 +1,15 @@
+{
+ "id": "nc-import-ncp",
+ "name": "nc-import-ncp",
+ "title": "nc-import-ncp",
+ "description": "Import NextCloudPi configuration from file",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "FILE",
+ "name": "FILE",
+ "value": "/media/USBdrive/ncp-config_xxxxxx.cfg"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-info.cfg b/etc/ncp-config.d/nc-info.cfg
new file mode 100644
index 00000000..8f902c02
--- /dev/null
+++ b/etc/ncp-config.d/nc-info.cfg
@@ -0,0 +1,9 @@
+{
+ "id": "nc-info",
+ "name": "nc-info",
+ "title": "nc-info",
+ "description": "Print NextCloudPi system info",
+ "info": "",
+ "infotitle": "",
+ "params": []
+}
diff --git a/etc/ncp-config.d/nc-init.cfg b/etc/ncp-config.d/nc-init.cfg
new file mode 100644
index 00000000..48149829
--- /dev/null
+++ b/etc/ncp-config.d/nc-init.cfg
@@ -0,0 +1,20 @@
+{
+ "id": "nc-init",
+ "name": "nc-init",
+ "title": "nc-init",
+ "description": "(Re)initiate Nextcloud to a clean configuration",
+ "info": "This action will configure NextCloud to NextCloudPi defaults.\n\n** YOUR CONFIGURATION WILL BE LOST **\n\n",
+ "infotitle": "Clean NextCloud configuration",
+ "params": [
+ {
+ "id": "ADMINUSER",
+ "name": "ADMINUSER",
+ "value": "ncp"
+ },
+ {
+ "id": "ADMINPASS",
+ "name": "ADMINPASS",
+ "value": "ownyourbits"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-limits.cfg b/etc/ncp-config.d/nc-limits.cfg
new file mode 100644
index 00000000..9f5982bd
--- /dev/null
+++ b/etc/ncp-config.d/nc-limits.cfg
@@ -0,0 +1,30 @@
+{
+ "id": "nc-limits",
+ "name": "nc-limits",
+ "title": "nc-limits",
+ "description": "Configure system limits for NextCloudPi",
+ "info": "Examples: 200M or 2G. Write 0 for autoconfig",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "MAXFILESIZE",
+ "name": "MAXFILESIZE",
+ "value": "10G"
+ },
+ {
+ "id": "MEMORYLIMIT",
+ "name": "MEMORYLIMIT",
+ "value": "0"
+ },
+ {
+ "id": "PHPTHREADS",
+ "name": "PHPTHREADS",
+ "value": "0"
+ },
+ {
+ "id": "REDISMEM",
+ "name": "REDISMEM",
+ "value": "0"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-nextcloud.cfg b/etc/ncp-config.d/nc-nextcloud.cfg
new file mode 100644
index 00000000..89288726
--- /dev/null
+++ b/etc/ncp-config.d/nc-nextcloud.cfg
@@ -0,0 +1,36 @@
+{
+ "id": "nc-nextcloud",
+ "name": "nc-nextcloud",
+ "title": "nc-nextcloud",
+ "description": "Install any NextCloud version",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "VER",
+ "name": "VER",
+ "value": "14.0.4"
+ },
+ {
+ "id": "BETA",
+ "name": "BETA",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "MAXFILESIZE",
+ "name": "MAXFILESIZE",
+ "value": "2G"
+ },
+ {
+ "id": "MEMORYLIMIT",
+ "name": "MEMORYLIMIT",
+ "value": "768M"
+ },
+ {
+ "id": "MAXTRANSFERTIME",
+ "name": "MAXTRANSFERTIME",
+ "value": "3600"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-notify-updates.cfg b/etc/ncp-config.d/nc-notify-updates.cfg
new file mode 100644
index 00000000..577c8ccd
--- /dev/null
+++ b/etc/ncp-config.d/nc-notify-updates.cfg
@@ -0,0 +1,21 @@
+{
+ "id": "nc-notify-updates",
+ "name": "nc-notify-updates",
+ "title": "nc-notify-updates",
+ "description": "Notify in NC when a NextCloudPi update is available",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "yes",
+ "type": "bool"
+ },
+ {
+ "id": "USER",
+ "name": "USER",
+ "value": "ncp"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-passwd.cfg b/etc/ncp-config.d/nc-passwd.cfg
new file mode 100644
index 00000000..fb2ccfd3
--- /dev/null
+++ b/etc/ncp-config.d/nc-passwd.cfg
@@ -0,0 +1,20 @@
+{
+ "id": "nc-passwd",
+ "name": "nc-passwd",
+ "title": "nc-passwd",
+ "description": "Change password for the NextCloudPi Panel",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "PASSWORD",
+ "name": "PASSWORD",
+ "value": "ownyourbits"
+ },
+ {
+ "id": "CONFIRM",
+ "name": "CONFIRM",
+ "value": "ownyourbits"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-prettyURL.cfg b/etc/ncp-config.d/nc-prettyURL.cfg
new file mode 100644
index 00000000..e51d967e
--- /dev/null
+++ b/etc/ncp-config.d/nc-prettyURL.cfg
@@ -0,0 +1,16 @@
+{
+ "id": "nc-prettyURL",
+ "name": "nc-prettyURL",
+ "title": "nc-prettyURL",
+ "description": "Set pretty URLs (no index.php in URL)",
+ "info": "",
+ "infotitle": "PrettyURL notes",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-previews.cfg b/etc/ncp-config.d/nc-previews.cfg
new file mode 100644
index 00000000..4ec1e9f1
--- /dev/null
+++ b/etc/ncp-config.d/nc-previews.cfg
@@ -0,0 +1,9 @@
+{
+ "id": "nc-previews",
+ "name": "nc-previews",
+ "title": "nc-previews",
+ "description": "Generate previews for the gallery",
+ "info": "This will make browsing the gallery much more smooth.\nFor big collections, this can take a LONG time, depending on your hardware",
+ "infotitle": "",
+ "params": []
+}
diff --git a/etc/ncp-config.d/nc-ramlogs.cfg b/etc/ncp-config.d/nc-ramlogs.cfg
new file mode 100644
index 00000000..568d18b9
--- /dev/null
+++ b/etc/ncp-config.d/nc-ramlogs.cfg
@@ -0,0 +1,16 @@
+{
+ "id": "nc-ramlogs",
+ "name": "nc-ramlogs",
+ "title": "nc-ramlogs",
+ "description": "mount logs in RAM to prevent SD degradation (faster, consumes more RAM)",
+ "info": "You need to reboot for this change to take effect",
+ "infotitle": "Warning",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-restore.cfg b/etc/ncp-config.d/nc-restore.cfg
new file mode 100644
index 00000000..0cfbbb1f
--- /dev/null
+++ b/etc/ncp-config.d/nc-restore.cfg
@@ -0,0 +1,15 @@
+{
+ "id": "nc-restore",
+ "name": "nc-restore",
+ "title": "nc-restore",
+ "description": "Restore a previously backuped NC instance",
+ "info": "This new installation will cleanup current\nNextCloud instance, including files and database.\n\n** perform backup before proceding **\n\nYou can use nc-backup",
+ "infotitle": "Restore NextCloud backup",
+ "params": [
+ {
+ "id": "BACKUPFILE",
+ "name": "BACKUPFILE",
+ "value": "/media/USBdrive/nextcloud-bkp_xxxxxxxx.tar"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-rsync-auto.cfg b/etc/ncp-config.d/nc-rsync-auto.cfg
new file mode 100644
index 00000000..9a86d743
--- /dev/null
+++ b/etc/ncp-config.d/nc-rsync-auto.cfg
@@ -0,0 +1,26 @@
+{
+ "id": "nc-rsync-auto",
+ "name": "nc-rsync-auto",
+ "title": "nc-rsync-auto",
+ "description": "Periodically sync Nextcloud data through rsync",
+ "info": "DESTINATION can be a regular path for local sync\n'user' needs SSH autologin from the NCP 'root' user at 'ip'",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "DESTINATION",
+ "name": "DESTINATION",
+ "value": "user@ip:/path/to/sync"
+ },
+ {
+ "id": "SYNCDAYS",
+ "name": "SYNCDAYS",
+ "value": "3"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-rsync.cfg b/etc/ncp-config.d/nc-rsync.cfg
new file mode 100644
index 00000000..7f7ee7ce
--- /dev/null
+++ b/etc/ncp-config.d/nc-rsync.cfg
@@ -0,0 +1,15 @@
+{
+ "id": "nc-rsync",
+ "name": "nc-rsync",
+ "title": "nc-rsync",
+ "description": "Sync Nextcloud data through rsync",
+ "info": "'user' needs SSH autologin from the NCP 'root' user at 'ip'\nif we are launching from ncp-web",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "DESTINATION",
+ "name": "DESTINATION",
+ "value": "user@ip:/path/to/sync"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-scan-auto.cfg b/etc/ncp-config.d/nc-scan-auto.cfg
new file mode 100644
index 00000000..4b2f6cfa
--- /dev/null
+++ b/etc/ncp-config.d/nc-scan-auto.cfg
@@ -0,0 +1,21 @@
+{
+ "id": "nc-scan-auto",
+ "name": "nc-scan-auto",
+ "title": "nc-scan-auto",
+ "description": "Periodically scan NC for externally modified files",
+ "info": "Set the time in minutes in SCANINTERVAL.\n\n>>> If there are too many files this can greatly affect performance. <<<",
+ "infotitle": "Instructions for auto synchronization",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "SCANINTERVAL",
+ "name": "SCANINTERVAL",
+ "value": "60"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-scan.cfg b/etc/ncp-config.d/nc-scan.cfg
new file mode 100644
index 00000000..3386816d
--- /dev/null
+++ b/etc/ncp-config.d/nc-scan.cfg
@@ -0,0 +1,9 @@
+{
+ "id": "nc-scan",
+ "name": "nc-scan",
+ "title": "nc-scan",
+ "description": "Scan NC for externally modified files",
+ "info": "",
+ "infotitle": "",
+ "params": []
+}
diff --git a/etc/ncp-config.d/nc-snapshot-auto.cfg b/etc/ncp-config.d/nc-snapshot-auto.cfg
new file mode 100644
index 00000000..add2ff22
--- /dev/null
+++ b/etc/ncp-config.d/nc-snapshot-auto.cfg
@@ -0,0 +1,16 @@
+{
+ "id": "nc-snapshot-auto",
+ "name": "nc-snapshot-auto",
+ "title": "nc-snapshot-auto",
+ "description": "Scheduled datadir BTRFS snapshots",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-snapshot-sync.cfg b/etc/ncp-config.d/nc-snapshot-sync.cfg
new file mode 100644
index 00000000..f5803836
--- /dev/null
+++ b/etc/ncp-config.d/nc-snapshot-sync.cfg
@@ -0,0 +1,37 @@
+{
+ "id": "nc-snapshot-sync",
+ "name": "nc-snapshot-sync",
+ "title": "nc-snapshot-sync",
+ "description": "Sync BTRFS snapshots to USBdrive or remote machine",
+ "info": "Use format user@ip:/path/to/snapshots for remote sync\n'user' needs permissions for the 'btrfs' command at 'ip'\n'user' needs SSH autologin from the NCP 'root' user at 'ip'\nOnly use compression for internet transfer, because it uses many resources",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "SNAPDIR",
+ "name": "SNAPDIR",
+ "value": "/media/USBdrive/ncp-snapshots"
+ },
+ {
+ "id": "DESTINATION",
+ "name": "DESTINATION",
+ "value": "/media/myBackupDrive/ncp-snapshots"
+ },
+ {
+ "id": "COMPRESSION",
+ "name": "COMPRESSION",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "SYNCDAYS",
+ "name": "SYNCDAYS",
+ "value": "1"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-snapshot.cfg b/etc/ncp-config.d/nc-snapshot.cfg
new file mode 100644
index 00000000..77edb622
--- /dev/null
+++ b/etc/ncp-config.d/nc-snapshot.cfg
@@ -0,0 +1,15 @@
+{
+ "id": "nc-snapshot",
+ "name": "nc-snapshot",
+ "title": "nc-snapshot",
+ "description": "Create BTRFS snapshot of the datadir",
+ "info": "Snapshots take up very little space because only the differences from one \nto the next are saved. This requires the datadir to be in a BTRFS filesystem",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "LIMIT",
+ "name": "LIMIT",
+ "value": "4"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-static-IP.cfg b/etc/ncp-config.d/nc-static-IP.cfg
new file mode 100644
index 00000000..df17a9e4
--- /dev/null
+++ b/etc/ncp-config.d/nc-static-IP.cfg
@@ -0,0 +1,21 @@
+{
+ "id": "nc-static-IP",
+ "name": "nc-static-IP",
+ "title": "nc-static-IP",
+ "description": "Set up a static IP address (ACTIVE=yes), or DHCP (ACTIVE=no)",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "IP",
+ "name": "IP",
+ "value": "192.168.1.130"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-swapfile.cfg b/etc/ncp-config.d/nc-swapfile.cfg
new file mode 100644
index 00000000..a1f95ff1
--- /dev/null
+++ b/etc/ncp-config.d/nc-swapfile.cfg
@@ -0,0 +1,20 @@
+{
+ "id": "nc-swapfile",
+ "name": "nc-swapfile",
+ "title": "nc-swapfile",
+ "description": "Move and resize your swapfile. Recommended to move to a permanent USB drive",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "SWAPFILE",
+ "name": "SWAPFILE",
+ "value": "/media/USBdrive/swap"
+ },
+ {
+ "id": "SWAPSIZE",
+ "name": "SWAPSIZE",
+ "value": "1024"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-update-nextcloud.cfg b/etc/ncp-config.d/nc-update-nextcloud.cfg
new file mode 100644
index 00000000..8358867e
--- /dev/null
+++ b/etc/ncp-config.d/nc-update-nextcloud.cfg
@@ -0,0 +1,15 @@
+{
+ "id": "nc-update-nextcloud",
+ "name": "nc-update-nextcloud",
+ "title": "nc-update-nextcloud",
+ "description": "Update current instance to a new Nextcloud version",
+ "info": "Set to 0 to update to the latest avaliable version",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "VERSION",
+ "name": "VERSION",
+ "value": "0"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-update.cfg b/etc/ncp-config.d/nc-update.cfg
new file mode 100644
index 00000000..c653340b
--- /dev/null
+++ b/etc/ncp-config.d/nc-update.cfg
@@ -0,0 +1,9 @@
+{
+ "id": "nc-update",
+ "name": "nc-update",
+ "title": "nc-update",
+ "description": "Update NextCloudPi",
+ "info": "",
+ "infotitle": "",
+ "params": []
+}
diff --git a/etc/ncp-config.d/nc-webui.cfg b/etc/ncp-config.d/nc-webui.cfg
new file mode 100644
index 00000000..33a5f4ef
--- /dev/null
+++ b/etc/ncp-config.d/nc-webui.cfg
@@ -0,0 +1,16 @@
+{
+ "id": "nc-webui",
+ "name": "nc-webui",
+ "title": "nc-webui",
+ "description": "Enable or disable the NCP web interface",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-wifi.cfg b/etc/ncp-config.d/nc-wifi.cfg
new file mode 100644
index 00000000..18061cf5
--- /dev/null
+++ b/etc/ncp-config.d/nc-wifi.cfg
@@ -0,0 +1,16 @@
+{
+ "id": "nc-wifi",
+ "name": "nc-wifi",
+ "title": "nc-wifi",
+ "description": "Configure your Wi-Fi connection",
+ "info": "\n0) Write 'yes' to activate wifi, and 'no' to disable it\n1) Select a Wi-Fi network\n2) Press right arrow ->\n3) Enter the passphrase for your Wi-Fi\n4) Make sure to select 'connect automatically'\n5) F10 to save\n6) C to connect",
+ "infotitle": "Instructions to configure Wi-Fi",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/nc-zram.cfg b/etc/ncp-config.d/nc-zram.cfg
new file mode 100644
index 00000000..afbb27e1
--- /dev/null
+++ b/etc/ncp-config.d/nc-zram.cfg
@@ -0,0 +1,16 @@
+{
+ "id": "nc-zram",
+ "name": "nc-zram",
+ "title": "nc-zram",
+ "description": "Enable compressed RAM to improve swap performance",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/samba.cfg b/etc/ncp-config.d/samba.cfg
new file mode 100644
index 00000000..2c2d8054
--- /dev/null
+++ b/etc/ncp-config.d/samba.cfg
@@ -0,0 +1,21 @@
+{
+ "id": "samba",
+ "name": "samba",
+ "title": "samba",
+ "description": "SMB/CIFS file server (for Mac/Linux/Windows)",
+ "info": "The username will be the Nextcloud username, and the password will be one we setup here.\nIf we intend to modify the data folder through SAMBA,\nthen we have to synchronize NextCloud to make it aware of the changes.\n\nThis can be done manually or automatically using 'nc-scan' and 'nc-scan-auto'",
+ "infotitle": "Instructions for external synchronization",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "no",
+ "type": "bool"
+ },
+ {
+ "id": "PWD",
+ "name": "PWD",
+ "value": "ownyourbits"
+ }
+ ]
+}
diff --git a/etc/ncp-config.d/unattended-upgrades.cfg b/etc/ncp-config.d/unattended-upgrades.cfg
new file mode 100644
index 00000000..fae568c8
--- /dev/null
+++ b/etc/ncp-config.d/unattended-upgrades.cfg
@@ -0,0 +1,22 @@
+{
+ "id": "unattended-upgrades",
+ "name": "unattended-upgrades",
+ "title": "unattended-upgrades",
+ "description": "Automatic installation of security updates. Keep your cloud safe",
+ "info": "",
+ "infotitle": "",
+ "params": [
+ {
+ "id": "ACTIVE",
+ "name": "ACTIVE",
+ "value": "yes",
+ "type": "bool"
+ },
+ {
+ "id": "AUTOREBOOT",
+ "name": "AUTOREBOOT",
+ "value": "yes",
+ "type": "bool"
+ }
+ ]
+}
diff --git a/install.sh b/install.sh
index be671504..2889522c 100644
--- a/install.sh
+++ b/install.sh
@@ -46,12 +46,11 @@ cd - && cd "$TMPDIR"/nextcloudpi-"$BRANCH"
echo -e "\nInstalling NextCloudPi"
source etc/library.sh
-install_script lamp.sh
-install_script etc/ncp-config.d/nc-nextcloud.sh
-activate_script etc/ncp-config.d/nc-nextcloud.sh
-install_script ncp.sh
-activate_script etc/ncp-config.d/nc-init.sh
-bash /usr/local/bin/ncp-provisioning.sh
+install_app lamp.sh
+install_app etc/ncp-config.d/nc-nextcloud.sh
+run_app etc/ncp-config.d/nc-nextcloud.sh
+install_app ncp.sh
+run_app etc/ncp-config.d/nc-init.sh
popd
diff --git a/ncp-web/L10N.php b/ncp-web/L10N.php
index 2fdf5434..d786413b 100644
--- a/ncp-web/L10N.php
+++ b/ncp-web/L10N.php
@@ -69,7 +69,6 @@ class L10N
function save($lang)
{
$cfg = 'ncp-web.cfg';
- $line = file_get_contents( $cfg );
$str = "LANGUAGE_=$lang";
return file_put_contents( $cfg , $str );
}
@@ -141,12 +140,14 @@ class L10N
function load_language_setting()
{
- $webui_config_file = 'ncp-web.cfg';
- $fh = fopen($webui_config_file, 'r');
+ $cfg = 'ncp-web.cfg';
+ if (!file_exists($cfg))
+ return "auto";
+ $fh = fopen($cfg, 'r');
if ($fh === false)
return "auto";
- $lang=file_get_contents($webui_config_file);
+ $lang=file_get_contents($cfg);
fclose($fh);
return ltrim($lang, 'LANGUAGE_=');
}
diff --git a/ncp-web/ncp.css b/ncp-web/css/ncp.css
index e379824f..bfd2a1cb 100644
--- a/ncp-web/ncp.css
+++ b/ncp-web/css/ncp.css
@@ -233,7 +233,7 @@ select {
-webkit-appearance:none;
-moz-appearance:none;
appearance:none;
- background:url('../../../core/css/../img/actions/triangle-s.svg') no-repeat right 4px center;
+ #background:url('../../../core/css/../img/actions/triangle-s.svg') no-repeat right 4px center;
background-color:inherit;
outline:0;
padding-right:24px !important
@@ -410,7 +410,7 @@ input[type='checkbox'].checkbox--white:indeterminate:disabled + label:after,inpu
}
#header .logo {
- background-image:url("logo.svg");
+ background-image:url("../img/logo.svg");
background-repeat:no-repeat;
background-size:175px;
background-position:center;
@@ -425,7 +425,7 @@ input[type='checkbox'].checkbox--white:indeterminate:disabled + label:after,inpu
}
#header .logo-icon {
display:inline-block;
- background-image:url('img/ncp-logo.svg');
+ background-image:url('../img/ncp-logo.svg');
background-repeat:no-repeat;
background-position:center center;
background-size:contain;
@@ -599,7 +599,7 @@ kbd {
overflow:auto;
box-sizing:border-box
}
-#app-navigation > ul > li:focus,#app-navigation > ul > li:hover,#app-navigation > ul > li.active,#app-navigation > ul > li a.selected,#app-navigation > ul > li:focus > a,#app-navigation > ul > li:hover > a,#app-navigation > ul > li.active > a,#app-navigation > ul > li a.selected > a {
+#app-navigation > ul > li:focus,#app-navigation ul:hover,#app-navigation ul.active,#app-navigation > ul > li a.selected,#app-navigation > ul > li:focus > a,#app-navigation > ul > li:hover > a,#app-navigation > ul > li.active > a,#app-navigation > ul > li a.selected > a {
opacity:1;
box-shadow:inset 2px 0 #0082c9
}
@@ -626,7 +626,7 @@ kbd {
background-position:14px center;
background-repeat:no-repeat
}
-#app-navigation li > a {
+#app-navigation li > span, #app-navigation ul {
display:block;
width:90%;
line-height:44px;
@@ -637,7 +637,19 @@ kbd {
white-space:nowrap;
text-overflow:ellipsis;
color:#000;
- opacity:0.57
+ opacity:0.57;
+ font-weight: normal;
+}
+#app-navigation li > span {
+ font-weight: bold;
+ background-image:url('../img/files.svg');
+ background-size: 16px 16px;
+ background-position: 10px center;
+ background-repeat: no-repeat;
+ padding: 0px 12px 0px 36px;
+}
+#app-navigation ul {
+ padding-left: 2em;
}
#app-navigation li > a:first-child img {
margin-bottom:-3px;
@@ -655,7 +667,7 @@ kbd {
margin:0;
padding:0;
background:none;
- background-image:url('../../../core/css/../img/actions/triangle-s.svg?v=1');
+#background-image:url('../../../core/css/../img/actions/triangle-s.svg?v=1');
background-size:16px;
background-repeat:no-repeat;
background-position:center;
@@ -685,10 +697,11 @@ kbd {
-ms-transform:rotate(0);
transform:rotate(0)
}
-#app-navigation > {
+#app-navigation {
+ overflow-y: scroll
}
#app-navigation > ul ul {
- display:none
+ /* display:none */
}
#app-navigation > ul ul li > a {
padding-left:32px
@@ -832,6 +845,7 @@ kbd {
border-left:0;
margin-right:0
}
+
#app-content {
position:relative;
height:100%;
@@ -1058,7 +1072,7 @@ select {
width: 100%;
}
-#loading-gif {
+.loading-gif {
display: none;
}
@@ -1073,23 +1087,23 @@ select {
text-align: center;
}
-#config-box-info-txt {
+.config-box-info-txt {
white-space: pre-wrap;
text-align: center;
}
-#config-button-wrapper {
+.config-button-wrapper {
display: flex;
align-items: center;
justify-content: center;
}
.icon-close {
- background-image:url('img/close.svg')
+ background-image:url('../img/close.svg')
}
.icon-menu {
- background-image: url('img/menu.svg');
+ background-image: url('../img/menu.svg');
}
#power {
@@ -1117,43 +1131,43 @@ select {
}
.icon-power-white {
- background-image: url('img/poweroff.svg');
+ background-image: url('../img/poweroff.svg');
}
.icon-nc-white {
- background-image: url('img/nc-button.svg');
+ background-image: url('../img/nc-button.svg');
}
.icon-nc-info {
- background-image: url('img/info-white.svg');
+ background-image: url('../img/info-white.svg');
}
.icon-config {
- background-image: url('img/settings-white.svg');
+ background-image: url('../img/settings-white.svg');
}
.icon-reboot-white {
- background-image: url('img/reboot.svg');
+ background-image: url('../img/reboot.svg');
}
.icon-dashboard {
- background-image: url('img/dashboard.svg');
+ background-image: url('../img/dashboard.svg');
}
.icon-wizard-white {
- background-image: url('img/wizard.svg');
+ background-image: url('../img/wizard.svg');
}
.icon-red-circle {
- background-image: url('img/red-circle.svg');
+ background-image: url('../img/red-circle.svg');
padding: 8px;
display: none;
}
.icon-green-circle {
- background-image: url('img/green-circle.svg');
+ background-image: url('../img/green-circle.svg');
padding: 8px;
}
.icon-info {
- background-image: url('img/info.svg');
- padding: 8px;
- float: right;
- display: none;
+ background-image: url('../img/info.svg');
+ position: absolute;
+ top: 5px;
+ right: 1em;
}
#expand #expandDisplayName {
@@ -1230,7 +1244,7 @@ a#versionlink:hover {
right: 5px;
display: block;
background: none;
- background-image:url('img/view-close.svg');
+ background-image:url('../img/view-close.svg');
width: 38px;
height: 19px;
text-indent: -9999px;
@@ -1311,7 +1325,7 @@ a#versionlink:hover {
overflow:hidden
}
-#details-box {
+.details-box {
background-color: #fbfbfb;
border: solid 1px lightgray;
color: #565656;
diff --git a/ncp-web/elements.php b/ncp-web/elements.php
new file mode 100644
index 00000000..dafb3aad
--- /dev/null
+++ b/ncp-web/elements.php
@@ -0,0 +1,154 @@
+<?php
+///
+// NextCloudPi Web Panel Side bar
+//
+// Copyleft 2018 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
+// GPL licensed (see end of file) * Use at your own risk!
+//
+// More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
+///
+
+// fill options with contents from directory
+
+function print_config_form( $ncp_app, $cfg, $l )
+{
+ $ret = <<<HTML
+ <div id="config-box">
+ <table>
+HTML;
+
+ foreach ($cfg['params'] as $param)
+ {
+ $ret .= "<tr>";
+ $ret .= "<td><label for=\"$ncp_app-$param[id]\">$param[name]</label></td>";
+
+ // default to text input
+ if (!array_key_exists('type', $param))
+ {
+ $ret .= "<td><input type=\"text\" name=\"$param[name]\" id=\"$ncp_app-$param[id]\" value=\"$param[value]\" size=\"40\"></td>";
+ }
+
+ // checkbox
+ else if ($param['type'] == 'bool')
+ {
+ $checked = "";
+ if ($param['value'] == 'yes')
+ $checked = 'checked';
+ $ret .= "<td><input type=\"checkbox\" id=\"$ncp_app-$param[id]\" name=\"$param[name]\" value=\"$param[value]\" $checked></td>";
+ }
+ $ret .= "</tr>";
+ }
+
+ $ret .= <<<HTML
+ </table>
+ </div>
+ <div class="config-button-wrapper">
+ <button id="$ncp_app-config-button" class="config-button">Run</button>
+ <img class="loading-gif" src="img/loading-small.gif">
+ <div class="circle-retstatus" class="icon-red-circle"></div>
+ </div>
+ </form>
+HTML;
+ return $ret;
+}
+
+function print_config_forms( $l /* translations l10n object */ )
+{
+ $bin_dir = '/usr/local/bin/ncp/';
+ $cfg_dir = '/usr/local/etc/ncp-config.d/';
+ $d_iterator = new RecursiveDirectoryIterator($bin_dir);
+ $iterator = new RecursiveIteratorIterator($d_iterator);
+ $objects = new RegexIterator($iterator, '/^.+\.sh$/i', RecursiveRegexIterator::GET_MATCH);
+
+ $ret = "";
+ $sections = array_diff(scandir($bin_dir), array('.', '..', 'l10n'));
+ foreach ($sections as $section)
+ {
+ $scripts = array_diff(scandir($bin_dir . $section), array('.', '..', 'nc-wifi.sh', 'nc-info.sh'));
+ foreach ($scripts as $script)
+ {
+ $ncp_app = pathinfo($script, PATHINFO_FILENAME);
+ $cfg_file = $cfg_dir . $ncp_app . ".cfg";
+ $cfg = json_decode(file_get_contents($cfg_file), true);
+
+ $hidden = 'hidden';
+ if (array_key_exists('app',$_GET) && $_GET['app'] == $ncp_app)
+ $hidden = '';
+ $ret .= <<<HTML
+ <div id="$cfg[id]-config-box" class="$hidden">
+ <h2 class="text-title">$cfg[description]</h2>
+ <div class="config-box-info-txt">$cfg[info]</div>
+ <a href="#" target="_blank">
+ <div class="icon-info"></div>
+ </a>
+ <br/>
+ <div class="table-wrapper">
+HTML;
+
+ $ret .= print_config_form($ncp_app, $cfg, $l);
+ $ret .= <<<HTML
+ <div id="$ncp_app-details-box" class="details-box outputbox hidden"></div>
+ </div>
+ </div>
+HTML;
+ }
+ }
+ return $ret;
+}
+
+function print_sidebar( $l /* translations l10n object */, $ticks /* wether to calculate ticks(slow) */ )
+{
+ $bin_dir = '/usr/local/bin/ncp/';
+ $cfg_dir = '/usr/local/etc/ncp-config.d/';
+ $d_iterator = new RecursiveDirectoryIterator($bin_dir);
+ $iterator = new RecursiveIteratorIterator($d_iterator);
+ $objects = new RegexIterator($iterator, '/^.+\.sh$/i', RecursiveRegexIterator::GET_MATCH);
+
+ $ret = "";
+ $sections = array_diff(scandir($bin_dir), array('.', '..', 'l10n'));
+ foreach ($sections as $section)
+ {
+ $ret .= "<li id=\"$section\" class=\"nav-recent\"><span>{$l->__($section, $section)}</span>";
+
+ $scripts = array_diff(scandir($bin_dir . $section), array('.', '..', 'nc-wifi.sh', 'nc-info.sh'));
+ foreach ($scripts as $script)
+ {
+ $ncp_app = pathinfo($script, PATHINFO_FILENAME);
+ $cfg_file = $cfg_dir . $ncp_app . ".cfg";
+ $cfg = json_decode(file_get_contents($cfg_file), true);
+
+ $active = "";
+ if ( $ticks ) {
+ exec("bash -c \"source /usr/local/etc/library.sh && is_active_app $ncp_app\"", $output, $retval);
+ if ($retval == 0)
+ $active = " ✓";
+ } else if (sizeof($cfg['params']) > 0 && $cfg['params'][0]['id'] == 'ACTIVE' && $cfg['params'][0]['value'] == 'yes')
+ $active = " ✓";
+
+ $ret .= "<ul id=\"$ncp_app\" class=\"nav-recent\">";
+ $ret .= "<a href=\"#\"> {$l->__($ncp_app, $ncp_app)}$active </a>";
+ $ret .= "</ul>";
+ }
+ $ret .= "</li>";
+ }
+
+ return $ret;
+}
+
+// License
+//
+// This script is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This script is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this script; if not, write to the
+// Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+// Boston, MA 02111-1307 USA
+?>
diff --git a/ncp-web/img/files.svg b/ncp-web/img/files.svg
new file mode 100644
index 00000000..15365027
--- /dev/null
+++ b/ncp-web/img/files.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" version="1.1" height="16"><path d="m1.5 2c-0.25 0-0.5 0.25-0.5 0.5v11c0 0.26 0.24 0.5 0.5 0.5h13c0.26 0 0.5-0.241 0.5-0.5v-9c0-0.25-0.25-0.5-0.5-0.5h-6.5l-2-2z"/></svg>
diff --git a/ncp-web/index.php b/ncp-web/index.php
index d12b6c0f..fdd30260 100644
--- a/ncp-web/index.php
+++ b/ncp-web/index.php
@@ -17,15 +17,19 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<?php
+
// redirect to activation first time
exec("a2query -s ncp-activation", $output, $ret);
if ($ret == 0) {
header("Location: activate");
exit();
}
+ ini_set('session.cookie_httponly', 1);
+ if (isset($_SERVER['HTTPS']))
+ ini_set('session.cookie_secure', 1);
session_start();
- include('sidebar.php');
+ include('elements.php');
$modules_path = '/usr/local/etc/ncp-config.d/';
$l10nDir = "l10n";
@@ -38,16 +42,14 @@
header("X-Frame-Options: DENY");
header("Cache-Control: no-cache");
header('Pragma: no-cache');
- ini_set('session.cookie_httponly', 1);
- if (isset($_SERVER['HTTPS']))
- ini_set('session.cookie_secure', 1);
+ header('Expires: -1');
// HTTP2 push headers
- header("Link: </minified.js>; rel=preload; as=script;,</ncp.js>; rel=preload; as=script;,</ncp.css>; rel=preload; as=style;,</img/ncp-logo.svg>; rel=preload; as=image;, </img/loading-small.gif>; rel=preload; as=image;, rel=preconnect href=ncp-launcher.php;");
+ header("Link: </js/minified.js>; rel=preload; as=script;,</js/ncp.js>; rel=preload; as=script;,</css/ncp.css>; rel=preload; as=style;,</img/ncp-logo.svg>; rel=preload; as=image;, </img/loading-small.gif>; rel=preload; as=image;, rel=preconnect href=ncp-launcher.php;");
?>
<link rel="icon" type="image/png" href="img/favicon.png"/>
- <link rel="stylesheet" href="ncp.css">
+ <link rel="stylesheet" href="css/ncp.css">
</head>
<body id="body-user">
<?php
@@ -70,9 +72,13 @@
<?php
exec("ncp-test-updates", $output, $ret);
if ($ret == 0) {
+ $version = "v0.0";
+ $ver_file = '/var/run/.ncp-latest-version';
+ if (file_exists($ver_file))
+ $version = file_get_contents($ver_file);
echo '<div id="notification">';
echo '<div id="update-notification" class="row type-error closeable">';
- echo "version " . file_get_contents( '/var/run/.ncp-latest-version' ) . " is available";
+ echo "version " . $version . " is available";
echo '<a class="action close icon-close" href="#" alt="Dismiss"></a>';
echo '</div>';
echo '</div>';
@@ -110,25 +116,30 @@ HTML;
</div>
</a>
<a id=versionlink target="_blank" href="https://github.com/nextcloud/nextcloudpi/blob/master/changelog.md">
- <?php echo file_get_contents( "/usr/local/etc/ncp-version" ) ?>
+ <?php
+ $version = "v0.0";
+ $ver_file = "/usr/local/etc/ncp-version";
+ if (file_exists($ver_file))
+ $version = file_get_contents($ver_file);
+ echo $version;
+ ?>
</a>
-<?php
- // language selection drop
- $selected_lang=$l->load_language_setting();
+ <?php
+ // language selection drop
+ $selected_lang=$l->load_language_setting();
- $fh = fopen('langs.cfg', 'r');
- echo "<select id=\"language-selection\" name=\"language-selection\">";
- while ($line = fgets($fh)) {
- echo "<option value='" . $line . "' ";
- error_log("NACHO $line - $selected_lang");
- if( $line == $selected_lang )
- echo "selected='selected'";
- echo ">". $line ."</option>";
- }
- echo "<option value=\"[new]\">new..</option>";
- echo "</select>";
- fclose($fh);
-?>
+ $fh = fopen('langs.cfg', 'r');
+ echo "<select id=\"language-selection\" name=\"language-selection\">";
+ while ($line = fgets($fh)) {
+ echo "<option value='" . $line . "' ";
+ if( $line == $selected_lang )
+ echo "selected='selected'";
+ echo ">". $line ."</option>";
+ }
+ echo "<option value=\"[new]\">new..</option>";
+ echo "</select>";
+ fclose($fh);
+ ?>
</div>
<div id="header-right">
<a href="https://ownyourbits.com" id="nextcloud-btn" target="_blank" tabindex="1" title="<?php echo $l->__("Launch Nextcloud"); ?>">
@@ -174,42 +185,26 @@ HTML;
<div id="content" class="app-files" role="main">
<div id='overlay' class="hidden"></div>
<div id="app-navigation">
- <ul id="ncp-options">
+ <div id="ncp-options">
<?php echo print_sidebar($l, false); ?>
- </ul>
+ </div>
</div>
<div id="app-content">
<div id="app-navigation-toggle" class="icon-menu hidden"></div>
- <div id="config-wrapper" class="hidden">
- <h2 id="config-box-title" class="text-title"><?php echo $l->__("System Info"); ?></h2>
- <div id="config-box-info-txt"></div>
- <a href="#" target="_blank">
- <div id="config-extra-info" class="icon-info"></div>
- </a>
- <br/>
- <div id="config-box-wrapper" class="table-wrapper">
- <form>
- <div id="config-box"></div>
- <div id="config-button-wrapper">
- <button id="config-button"><?php echo $l->__("Run"); ?></button>
- <img id="loading-gif" src="img/loading-small.gif">
- <div id="circle-retstatus" class="icon-red-circle"></div>
- </div>
- </form>
- <div id="details-box" class="outputbox"></div>
- </div>
+ <div id="config-wrapper">
+ <?php echo print_config_forms($l); ?>
</div>
- <div id="dashboard-wrapper">
+ <div id="dashboard-wrapper" <?php if(array_key_exists('app',$_GET) && ($_GET['app'] != 'dashboard')) echo 'class="hidden"'; ?>>
<h2 class="text-title"><?php echo $l->__("System Info"); ?></h2>
<div id="dashboard-suggestions" class="table-wrapper"></div>
<div id="dashboard-table" class="outputbox table-wrapper"></div>
<div id="loading-info-gif"> <img src="img/loading-small.gif"> </div>
</div>
- <div id="nc-config-wrapper" class="hidden">
+ <div id="nc-config-wrapper" <?php if($_GET['app'] != 'config') echo 'class="hidden"';?>>
<h2 class="text-title"><?php echo $l->__("Nextcloud configuration"); ?></h2>
<div id="nc-config-box" class="table-wrapper">
<?php
@@ -253,8 +248,8 @@ HTML;
echo '<input type="hidden" id="csrf-token-ui" name="csrf-token-ui" value="' . getCSRFToken() . '"/>';
echo '<input type="hidden" id="csrf-token-cfg" name="csrf-token-cfg" value="' . getCSRFToken() . '"/>';
?>
- <script src="minified.js"></script>
- <script src="ncp.js"></script>
+ <script src="js/minified.js"></script>
+ <script src="js/ncp.js"></script>
</body>
</html>
diff --git a/ncp-web/minified.js b/ncp-web/js/minified.js
index 251866b7..251866b7 100644
--- a/ncp-web/minified.js
+++ b/ncp-web/js/minified.js
diff --git a/ncp-web/ncp.js b/ncp-web/js/ncp.js
index fa53b714..3f4e6d38 100644
--- a/ncp-web/ncp.js
+++ b/ncp-web/js/ncp.js
@@ -12,17 +12,28 @@ var $ = MINI.$, $$ = MINI.$$, EE = MINI.EE;
var selectedID = null;
var lock = false;
+// URL based navigation
+window.onpopstate = function(event) {
+ var ncp_app = location.search.split('=')[1];
+ if (ncp_app == 'config')
+ switch_to_section('nc-config');
+ else if (ncp_app == 'dashboard')
+ switch_to_section('dashboard');
+ else
+ app_clicked($('#' + ncp_app));
+};
+
function errorMsg()
{
$('#config-box').fill( "Something went wrong. Try refreshing the page" );
}
-function switch_to_section( name )
+function switch_to_section(section)
{
- $( '#config-wrapper' ).hide();
- $( '#dashboard-wrapper' ).hide();
- $( '#nc-config-wrapper' ).hide();
- $( '#' + name + '-wrapper' ).show();
+ $( '#config-wrapper > div' ).hide();
+ $( '#dashboard-wrapper' ).hide();
+ $( '#nc-config-wrapper' ).hide();
+ $( '#' + section + '-wrapper' ).show();
$( '#' + selectedID ).set('-active');
selectedID = null;
}
@@ -81,27 +92,19 @@ function disable_slide_menu()
function set_sidebar_click_handlers()
{
// Show selected option configuration box
- $( 'li' , '#app-navigation' ).on('click', function(e)
+ $( 'ul' , '#app-navigation' ).on('click', function(e)
{
if ( selectedID == this.get( '.id' ) ) // already selected
return;
if ( lock ) return;
- lock = true;
if ( window.innerWidth <= 768 )
close_menu();
$( '#' + selectedID ).set('-active');
- var that = this;
- $.request('post', 'ncp-launcher.php', { action:'cfgreq',
- ref:this.get('.id') ,
- csrf_token: $( '#csrf-token' ).get( '.value' ) }).then(
- function success( result )
- {
- cfgreqReceive( result, that );
- lock = false;
- }).error( errorMsg );
+ app_clicked(this);
+ history.pushState(null, selectedID, "?app=" + selectedID);
});
}
@@ -139,24 +142,17 @@ function reload_sidebar()
}).error( errorMsg );
}
-function cfgreqReceive( result, item )
+function app_clicked(item)
{
- var ret = $.parseJSON( result );
- if ( ret.token )
- $('#csrf-token').set( { value: ret.token } );
-
- switch_to_section( 'config' );
+ $('.details-box').hide();
+ $('.circle-retstatus').hide();
+ $('#' + selectedID + '-config-box').hide();
+ switch_to_section('config');
selectedID = item.get('.id');
- item.set( '+active' );
-
- $('#details-box' ).hide();
- $('#circle-retstatus').hide();
- $('#config-box').ht( ret.output );
- $('#config-box-title' ).fill( $( '#' + selectedID + '-desc' ).get( '.value' ) );
- $('#config-box-info-txt' ).fill( $( '#' + selectedID + '-info' ).get( '.value' ) );
- $('#config-box-wrapper').show();
- $('#config-extra-info').set( { $display: 'inline-block' } );
- $('#config-extra-info').up().set( '@href', 'https://github.com/nextcloud/nextcloudpi/wiki/Configuration-Reference#' + selectedID );
+ item.set('+active');
+ $('#' + selectedID + '-config-box').show();
+ var baseURL = 'https://github.com/nextcloud/nextcloudpi/wiki/Configuration-Reference#';
+ $('#' + selectedID + '-config-box .icon-info').up().set( '@href', baseURL + selectedID );
}
$(function()
@@ -174,28 +170,28 @@ $(function()
{
if ( e.origin != 'https://' + window.location.hostname + ':4443')
{
- $('#details-box').fill( "Invalid origin" );
+ $('.details-box').fill( "Invalid origin" );
return;
}
- var box = $$('#details-box');
- $('#details-box').ht( box.innerHTML + e.data + '<br>' );
+ var box = $$('.details-box');
+ $('.details-box').ht( box.innerHTML + e.data + '<br>' );
box.scrollTop = box.scrollHeight;
}, false);
set_sidebar_click_handlers();
// Launch selected script
- $( '#config-button' ).on('click', function(e)
+ $( '.config-button' ).on('click', function(e)
{
lock = true;
- $('#details-box').hide( '' );
- $('#config-button').set('@disabled',true);
- $('#loading-gif').set( { $display: 'inline' } );
+ $('.details-box').hide( '' );
+ $('.config-button').set('@disabled',true);
+ $('.loading-gif').set( { $display: 'inline' } );
// create configuration object
var cfg = {};
- $( 'input' , '#config-box' ).each( function(item){
+ $( 'input' , '#' + selectedID + '-config-box' ).each( function(item){
if( item.getAttribute('type') == 'checkbox' )
item.value = item.checked ? 'yes' : 'no';
@@ -215,11 +211,11 @@ $(function()
// reset box
- $('#details-box').fill();
- $('#details-box').show();
- $('#details-box').set( {$height: '0vh'} );
- $('#details-box').animate( {$height: '50vh'}, 150 );
- $('#circle-retstatus').hide();
+ $('.details-box').fill();
+ $('.details-box').show();
+ $('.details-box').set( {$height: '0vh'} );
+ $('.details-box').animate( {$height: '50vh'}, 150 );
+ $('.circle-retstatus').hide();
$( 'input' , '#config-box-wrapper' ).set('@disabled',true);
@@ -227,7 +223,7 @@ $(function()
$.request('post', 'ncp-launcher.php', { action:'launch',
ref : selectedID,
config: $.toJSON(cfg),
- csrf_token: $( '#csrf-token' ).get( '.value' ) }).then(
+ csrf_token: $( '#csrf-token' ).get( '.value' ) }).then(
function success( result )
{
var ret = $.parseJSON( result );
@@ -240,17 +236,17 @@ $(function()
if( ret.ref && ret.ref == 'nc-update' )
window.location.reload( true );
reload_sidebar();
- $('#circle-retstatus').set( '+icon-green-circle' );
+ $('.circle-retstatus').set( '+icon-green-circle' );
}
else
- $('#circle-retstatus').set( '-icon-green-circle' );
- $('#circle-retstatus').show();
+ $('.circle-retstatus').set( '-icon-green-circle' );
+ $('.circle-retstatus').show();
}
else // print error from server instead
- $('#details-box').fill(ret.output);
+ $('.details-box').fill(ret.output);
$( 'input' , '#config-box-wrapper' ).set('@disabled', null);
- $('#config-button').set('@disabled',null);
- $('#loading-gif').hide();
+ $('.config-button').set('@disabled',null);
+ $('.loading-gif').hide();
lock = false;
}).error( errorMsg );
});
@@ -263,19 +259,10 @@ $(function()
$( '#' + selectedID ).set('-active');
- // request
- $.request('post', 'ncp-launcher.php', { action:'cfgreq',
- ref:'nc-update' ,
- csrf_token: $( '#csrf-token' ).get( '.value' ) }).then(
- function success( result )
- {
- cfgreqReceive( result, $( '#nc-update' ) );
- lock = false;
- }
- ).error( errorMsg );
+ app_clicked( $('#nc-update') );
//clear details box
- $('#details-box').hide( '' );
+ $('.details-box').hide( '' );
} );
// slide menu
@@ -314,9 +301,9 @@ $(function()
csrf_token: $( '#csrf-token' ).get( '.value' ) }).then(
function success( result )
{
- $('#config-box-wrapper').hide();
+ switch_to_section( 'nc-config' );
$.off( poweroff_event_handler );
- $('#config-box-title').fill( "Shutting down..." );
+ $('#nc-config-wrapper').ht('<h2 class="text-title">Shutting down...<h2>');
}).error( errorMsg );
} );
@@ -329,9 +316,9 @@ $(function()
csrf_token: $( '#csrf-token' ).get( '.value' ) }).then(
function success( result )
{
- $('#config-box-wrapper').hide();
+ switch_to_section( 'nc-config' );
$.off( poweroff_event_handler );
- $('#config-box-title').fill( "Rebooting..." );
+ $('#nc-config-wrapper').ht('<h2 class="text-title">Rebooting...<h2>');
}).error( errorMsg );
} );
@@ -361,6 +348,7 @@ $(function()
if ( lock ) return;
close_menu();
switch_to_section( 'dashboard' );
+ history.pushState(null, selectedID, "?app=dashboard");
} );
// config button
@@ -369,6 +357,7 @@ $(function()
if ( lock ) return;
close_menu();
switch_to_section( 'nc-config' );
+ history.pushState(null, selectedID, "?app=config");
} );
// language selection
diff --git a/ncp-web/ncp-launcher.php b/ncp-web/ncp-launcher.php
index 9fca90c4..4d720ced 100644
--- a/ncp-web/ncp-launcher.php
+++ b/ncp-web/ncp-launcher.php
@@ -2,218 +2,165 @@
///
// NextCloudPi Web Panel backend
//
-// Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
+// Copyleft 2018 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
// GPL licensed (see end of file) * Use at your own risk!
//
-// More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
+// More at https://nextcloudpi.com
///
include ('csrf.php');
session_start();
-$modules_path = '/usr/local/etc/ncp-config.d/';
+$cfg_dir = '/usr/local/etc/ncp-config.d/';
$l10nDir = "l10n";
-ignore_user_abort( true );
-
+ignore_user_abort(true);
+//
+// language
+//
require("L10N.php");
try {
- $l = new L10N($_SERVER["HTTP_ACCEPT_LANGUAGE"], $l10nDir, $modules_path);
+ $l = new L10N($_SERVER["HTTP_ACCEPT_LANGUAGE"], $l10nDir, $cfg_dir);
} catch (Exception $e) {
die(json_encode("<p class='error'>Error while loading localizations!</p>"));
}
-if ( $_POST['action'] == "cfgreq" )
+// CSRF check
+$token = isset($_POST['csrf_token']) ? $_POST['csrf_token'] : '';
+if ( empty($token) || !validateCSRFToken($token) )
+ exit( '{ "output": "Unauthorized request. Try reloading the page" }' );
+
+//
+// launch
+//
+if ( $_POST['action'] == "launch" && $_POST['config'] )
{
+ // sanity checks
if ( !$_POST['ref'] ) exit( '{ "output": "Invalid request" }' );
- //CSFR check
- $token = isset($_POST['csrf_token']) ? $_POST['csrf_token'] : '';
- if ( empty($token) || !validateCSRFToken($token) )
- exit( '{ "output": "Unauthorized request. Try reloading the page" }' );
-
- $path = '/usr/local/etc/ncp-config.d/';
- $files = array_diff(scandir($path), array('.', '..'));
+ $ncp_app = $_POST['ref'];
- $fh = fopen( $path . $_POST['ref'] . '.sh' ,'r')
- or exit( '{ "output": "' . $file . ' read error" }' );
-
- echo '{ "token": "' . getCSRFToken() . '",'; // Get new token
- echo ' "output": ';
-
- $output = "<table>";
+ preg_match( '/^[0-9A-Za-z_-]+$/' , $_POST['ref'] , $matches )
+ or exit( '{ "output": "Invalid input" , "token": "' . getCSRFToken() . '" }' );
- while ( $line = fgets($fh) )
+ // save new config
+ if ( $_POST['config'] != "{}" )
{
- // checkbox (yes/no) field
- if ( preg_match('/^(\w+)_=(yes|no)$/', $line, $matches) )
- {
- $checked = "";
- if ( $matches[2] == "yes" )
- $checked = "checked";
- $output .= "<tr>";
- $output .= "<td><label for=\"$matches[1]\">". $l->__($matches[1], $_POST['ref']) ."</label></td>";
- $output .= "<td><input type=\"checkbox\" id=\"$matches[1]\" name=\"$matches[1]\" value=\"$matches[2]\" $checked></td>";
- $output .= "</tr>";
- }
- // drop down menu
- else if(preg_match('/^(\w+)_=\[(([_\w]+,)*[_\w]+)\]$/', $line, $matches))
- {
- $options = explode(",", $matches[2]);
- $output .= "<tr>";
- $output .= "<td><label for=\"$matches[1]\">". $l->__($matches[1], $_POST['ref']) ."</label></td>";
- $output .= "<td><select id=\"$matches[1]\" name=\"$matches[1]\">";
- foreach($options as $option)
- {
- $output .= "<option value='". trim($option, "_") ."' ";
- if( $option[0] == "_" && $option[count($option) - 1] == "_" )
- {
- $output .="selected='selected'";
- }
- $output .= ">". $l->__(trim($option, "_"), $_POST['ref']) ."</option>";
- }
- $output .= "</select></td></tr>";
- }
- // text field
- else if ( preg_match('/^(\w+)_=(.*)$/', $line, $matches) )
- {
- $output .= "<tr>";
- $output .= "<td><label for=\"$matches[1]\">". $l->__($matches[1], $_POST['ref']) ."</label></td>";
- $output .= "<td><input type=\"text\" name=\"$matches[1]\" id=\"$matches[1]\" value=\"$matches[2]\" size=\"40\"></td>";
- $output .= "</tr>";
- }
- }
+ $cfg_file = $cfg_dir . $ncp_app . '.cfg';
- $output .= "</table>";
- fclose($fh);
+ $cfg_str = file_get_contents($cfg_file)
+ or exit('{ "output": "' . $ncp_app . ' read error" }');
- echo json_encode( $output ) . ' }'; // close JSON
-}
+ $cfg = json_decode($cfg_str, true)
+ or exit('{ "output": "' . $ncp_app . ' read error" }');
-else if ( $_POST['action'] == "launch" && $_POST['config'] )
-{
- // sanity checks
- if ( !$_POST['ref'] ) exit( '{ "output": "Invalid request" }' );
-
- preg_match( '/^[0-9A-Za-z_-]+$/' , $_POST['ref'] , $matches )
- or exit( '{ "output": "Invalid input" , "token": "' . getCSRFToken() . '" }' );
-
- // CSRF check
- $token = isset($_POST['csrf_token']) ? $_POST['csrf_token'] : '';
- if ( empty($token) || !validateCSRFToken($token) )
- exit( '{ "output": "Unauthorized request. Try reloading the page" }' );
+ $new_params = json_decode($_POST['config'], true)
+ or exit('{ "output": "Invalid request" }');
- chdir('/usr/local/etc/ncp-config.d/');
+ foreach ($cfg['params'] as $index => $param)
+ $cfg['params'][$index]['value'] = $new_params[$cfg['params'][$index]['id']];
- $file = $_POST['ref'] . '.sh';
+ $cfg_str = json_encode($cfg)
+ or exit('{ "output": "' . $ncp_app . ' internal error" }');
- if ( $_POST['config'] != "{}" )
- $params = json_decode( $_POST['config'], true )
- or exit( '{ "output": "Invalid request" }' );
-
- $code = file_get_contents( $file )
- or exit( '{ "output": "' . $file . ' read error" }' );
-
- if ( !empty( $params ) )
- foreach( $params as $name => $value )
- {
- if( is_array($value))
- {
- $value = "[". join(",", $value) ."]";
- }
- preg_match( '/^[\[\]\w+-.,@_\/:]+$/' , $value , $matches )
- or exit( '{ "output": "Invalid input" , "token": "' . getCSRFToken() . '" }' );
- $code = preg_replace( '/\n' . $name . '_=.*' . PHP_EOL . '/' ,
- PHP_EOL . $name . '_=' . $value . PHP_EOL ,
- $code )
- or exit();
- }
-
- file_put_contents($file, $code )
- or exit( '{ "output": "' . $file . ' write error" }' );
+ file_put_contents($cfg_file, $cfg_str)
+ or exit('{ "output": "' . $ncp_app . ' write error" }');
+ }
+ // launch
echo '{ "token": "' . getCSRFToken() . '",'; // Get new token
- echo ' "ref": "' . $_POST['ref'] . '",';
+ echo ' "ref": "' . $ncp_app . '",';
echo ' "output": "" , ';
echo ' "ret": ';
- exec( 'bash -c "sudo /home/www/ncp-launcher.sh ' . $file . '"' , $output , $ret );
+ exec( 'bash -c "sudo /home/www/ncp-launcher.sh ' . $ncp_app . '"' , $output , $ret );
echo '"' . $ret . '" }';
}
-else
+//
+// info
+//
+else if ( $_POST['action'] == "info" )
{
- // CSRF check
- $token = isset($_POST['csrf_token']) ? $_POST['csrf_token'] : '';
- if ( empty($token) || !validateCSRFToken($token) )
- exit( '{ "output": "Unauthorized request. Try reloading the page" }' );
+ exec( 'bash /usr/local/bin/ncp-diag', $output, $ret );
- if ( $_POST['action'] == "poweroff" )
- {
- shell_exec( 'bash -c "( sleep 2 && sudo halt ) 2>/dev/null >/dev/null &"' );
- }
- else if ( $_POST['action'] == "reboot" )
+ // info table
+ $table = '<table class="dashtable">';
+ foreach( $output as $line )
{
- shell_exec('bash -c "( sleep 2 && sudo reboot ) 2>/dev/null >/dev/null &"');
+ $table .= "<tr>";
+ $fields = explode( "|", $line );
+ $table .= "<td>$fields[0]</td>";
+
+ $class = 'val-field';
+ if ( strpos( $fields[1], "up" ) !== false
+ || strpos( $fields[1], "ok" ) !== false
+ || strpos( $fields[1], "open" ) !== false )
+ $class = 'ok-field';
+ if ( strpos( $fields[1], "down" ) !== false
+ || strpos( $fields[1], "error" ) !== false )
+ $class = 'error-field';
+
+ $table .= "<td class=\"$class\">$fields[1]</td>";
+ $table .= "</tr>";
}
- else if ( $_POST['action'] == "info" )
- {
- exec( 'bash /usr/local/bin/ncp-diag', $output, $ret );
-
- // info table
- $table = '<table class="dashtable">';
- foreach( $output as $line )
- {
- $table .= "<tr>";
- $fields = explode( "|", $line );
- $table .= "<td>$fields[0]</td>";
-
- $class = 'val-field';
- if ( strpos( $fields[1], "up" ) !== false
- || strpos( $fields[1], "ok" ) !== false
- || strpos( $fields[1], "open" ) !== false )
- $class = 'ok-field';
- if ( strpos( $fields[1], "down" ) !== false
- || strpos( $fields[1], "error" ) !== false )
- $class = 'error-field';
-
- $table .= "<td class=\"$class\">$fields[1]</td>";
- $table .= "</tr>";
- }
- $table .= "</table>";
-
- // suggestions
- $suggestions = "";
- if ( $ret == 0 )
- {
- exec( "bash /usr/local/bin/ncp-suggestions \"" . implode( "\n", $output ) . '"', $out, $ret );
- foreach( $out as $line )
- if ( $line != "" )
- $suggestions .= "<p class=\"val-field\">‣ $line</p>";
- }
-
- // return JSON
- echo '{ "token": "' . getCSRFToken() . '",'; // Get new token
- echo ' "table": ' . json_encode( $table ) . ' , ';
- echo ' "suggestions": ' . json_encode( $suggestions ) . ' , ';
- echo ' "ret": "' . $ret . '" }';
- }
- else if ( $_POST['action'] == "sidebar" )
- {
- require( "sidebar.php" );
- // return JSON
- echo '{ "token": "' . getCSRFToken() . '",'; // Get new token
- echo ' "output": ' . json_encode( print_sidebar( $l, true ) ) . ' , ';
- echo ' "ret": "0" }';
- }
- else if ( $_POST['action'] == "cfg-ui" )
+ $table .= "</table>";
+
+ // suggestions
+ $suggestions = "";
+ if ( $ret == 0 )
{
- $ret = $l->save( $_POST['value'] );
- $ret = $ret !== FALSE ? 0 : 1;
- // return JSON
- echo '{ "token": "' . getCSRFToken() . '",'; // Get new token
- echo ' "ret": "' . $ret . '" }';
+ exec( "bash /usr/local/bin/ncp-suggestions \"" . implode( "\n", $output ) . '"', $out, $ret );
+ foreach( $out as $line )
+ if ( $line != "" )
+ $suggestions .= "<p class=\"val-field\">‣ $line</p>";
}
+
+ // return JSON
+ echo '{ "token": "' . getCSRFToken() . '",'; // Get new token
+ echo ' "table": ' . json_encode( $table ) . ' , ';
+ echo ' "suggestions": ' . json_encode( $suggestions ) . ' , ';
+ echo ' "ret": "' . $ret . '" }';
+}
+
+//
+// sidebar
+//
+else if ( $_POST['action'] == "sidebar" )
+{
+ require( "elements.php" );
+ // return JSON
+ echo '{ "token": "' . getCSRFToken() . '",'; // Get new token
+ echo ' "output": ' . json_encode( print_sidebar( $l, true ) ) . ' , ';
+ echo ' "ret": "0" }';
+}
+
+//
+// cfg-ui
+//
+else if ( $_POST['action'] == "cfg-ui" )
+{
+ $ret = $l->save( $_POST['value'] );
+ $ret = $ret !== FALSE ? 0 : 1;
+ // return JSON
+ echo '{ "token": "' . getCSRFToken() . '",'; // Get new token
+ echo ' "ret": "' . $ret . '" }';
+}
+
+//
+// poweroff
+//
+else if ( $_POST['action'] == "poweroff" )
+{
+ shell_exec( 'bash -c "( sleep 2 && sudo halt ) 2>/dev/null >/dev/null &"' );
+}
+
+//
+// reboot
+//
+else if ( $_POST['action'] == "reboot" )
+{
+ shell_exec('bash -c "( sleep 2 && sudo reboot ) 2>/dev/null >/dev/null &"');
}
// License
diff --git a/ncp-web/ncp-output.php b/ncp-web/ncp-output.php
index 8bea03bb..704b0a58 100644
--- a/ncp-web/ncp-output.php
+++ b/ncp-web/ncp-output.php
@@ -78,8 +78,11 @@ function follow($file)
session_write_close();
echo str_pad('',1024*1024*4); // make sure the browser buffer becomes full
-touch( '/var/log/ncp.log' );
-follow( '/var/log/ncp.log' );
+
+$ncp_log = '/var/log/ncp.log';
+if (!file_exists($ncp_log))
+ touch($ncp_log);
+follow($ncp_log);
// License
//
diff --git a/ncp-web/sidebar.php b/ncp-web/sidebar.php
deleted file mode 100644
index c90a509c..00000000
--- a/ncp-web/sidebar.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-///
-// NextCloudPi Web Panel Side bar
-//
-// Copyleft 2018 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
-// GPL licensed (see end of file) * Use at your own risk!
-//
-// More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
-///
-
-// fill options with contents from directory
-
-function print_sidebar( $l /* translations l10n object */, $ticks /* wether to calculate ticks(slow) */ )
-{
- $modules_path = '/usr/local/etc/ncp-config.d/';
- $files = array_diff(scandir($modules_path), array('.', '..', 'nc-wifi.sh', 'nc-info.sh', 'l10n'));
- $ret = "";
-
- foreach ($files as $file) {
- $script = pathinfo($file, PATHINFO_FILENAME);
- $txt = file_get_contents($modules_path . $file);
-
- $active = "";
- if ( $ticks ) {
- $etc = '/usr/local/etc';
- exec("bash -c \"source $etc/library.sh && is_active_script $etc/ncp-config.d/$script\".sh", $output, $retval);
- if ($retval == 0)
- $active = " ✓";
- } else if (preg_match('/^ACTIVE_=yes$/m', $txt, $matches))
- $active = " ✓";
-
- $ret .= "<li id=\"$script\" class=\"nav-recent\">";
- $ret .= "<a href=\"#\"> {$l->__($script, $script)}$active </a>";
-
- if (preg_match('/^DESCRIPTION="(.*)"$/m', $txt, $matches))
- $ret .= "<input id=\"$script-desc\" type=\"hidden\" value=\"{$l->__($matches[1], $script)}\" />";
-
- if (preg_match('/^INFO="(.*)"/msU', $txt, $matches))
- $ret .= "<input id=\"$script-info\" type=\"hidden\" value=\"{$l->__($matches[1], $script)}\" />";
-
- if (preg_match('/^INFOTITLE="(.*)"/msU', $txt, $matches))
- $ret .= "<input id=\"$script-infotitle\" type=\"hidden\" value=\"{$l->__($matches[1], $script)}\" />";
-
- $ret .= "</li>";
- }
- return $ret;
-}
-// License
-//
-// This script is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This script is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this script; if not, write to the
-// Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-// Boston, MA 02111-1307 USA
-?>
diff --git a/ncp.sh b/ncp.sh
index 900d5e6a..c2e86a9f 100644
--- a/ncp.sh
+++ b/ncp.sh
@@ -12,6 +12,7 @@ WEBADMIN=ncp
WEBPASSWD=ownyourbits
BRANCH=master
+BINDIR=/usr/local/bin/ncp
CONFDIR=/usr/local/etc/ncp-config.d/
APTINSTALL="apt-get install -y --no-install-recommends"
export DEBIAN_FRONTEND=noninteractive
@@ -21,8 +22,8 @@ install()
{
# NCP-CONFIG
apt-get update
- $APTINSTALL git dialog whiptail
- mkdir -p $CONFDIR
+ $APTINSTALL git dialog whiptail jq
+ mkdir -p "$CONFDIR" "$BINDIR"
# include option in raspi-config (only Raspbian)
test -f /usr/bin/raspi-config && {
@@ -129,12 +130,8 @@ EOF
cat > /home/www/ncp-launcher.sh <<'EOF'
#!/bin/bash
-DIR=/usr/local/etc/ncp-config.d
-[[ -f $DIR/$1 ]] || { echo "File not found"; exit 1; }
-[[ "$1" =~ ../ ]] && { echo "Forbidden path"; exit 2; }
source /usr/local/etc/library.sh
-cd $DIR
-launch_script $1
+run_app $1
EOF
chmod 700 /home/www/ncp-launcher.sh
echo "www-data ALL = NOPASSWD: /home/www/ncp-launcher.sh , /sbin/halt, /sbin/reboot" >> /etc/sudoers
@@ -169,7 +166,6 @@ cd /var/www/nextcloud
sudo -u www-data php occ config:system:set trusted_domains 1 --value=$IP
EOF
- # make sure this is called on last re-boot
[[ "$DOCKERBUILD" != 1 ]] && systemctl enable nextcloud-domain
# NEXTCLOUDPI UPDATES
diff --git a/post-inst.sh b/post-inst.sh
index 8be379a7..986a6661 100644
--- a/post-inst.sh
+++ b/post-inst.sh
@@ -8,7 +8,7 @@
# More at nextcloudpi.com
#
-install()
+configure()
{
# stop mysqld and redis
mysqladmin -u root shutdown
@@ -18,10 +18,8 @@ install()
# cleanup all NCP extras
source /usr/local/etc/library.sh
- cd /usr/local/etc/ncp-config.d/
- for script in *.sh; do
- cleanup_script $script
- done
+ find /usr/local/bin/ncp -name '*.sh' | \
+ while read script; do cleanup_script $script; done
# clean packages and installation logs
apt-get autoremove -y
diff --git a/update.sh b/update.sh
index 2ee811c1..31226e51 100755
--- a/update.sh
+++ b/update.sh
@@ -12,29 +12,29 @@ CONFDIR=/usr/local/etc/ncp-config.d/
# don't make sense in a docker container
EXCL_DOCKER="
-nc-automount.sh
-nc-format-USB.sh
-nc-datadir.sh
-nc-database.sh
-nc-ramlogs.sh
-nc-swapfile.sh
-nc-static-IP.sh
-nc-wifi.sh
-nc-nextcloud.sh
-nc-init.sh
-UFW.sh
-nc-snapshot.sh
-nc-snapshot-auto.sh
-nc-audit.sh
-nc-hdd-monitor.sh
-SSH.sh
-fail2ban.sh
-NFS.sh
+nc-automount
+nc-format-USB
+nc-datadir
+nc-database
+nc-ramlogs
+nc-swapfile
+nc-static-IP
+nc-wifi
+nc-nextcloud
+nc-init
+UFW
+nc-snapshot
+nc-snapshot-auto
+nc-audit
+nc-hdd-monitor
+SSH
+fail2ban
+NFS
"
# better use a designated container
EXCL_DOCKER+="
-samba.sh
+samba
"
# check running apt
@@ -46,38 +46,28 @@ source /usr/local/etc/library.sh
mkdir -p "$CONFDIR"
-# prevent installing some apt packages in the docker version
+# prevent installing some ncp-apps in the docker version
[[ -f /.docker-image ]] && {
- for opt in $EXCL_DOCKER; do
- touch $CONFDIR/$opt
-done
+ for opt in $EXCL_DOCKER; do
+ touch $CONFDIR/$opt.cfg
+ done
}
# copy all files in bin and etc
-for file in bin/* etc/*; do
- [ -f "$file" ] || continue;
- cp "$file" /usr/local/"$file"
-done
+cp -r bin/* /usr/local/bin/
+find etc -maxdepth 1 -type f -exec echo cp '{}' /usr/local/ \;
# install new entries of ncp-config and update others
for file in etc/ncp-config.d/*; do
[ -f "$file" ] || continue; # skip dirs
[ -f /usr/local/"$file" ] || { # new entry
- install_script "$file" # install
+ install_app "$(basename "$file" .cfg)"
# configure if active by default
- grep -q '^ACTIVE_=yes$' "$file" && activate_script "$file"
- }
-
- # save current configuration to (possibly) updated script
- [ -f /usr/local/"$file" ] && {
- VARS=( $( grep "^[[:alpha:]]\+_=" /usr/local/"$file" | cut -d= -f1 ) )
- VALS=( $( grep "^[[:alpha:]]\+_=" /usr/local/"$file" | cut -d= -f2 ) )
- for i in $( seq 0 1 ${#VARS[@]} ); do
- sed -i "s|^${VARS[$i]}=.*|${VARS[$i]}=${VALS[$i]}|" "$file"
- done
+ [[ "$(jq -r ".params[0].id" "$file")" == "active" ]] && \
+ [[ "$(jq -r ".params[0].value" "$file")" == "yes" ]] && \
+ run_app_unsafe "$file"
}
-
cp "$file" /usr/local/"$file"
done
@@ -95,8 +85,11 @@ chown -R www-data:www-data /var/www/ncp-web
chmod 770 /var/www/ncp-web
[[ -f /.docker-image ]] && {
- # remove unwanted packages for the docker version
- for opt in $EXCL_DOCKER; do rm $CONFDIR/$opt; done
+ # remove unwanted ncp-apps for the docker version
+ for opt in $EXCL_DOCKER; do
+ rm $CONFDIR/$opt.cfg
+ find /usr/local/bin/ncp -name "$opt.sh" -exec rm '{}' \;
+ done
# update services
cp docker-common/{lamp/010lamp,nextcloud/020nextcloud,nextcloudpi/000ncp} /etc/services-enabled.d
@@ -110,24 +103,7 @@ chmod 770 /var/www/ncp-web
# docker images only
[[ -f /.docker-image ]] && {
- cat > /etc/services-available.d/000ncp <<EOF
-#!/bin/bash
-
-source /usr/local/etc/library.sh
-
-# INIT NCP CONFIG (first run)
-persistent_cfg /usr/local/etc/ncp-config.d /data/ncp
-persistent_cfg /usr/local/bin /data/bin
-persistent_cfg /etc/services-enabled.d
-persistent_cfg /etc/letsencrypt # persist SSL certificates
-persistent_cfg /etc/shadow # persist ncp-web password
-persistent_cfg /etc/cron.d
-persistent_cfg /etc/cron.daily
-persistent_cfg /etc/cron.hourly
-persistent_cfg /etc/cron.weekly
-
-exit 0
-EOF
+ :
}
# for non docker images
@@ -142,24 +118,11 @@ EOF
}
# update nc-restore
- cd "$CONFDIR" &>/dev/null
- install_script nc-backup.sh
- install_script nc-restore.sh
- cd - &>/dev/null
-
- # Update btrfs-sync
- wget -q https://raw.githubusercontent.com/nachoparker/btrfs-sync/master/btrfs-sync -O /usr/local/bin/btrfs-sync
-
- # Update php imagick
- apt-get install -y --no-install-recommends imagemagick php7.2-imagick php7.2-exif
+ install_app nc-backup
+ install_app nc-restore
# update to NC14.0.4
- F="$CONFDIR"/nc-autoupdate-nc.sh
- grep -q '^ACTIVE_=yes$' "$F" && {
- cd "$CONFDIR" &>/dev/null
- activate_script nc-autoupdate-nc.sh
- cd - &>/dev/null
- }
+ is_active_app nc-autoupdate-nc && run_app nc-autoupdate-nc
# remove redundant opcache configuration. Leave until update bug is fixed -> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815968
# Bug #416 reappeared after we moved to php7.2 and debian buster packages. (keep last)
@@ -169,6 +132,12 @@ EOF
# in NC14.0.4 the referrer policy is included in .htaccess
grep -q Referrer-Policy /var/www/nextcloud/.htaccess && sed -i /Referrer-Policy/d /etc/apache2/apache2.conf
+ # install new dependencies
+ type jq &>/dev/null || {
+ apt-get update
+ apt-get install -y --no-install-recommends jq
+ }
+
} # end - only live updates
exit 0