From 06423bf4ae86ec695d4dcde482f1f316a79e5cd6 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Tue, 23 May 2017 18:37:15 +0200 Subject: if ACTIVE=yes by default, launch configure for that script on update --- etc/library.sh | 11 +++++++++++ etc/nextcloudpi-config.d/NFS.sh | 3 +++ etc/nextcloudpi-config.d/dnsmasq.sh | 2 +- etc/nextcloudpi-config.d/fail2ban.sh | 2 +- etc/nextcloudpi-config.d/nc-scan-auto.sh | 6 +++--- etc/nextcloudpi-config.d/nc-wifi.sh | 10 ++++++++++ etc/nextcloudpi-config.d/no-ip.sh | 2 +- etc/nextcloudpi-config.d/samba.sh | 3 +++ update.sh | 9 +++++++-- 9 files changed, 40 insertions(+), 8 deletions(-) diff --git a/etc/library.sh b/etc/library.sh index 12ae1de6..c594d68f 100755 --- a/etc/library.sh +++ b/etc/library.sh @@ -202,6 +202,17 @@ function install_script() ) } +function activate_script() +{ + ( + local SCRIPT=$1 + source ./$SCRIPT + echo -e "Activating \e[1m$( basename $SCRIPT .sh )\e[0m" + set +x + configure + ) +} + function info_script() { ( diff --git a/etc/nextcloudpi-config.d/NFS.sh b/etc/nextcloudpi-config.d/NFS.sh index 2e64f407..31d6837c 100644 --- a/etc/nextcloudpi-config.d/NFS.sh +++ b/etc/nextcloudpi-config.d/NFS.sh @@ -14,6 +14,7 @@ # More at: https://ownyourbits.com # +ACTIVE_=no DIR_=/media/USBdrive/ncdata/admin/files SUBNET_=192.168.1.0/24 USER_=www-data @@ -41,6 +42,8 @@ from 'nextcloudpi-config'" \ configure() { + [[ $ACTIVE_ != "yes" ]] && { service nfs-kernel-server stop; systemctl disable nfs-kernel-server; return; } + # CHECKS ################################ [ -d "$DIR_" ] || { echo -e "INFO: directory $DIR_ does not exist. Creating"; mkdir -p "$DIR_"; } diff --git a/etc/nextcloudpi-config.d/dnsmasq.sh b/etc/nextcloudpi-config.d/dnsmasq.sh index 03b16adf..d475c51f 100644 --- a/etc/nextcloudpi-config.d/dnsmasq.sh +++ b/etc/nextcloudpi-config.d/dnsmasq.sh @@ -30,7 +30,7 @@ install() configure() { - [[ $ACTIVE_ == "no" ]] && { service dnsmasq stop; update-rc.d dnsmasq disable; return; } + [[ $ACTIVE_ != "yes" ]] && { service dnsmasq stop; update-rc.d dnsmasq disable; return; } cat > /etc/dnsmasq.conf <>> If there are too many files this can greatly affect performance. <<< \n -SCANINTERVAL=0 will disable periodic synchronization." \ +>>> If there are too many files this can greatly affect performance. <<<" \ 20 90 } configure() { - [[ $SCANINTERVAL_ == 0 ]] && { + [[ $ACTIVE_ != "yes" ]] && { systemctl stop nc-scan.timer systemctl disable nc-scan.timer return 0 diff --git a/etc/nextcloudpi-config.d/nc-wifi.sh b/etc/nextcloudpi-config.d/nc-wifi.sh index f13abec3..a59d0a9d 100644 --- a/etc/nextcloudpi-config.d/nc-wifi.sh +++ b/etc/nextcloudpi-config.d/nc-wifi.sh @@ -15,6 +15,7 @@ # More at https://ownyourbits.com/ # +ACTIVE_=no DESCRIPTION="Configure your Wi-Fi connection" install() @@ -40,6 +41,15 @@ show_info() configure() { + [[ $ACTIVE_ != "yes" ]] && { + systemctl stop wicd + systemctl disable wicd + systemctl start dhcpcd + systemctl enable dhcpcd + systemctl start nextcloud-domain + return; + } + # Installation in QEMU (without a wireless interface) produces # wicd installation to generate 'wireless_interface = None'. # It does not hurt to restart it to wlan0 for RPi3 & zero w diff --git a/etc/nextcloudpi-config.d/no-ip.sh b/etc/nextcloudpi-config.d/no-ip.sh index aa0336a3..17f44e52 100644 --- a/etc/nextcloudpi-config.d/no-ip.sh +++ b/etc/nextcloudpi-config.d/no-ip.sh @@ -63,7 +63,7 @@ show_info() configure() { - [[ $ACTIVE_ == "no" ]] && { service noip2 stop; update-rc.d noip2 disable; return; } + [[ $ACTIVE_ != "yes" ]] && { service noip2 stop; update-rc.d noip2 disable; return; } /usr/local/bin/noip2 -C -c /usr/local/etc/no-ip2.conf -U $TIME_ -u $USER_ -p $PASS_ update-rc.d noip2 defaults diff --git a/etc/nextcloudpi-config.d/samba.sh b/etc/nextcloudpi-config.d/samba.sh index 95e87608..5e9e8d23 100644 --- a/etc/nextcloudpi-config.d/samba.sh +++ b/etc/nextcloudpi-config.d/samba.sh @@ -14,6 +14,7 @@ # More at: https://ownyourbits.com # +ACTIVE_=no DIR_=/media/USBdrive/ncdata/admin/files USER_=pi PWD_=raspberry @@ -43,6 +44,8 @@ from 'nextcloudpi-config'" \ configure() { + [[ $ACTIVE_ != "yes" ]] && { service smbd stop; update-rc.d smbd disable; return; } + # CHECKS ################################ [ -d "$DIR_" ] || { echo -e "INFO: directory $DIR_ does not exist. Creating"; mkdir -p "$DIR_"; } diff --git a/update.sh b/update.sh index c23f0ebb..d6b6d76e 100755 --- a/update.sh +++ b/update.sh @@ -21,8 +21,13 @@ done # install new entries of nextcloudpi-config and update others for file in etc/nextcloudpi-config.d/*; do - [ -f $file ] || continue; - [ -f /usr/local/$file ] || install_script $file + [ -f $file ] || continue; # skip dirs + [ -f /usr/local/$file ] || { # new entry + install_script $file # install + + # configure if active by default + grep -q '^ACTIVE_=yes$' $file && activate_script $file + } # save current configuration to (possibly) updated script [ -f /usr/local/$file ] && { -- cgit v1.2.3