Skip to content

Commit

Permalink
restart HTTPd delayed on the bg, so it does not kill AJAX response
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Aug 10, 2017
1 parent 41e71b4 commit 1e98c8e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
9 changes: 5 additions & 4 deletions etc/nextcloudpi-config.d/modsecurity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ a basic NextCloud installation. If a new App does not work disable it" \

configure()
{

cat >> /etc/modsecurity/modsecurity_crs_99_whitelist.conf <<EOF
cat > /etc/modsecurity/modsecurity_crs_99_whitelist.conf <<EOF
<Directory $NCDIR_>
# VIDEOS
SecRuleRemoveById 958291 # Range Header Checks
Expand Down Expand Up @@ -120,8 +119,10 @@ EOF

[[ $ACTIVE_ == "yes" ]] && local STATE=On || local STATE=Off
sed -i "s|SecRuleEngine .*|SecRuleEngine $STATE|" /etc/modsecurity/modsecurity.conf
a2enmod security2
service apache2 restart
[[ $ACTIVE_ == "yes" ]] && a2enmod security2 || a2dismod security2

# delayed in bg so it does not kill the connection, and we get AJAX response
( sleep 2 && systemctl restart apache2 ) &>/dev/null &
}

cleanup()
Expand Down
9 changes: 6 additions & 3 deletions etc/nextcloudpi-config.d/nc-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ configure()
[[ $( stat -fc%d / ) == $( stat -fc%d $BASEDIR ) ]] && \
echo -e "INFO: moving database to another place in the same SD card\nIf you want to use an external mount, make sure it is properly set up"

service apache2 stop
service mysql stop
cd /var/www/nextcloud
sudo -u www-data php occ maintenance:mode --on

echo "moving database to $DBDIR_..."
service mysql stop
mv $SRCDIR "$DBDIR_" || return 1
sed -i "s|^datadir.*|datadir = $DBDIR_|" /etc/mysql/mariadb.conf.d/50-server.cnf
service mysql start

service mysql start && service apache2 start
sudo -u www-data php occ maintenance:mode --off
}

install(){ :; }
Expand Down
7 changes: 4 additions & 3 deletions etc/nextcloudpi-config.d/nc-datadir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ configure()
echo -e "INFO: moving data dir to another place in the same SD card\nIf you want to use an external mount, make sure it is properly set up"

## COPY
service apache2 stop
cd /var/www/nextcloud
sudo -u www-data php occ maintenance:mode --on

echo "moving data dir to $DATADIR_..."
cp -ra "$SRCDIR" "$DATADIR_" || return 1

# tmp upload dir
Expand All @@ -70,9 +72,8 @@ configure()
sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$DATADIR_/.opcache|" /etc/php/7.0/mods-available/opcache.ini

# datadir
cd /var/www/nextcloud
sudo -u www-data php occ config:system:set datadirectory --value=$DATADIR_
service apache2 start
sudo -u www-data php occ maintenance:mode --off
}

install() { :; }
Expand Down
5 changes: 4 additions & 1 deletion etc/nextcloudpi-config.d/nc-httpsonly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ configure()
{
[[ $ACTIVE_ == "no" ]] && local OPT=Off || local OPT=On
sed -i "s|RewriteEngine .*|RewriteEngine $OPT|" /etc/apache2/sites-available/000-default.conf
service apache2 reload
echo "Forcing HTTPS $OPT"

# delayed in bg so it does not kill the connection, and we get AJAX response
( sleep 2 && systemctl restart apache2 ) &>/dev/null &
}

install() { :; }
Expand Down
4 changes: 0 additions & 4 deletions etc/nextcloudpi-config.d/nc-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ show_info()

configure()
{
systemctl stop apache2;

## RE-CREATE DATABASE TABLE

echo "Setting up database..."
Expand Down Expand Up @@ -81,8 +79,6 @@ EOF

# Default trusted domain ( only from nextcloudpi-config )
test -f /usr/local/bin/nextcloud-domain.sh && bash /usr/local/bin/nextcloud-domain.sh

systemctl start apache2;
}

install(){ :; }
Expand Down
4 changes: 1 addition & 3 deletions etc/nextcloudpi-config.d/nc-nextcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ install() { :; }

configure()
{
systemctl stop apache2;

## RE-CREATE DATABASE TABLE

# wait for mariadb
Expand Down Expand Up @@ -174,7 +172,7 @@ EOF
crontab -u www-data /tmp/crontab_http
rm /tmp/crontab_http

systemctl start apache2;
systemctl start apache2

echo "Don't forget to run nc-init"
}
Expand Down
5 changes: 2 additions & 3 deletions etc/nextcloudpi-config.d/nc-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ configure()
[ -d $BASEDIR_ ] || { echo -e "$BASEDIR_ not found"; return 1; }
[ -d $BASEDIR_/nextcloud ] && { echo -e "WARNING: overwriting old instance"; }

service apache2 stop
cd $BASEDIR_/nextcloud
sudo -u www-data php occ maintenance:mode --on

# RESTORE FILES
echo -e "restore files..."
Expand All @@ -69,8 +70,6 @@ EOF

cd $BASEDIR_/nextcloud
sudo -u www-data php occ maintenance:mode --off

service apache2 start
}

install() { :; }
Expand Down

0 comments on commit 1e98c8e

Please sign in to comment.