Skip to content

Commit

Permalink
backend: is_active() functionality
Browse files Browse the repository at this point in the history
nachoparker committed Sep 8, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 6e63b55 commit 4a0a182
Showing 7 changed files with 43 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bin/nextcloudpi-config
Original file line number Diff line number Diff line change
@@ -34,11 +34,12 @@ function nextcloud-config()
[[ $? -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|"$||' )
grep -q "^ACTIVE_=yes" "$item" && local ON="" || local ON=" "
is_active_script "$item" && local ON="" || local ON=" "
LIST+=( "$ON $( basename "$item" .sh )" "$DESC" )
done

6 changes: 5 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

[v0.26.18](https://github.com/nextcloud/nextcloudpi/commit/a4144dc) (2017-09-07) refactor show_info(), make it only depend on variables
[v0.26.20](https://github.com/nextcloud/nextcloudpi/commit/bbbe114) (2017-09-08) backend: is_active() functionality

[v0.26.19](https://github.com/nextcloud/nextcloudpi/commit/9e7b3ab) (2017-09-08) letsencrypt: occ path fix

[v0.26.18](https://github.com/nextcloud/nextcloudpi/commit/0fcde74) (2017-09-07) refactor show_info(), make it only depend on variables

[v0.26.17](https://github.com/nextcloud/nextcloudpi/commit/0197f31) (2017-09-07) ncp-web: link to changelog

11 changes: 11 additions & 0 deletions etc/library.sh
Original file line number Diff line number Diff line change
@@ -210,6 +210,17 @@ function activate_script()
launch_script "$SCRIPT"
}

function is_active_script()
{
(
local SCRIPT=$1
unset is_active
source "$SCRIPT"
grep -q "^ACTIVE_=yes" "$SCRIPT" && return 0
[[ $( type -t is_active ) == function ]] && is_active
)
}

function launch_script()
{
(
5 changes: 5 additions & 0 deletions etc/nextcloudpi-config.d/letsencrypt.sh
Original file line number Diff line number Diff line change
@@ -28,6 +28,11 @@ Both ports 80 and 443 need to be accessible from the internet
Your certificate will be automatically renewed every month"

is_active()
{
test -d /etc/letsencrypt/live
}

install()
{
cd /etc || return 1
6 changes: 6 additions & 0 deletions etc/nextcloudpi-config.d/nc-database.sh
Original file line number Diff line number Diff line change
@@ -25,6 +25,12 @@ or the database will fail.
** If it ever fails with a white page, move the database back to the SD **"

is_active()
{
local SRCDIR=$( grep datadir /etc/mysql/mariadb.conf.d/50-server.cnf | awk -F "= " '{ print $2 }' )
[[ "$SRCDIR" != "/var/lib/mysql" ]]
}

configure()
{
local SRCDIR=$( grep datadir /etc/mysql/mariadb.conf.d/50-server.cnf | awk -F "= " '{ print $2 }' )
7 changes: 7 additions & 0 deletions etc/nextcloudpi-config.d/nc-datadir.sh
Original file line number Diff line number Diff line change
@@ -20,6 +20,13 @@ 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"

is_active()
{
local SRCDIR
SRCDIR=$( cd /var/www/nextcloud; sudo -u www-data php occ config:system:get datadirectory ) || return 1;
[[ "$SRCDIR" != "/var/www/nextcloud/data" ]]
}

configure()
{
## CHECKS
8 changes: 7 additions & 1 deletion etc/nextcloudpi-config.d/nc-swapfile.sh
Original file line number Diff line number Diff line change
@@ -14,10 +14,16 @@
# More at https://ownyourbits.com/
#

SWAPFILE_=/var/swap
SWAPFILE_=/media/USBdrive/swap
SWAPSIZE_=1024
DESCRIPTION="Move and resize your swapfile. Recommended to move to a permanent USB drive"

is_active()
{
local DIR=$( swapon -s | sed -n 2p | awk '{ print $1 }' )
[[ "$DIR" != "/var/swap" ]]
}

configure()
{
local ORIG=$( grep -oP "CONF_SWAPFILE=.*" /etc/dphys-swapfile | cut -f2 -d= )

0 comments on commit 4a0a182

Please sign in to comment.