backend: is_active() functionality

This commit is contained in:
nachoparker 2017-09-08 08:47:40 +02:00
parent 6e63b55274
commit 4a0a1824cc
7 changed files with 43 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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()
{
(

View File

@ -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

View File

@ -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 }' )

View File

@ -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

View File

@ -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= )