Skip to content

Commit

Permalink
show ✓ if an item is activated in nextcloudpi-config
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed May 22, 2017
1 parent 092d22a commit aae7663
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 36 deletions.
73 changes: 41 additions & 32 deletions bin/nextcloudpi-config
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,52 @@ source /usr/local/etc/library.sh

function nextcloud-config()
{
local DIALOG_OK=0
local LIST=()
local VERFILE=/var/run/.ncp-latest-version
local BACKTITLE="NextCloudPi configuration ver. "
local CONFDIR=/usr/local/etc/nextcloudpi-config.d/
{
local DIALOG_OK=0
local VERFILE=/var/run/.ncp-latest-version
local BACKTITLE="NextCloudPi configuration ver. "
local CONFDIR=/usr/local/etc/nextcloudpi-config.d/

# save latest version if it has never done before
test -f $VERFILE || ncp-check-version
# save latest version if it has never done before
test -f $VERFILE || ncp-check-version

# ask for update if outdated
ncp-test-updates && \
whiptail --backtitle "$BACKTITLE $( cat /usr/local/etc/ncp-version )" \
--title "NextCloudPi update available" \
--clear --yesno "Update to $( cat $VERFILE )?" \
10 40
[[ $? -eq $DIALOG_OK ]] && ncp-update
# ask for update if outdated
ncp-test-updates && \
whiptail --backtitle "$BACKTITLE $( cat /usr/local/etc/ncp-version )" \
--title "NextCloudPi update available" \
--clear --yesno "Update to $( cat $VERFILE )?" \
10 40
[[ $? -eq $DIALOG_OK ]] && ncp-update

# launch the selection menu
for item in $CONFDIR/*.sh; do
local DESC=$( grep "DESCRIPTION=" $item | sed 's|^DESCRIPTION="||;s|"$||' )
LIST+=( $( basename $item .sh ) "$DESC" )
done
while true; do
local script
script=$( whiptail --backtitle "$BACKTITLE $( cat /usr/local/etc/ncp-version )" \
--title "NextCloudPi Software Configuration Tool (nextcloudpi-config)" \
--cancel-button Finish --ok-button Select \
--menu "Select program to configure and activate:" 20 100 10 \
"${LIST[@]}" \
3>&1 1>&2 2>&3 )
while true; do
# fill options
local LIST=()
for item in $CONFDIR/*.sh; do
local DESC=$( grep "DESCRIPTION=" $item | sed 's|^DESCRIPTION="||;s|"$||' )
grep -q "^ACTIVE_=yes" $item && local ON="" || local ON=" "
LIST+=( "$ON $( basename $item .sh )" "$DESC" )
done

[[ $? -ne $DIALOG_OK ]] || [[ "$script" == "" ]] && return 0
# launch the selection menu
local script
script=$( whiptail --backtitle "$BACKTITLE $( cat /usr/local/etc/ncp-version )" \
--title "NextCloudPi Software Configuration Tool (nextcloudpi-config)" \
--cancel-button Finish --ok-button Select \
--menu "Select program to configure and activate:" 20 105 10 \
"${LIST[@]}" \
3>&1 1>&2 2>&3 )

# launch selected script
info_script $script.sh || continue;
configure_script $script.sh
done
[[ $? -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
done
return
} # force to read the whole thing into memory, as its contents might change in update.sh
}

if [ $(id -u) -ne 0 ]; then
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 @@ -14,7 +14,7 @@
# More at: https://ownyourbits.com/2017/03/09/dnsmasq-as-dns-cache-server-for-nextcloudpi-and-raspbian/
#

ACTIVE_=yes
ACTIVE_=no
DOMAIN_=mycloud.ownyourbits.com
IP_=127.0.0.1
DNSSERVER_=8.8.8.8
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 @@ -14,7 +14,7 @@
# More at: https://ownyourbits.com/2017/02/24/nextcloudpi-fail2ban-installer/
#

ACTIVE_=yes
ACTIVE_=no

# location of Nextcloud logs
NCLOG_=/var/www/nextcloud/data/nextcloud.log
Expand Down
2 changes: 1 addition & 1 deletion etc/nextcloudpi-config.d/nc-ramlogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

ACTIVE_=no
DESCRIPTION="mount logs in RAM to prevent SD card degradation (faster, consumes more RAM)"
DESCRIPTION="mount logs in RAM to prevent SD degradation (faster, consumes more RAM)"

show_info()
{
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 @@ -15,7 +15,7 @@
# More at https://ownyourbits.com/2017/03/05/dynamic-dns-for-raspbian-with-no-ip-org-installer/
#

ACTIVE_=yes
ACTIVE_=no
[email protected]
PASS_=noip-pass
TIME_=30
Expand Down

0 comments on commit aae7663

Please sign in to comment.