Skip to content

Commit

Permalink
if ACTIVE=yes by default, launch configure for that script on update
Browse files Browse the repository at this point in the history
  • Loading branch information
nacho committed May 23, 2017
1 parent d303e76 commit 8c91f10
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 8 deletions.
11 changes: 11 additions & 0 deletions etc/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
(
Expand Down
3 changes: 3 additions & 0 deletions etc/nextcloudpi-config.d/NFS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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_"; }
Expand Down
2 changes: 1 addition & 1 deletion etc/nextcloudpi-config.d/dnsmasq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
domain-needed # Never forward plain names (without a dot or domain part)
Expand Down
2 changes: 1 addition & 1 deletion etc/nextcloudpi-config.d/fail2ban.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ install()

configure()
{
[[ $ACTIVE_ == "no" ]] && { service fail2ban stop; update-rc.d fail2ban disable; return; }
[[ $ACTIVE_ != "yes" ]] && { service fail2ban stop; update-rc.d fail2ban disable; return; }

touch /var/www/nextcloud/data/nextcloud.log
chown -R www-data /var/www/nextcloud/data
Expand Down
6 changes: 3 additions & 3 deletions etc/nextcloudpi-config.d/nc-scan-auto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# More at: https://ownyourbits.com
#

ACTIVE_=no
SCANINTERVAL_=60
DESCRIPTION="Periodically scan NC for externally modified files"

Expand All @@ -23,14 +24,13 @@ show_info()
--backtitle "NextCloudPi configuration" \
--title "Instructions for auto synchronization" \
"Set the time in minutes in SCANINTERVAL. \n
>>> If there are too many files this can greatly affect performance. <<< \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
Expand Down
10 changes: 10 additions & 0 deletions etc/nextcloudpi-config.d/nc-wifi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# More at https://ownyourbits.com/
#

ACTIVE_=no
DESCRIPTION="Configure your Wi-Fi connection"

install()
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion etc/nextcloudpi-config.d/no-ip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions etc/nextcloudpi-config.d/samba.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# More at: https://ownyourbits.com
#

ACTIVE_=no
DIR_=/media/USBdrive/ncdata/admin/files
USER_=pi
PWD_=raspberry
Expand Down Expand Up @@ -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_"; }
Expand Down
9 changes: 7 additions & 2 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] && {
Expand Down

0 comments on commit 8c91f10

Please sign in to comment.