Skip to content

Commit

Permalink
nc-import-ncp: run activated apps upon import
Browse files Browse the repository at this point in the history
Signed-off-by: nachoparker <[email protected]>
  • Loading branch information
nachoparker committed Oct 14, 2021
1 parent 35a3a54 commit 85cb1f0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bin/ncp-update
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
./update.sh || exit $?

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

# check format
Expand Down
5 changes: 2 additions & 3 deletions bin/ncp/BACKUPS/nc-export-ncp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ configure()
{
[[ -d "$DIR" ]] || { echo "directory $DIR does not exist"; return 1; }

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

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

cd $OLDPWD
rm -rf /tmp/ncp-export
echo -e "configuration exported to $destfile"
}

Expand Down
23 changes: 12 additions & 11 deletions bin/ncp/BACKUPS/nc-import-ncp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,33 @@



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

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

source /usr/local/etc/library.sh || return 1
cd "$CFGDIR" || return 1

# extract export
tar -xf "$FILE" -C "$CFGDIR"

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

# activate
# TODO

# Fix invalid configuration
#sed -i "/^invalid_op/d" /etc/apache2/sites-available/000-default.conf
# order is important for these
is_active_app "dnsmasq" && run_app "dnsmasq"
is_active_app "letsencrypt" && run_app "letsencrypt"

echo -e "\nconfiguration restored"

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

install() { :; }
Expand Down
9 changes: 4 additions & 5 deletions bin/ncp/SECURITY/modsecurity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
# More at ownyourbits.com
#

NCDIR=/var/www/nextcloud/
NCPWB=/var/www/ncp-web/

install()
{
apt-get update
Expand Down Expand Up @@ -42,6 +39,9 @@ EOF

configure()
{
local NCDIR=/var/www/nextcloud/
local NCPWB=/var/www/ncp-web/

cat > /etc/modsecurity/modsecurity_crs_99_whitelist.conf <<EOF
<Directory $NCDIR>
# VIDEOS
Expand Down Expand Up @@ -92,8 +92,7 @@ EOF
[[ $ACTIVE == "yes" ]] && echo "Enabling module security2" || echo "Disabling module security2"
[[ $ACTIVE == "yes" ]] && a2enmod security2 &>/dev/null || a2dismod security2 &>/dev/null

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

# License
Expand Down

0 comments on commit 85cb1f0

Please sign in to comment.