Skip to content

Commit 85cb1f0

Browse files
committed
nc-import-ncp: run activated apps upon import
Signed-off-by: nachoparker <nacho@ownyourbits.com>
1 parent 35a3a54 commit 85cb1f0

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

bin/ncp-update

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
./update.sh || exit $?
2424

2525
cd "$TMPDIR"
26-
git describe --always --tags --abbrev=0 2>/dev/null | grep -oP "v\d+\.\d+\.\d+" || git fetch --unshallow --tags
26+
git describe --always --tags --abbrev=0 2>/dev/null | grep -qoP "v\d+\.\d+\.\d+" || git fetch --unshallow --tags
2727
VER=$( git describe --always --tags --abbrev=0 | grep -oP "v\d+\.\d+\.\d+" )
2828

2929
# check format

bin/ncp/BACKUPS/nc-export-ncp.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ configure()
1313
{
1414
[[ -d "$DIR" ]] || { echo "directory $DIR does not exist"; return 1; }
1515

16-
local destfile="$DIR"/ncp-config_$( date +"%Y%m%d" ).tar
16+
local destfile
17+
destfile="$DIR"/ncp-config_$(date +"%Y%m%d").tar
1718

1819
tar -cf "$destfile" -C /usr/local/etc/ncp-config.d .
1920
chmod 600 "$destfile"
2021

21-
cd $OLDPWD
22-
rm -rf /tmp/ncp-export
2322
echo -e "configuration exported to $destfile"
2423
}
2524

bin/ncp/BACKUPS/nc-import-ncp.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,33 @@
99

1010

1111

12-
CFGDIR="/usr/local/etc/ncp-config.d"
1312

1413
configure()
1514
{
1615
[[ -f "$FILE" ]] || { echo "export file $FILE does not exist"; return 1; }
1716

18-
source /usr/local/etc/library.sh || return 1
1917
cd "$CFGDIR" || return 1
2018

2119
# extract export
2220
tar -xf "$FILE" -C "$CFGDIR"
2321

24-
# UGLY workaround to prevent apache from restarting upon activating some extras
25-
# which leads to the operation appearing to fail in ncp-web
26-
#echo "invalid_op" >> /etc/apache2/sites-available/000-default.conf
22+
# activate ncp-apps
23+
find "${CFGDIR}/" -name '*.cfg' | while read -r cfg; do
24+
app="$(basename "${cfg}" .cfg)"
25+
if [[ "${app}" == "letsencrypt" ]] || [[ "${app}" == "dnsmasq" ]]; then
26+
continue
27+
fi
28+
is_active_app "${app}" && run_app "${app}"
29+
done
2730

28-
# activate
29-
# TODO
30-
31-
# Fix invalid configuration
32-
#sed -i "/^invalid_op/d" /etc/apache2/sites-available/000-default.conf
31+
# order is important for these
32+
is_active_app "dnsmasq" && run_app "dnsmasq"
33+
is_active_app "letsencrypt" && run_app "letsencrypt"
3334

3435
echo -e "\nconfiguration restored"
3536

3637
# delayed in bg so it does not kill the connection, and we get AJAX response
37-
bash -c "sleep 2 && service apache2 reload" &>/dev/null &
38+
apachectl -k graceful
3839
}
3940

4041
install() { :; }

bin/ncp/SECURITY/modsecurity.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
# More at ownyourbits.com
99
#
1010

11-
NCDIR=/var/www/nextcloud/
12-
NCPWB=/var/www/ncp-web/
13-
1411
install()
1512
{
1613
apt-get update
@@ -42,6 +39,9 @@ EOF
4239

4340
configure()
4441
{
42+
local NCDIR=/var/www/nextcloud/
43+
local NCPWB=/var/www/ncp-web/
44+
4545
cat > /etc/modsecurity/modsecurity_crs_99_whitelist.conf <<EOF
4646
<Directory $NCDIR>
4747
# VIDEOS
@@ -92,8 +92,7 @@ EOF
9292
[[ $ACTIVE == "yes" ]] && echo "Enabling module security2" || echo "Disabling module security2"
9393
[[ $ACTIVE == "yes" ]] && a2enmod security2 &>/dev/null || a2dismod security2 &>/dev/null
9494

95-
# delayed in bg so it does not kill the connection, and we get AJAX response
96-
bash -c "sleep 2 && service apache2 reload" &>/dev/null &
95+
apachectl -k graceful
9796
}
9897

9998
# License

0 commit comments

Comments
 (0)