Modified to use apache conf template and take app offline during upgrade
This commit is contained in:
74
install.sh
74
install.sh
@@ -201,10 +201,37 @@ then
|
||||
abort_exit
|
||||
else
|
||||
# proceed with upgrade
|
||||
|
||||
# take app offline during upgrade
|
||||
# put app in maintenance mode
|
||||
echo "Putting the applocation in maintenance mode..."
|
||||
# make sure mod_rewrite is enabled
|
||||
if [[ ! -e "$APACHE_CONF_DIR/../mods-enabled/rewrite.load" ]]
|
||||
then
|
||||
a2enmod -q rewrite
|
||||
systemctl restart apache2
|
||||
fi
|
||||
# disable the app
|
||||
a2disconf -q $install_loc_in
|
||||
systemctl reload apache2
|
||||
# modify the apache conf file
|
||||
if ! grep -q "RewriteEngine" "$APACHE_CONF_DIR/$install_loc_in.conf"
|
||||
then
|
||||
# this is an old version of the conf file. Replace with new version
|
||||
cp -f default-apache.conf $APACHE_CONF_DIR/$install_loc_in.conf
|
||||
sed -i "s|_APPNAME_|$APP_NAME|g" $APACHE_CONF_DIR/$install_loc_in.conf
|
||||
sed -i "s|_BASEURL_|$install_loc_in|g" $APACHE_CONF_DIR/$install_loc_in.conf
|
||||
sed -i "s|_DOCROOTIN_|$doc_root_in|g" $APACHE_CONF_DIR/$install_loc_in.conf
|
||||
fi
|
||||
sed -i "s|#Rewrite|Rewrite|g" $APACHE_CONF_DIR/$install_loc_in.conf
|
||||
# copy in the default maintenancemode.php if it's not already there
|
||||
if [[ ! -e "$install_path/maintenancemode.php" ]]
|
||||
then
|
||||
cp maintenancemode.php $install_path/
|
||||
# modify the maintenancemode.php file
|
||||
sed -i "s|_APPNAME_|$APP_NAME|g" $install_path/maintenancemode.php
|
||||
fi
|
||||
# re-enable the app in maintenance mode
|
||||
a2enconf -q $install_loc_in
|
||||
systemctl reload apache2
|
||||
|
||||
datestamp=$(date +%Y-%m-%d_%H:%M:%S)
|
||||
backupdir=backups/$datestamp
|
||||
@@ -231,8 +258,8 @@ then
|
||||
echo "Backing up current installation to the package directory."
|
||||
cp -R $install_path $backupdir/$install_loc_in-$datestamp-backup
|
||||
|
||||
# delete all existing installation files except db.php
|
||||
find $install_path/ -mindepth 1 -not -name 'db.php' -delete
|
||||
# delete all existing installation files except db.php and maintenancemode.php
|
||||
find $install_path/ -mindepth 1 ! \( -name 'db.php' -o -name 'maintenancemode.php' \) -delete
|
||||
|
||||
echo "Performing database updates..."
|
||||
# apply database updates from sql file
|
||||
@@ -271,6 +298,17 @@ then
|
||||
chown -R $httpd_user_group $install_path
|
||||
echo "Backups of the previous openlog files and the previous database were made"
|
||||
echo "and are located in the $backupdir directory."
|
||||
|
||||
# take app out of maintenance mode
|
||||
echo "Taking the app out of maintenance mode..."
|
||||
# disable the app
|
||||
a2disconf -q $install_loc_in
|
||||
systemctl reload apache2
|
||||
# modify the apache conf file
|
||||
sed -i "s|Rewrite|#Rewrite|g" $APACHE_CONF_DIR/$install_loc_in.conf
|
||||
# re-enable the app in production mode
|
||||
a2enconf -q $install_loc_in
|
||||
systemctl reload apache2
|
||||
fi
|
||||
else
|
||||
# This was a mistake. Exit now to avoid clobbering another app.
|
||||
@@ -369,10 +407,16 @@ else
|
||||
if [[ ! -f "$install_path/db.php" ]]
|
||||
then
|
||||
cp db.php.template $install_path/db.php
|
||||
sed -i "s/DBNAME/$new_db_name/g" $install_path/db.php
|
||||
sed -i "s/DBUSER/$db_user/g" $install_path/db.php
|
||||
sed -i "s/DBPASS/$db_pass/g" $install_path/db.php
|
||||
sed -i "s/APPNAME/$APP_NAME/g" $install_path/db.php
|
||||
sed -i "s|DBNAME|$new_db_name|g" $install_path/db.php
|
||||
sed -i "s|DBUSER|$db_user|g" $install_path/db.php
|
||||
sed -i "s|DBPASS|$db_pass|g" $install_path/db.php
|
||||
sed -i "s|APPNAME|$APP_NAME|g" $install_path/db.php
|
||||
fi
|
||||
# Create maintenancemode.php if it doesn't exist
|
||||
if [[ ! -f "$install_path/maintenancemode.php" ]]
|
||||
then
|
||||
cp maintenancemode.php $install_path/maintenancemode.php
|
||||
sed -i "s|_APPNAME_|$APP_NAME|g" $install_path/maintenancemode.php
|
||||
fi
|
||||
|
||||
# copy distribution to install location
|
||||
@@ -412,15 +456,11 @@ then
|
||||
fi
|
||||
if [[ "$operation" == "installed" ]]
|
||||
then
|
||||
echo "# $APP_NAME default Apache configuration" > $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "Alias /$base_url $doc_root_in/$base_url" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "<Directory $doc_root_in/$base_url>" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " AllowOverride Options" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " Options FollowSymLinks" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " DirectoryIndex index.php" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "</Directory>" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
cp -f default-apache.conf $APACHE_CONF_DIR/$base_url.conf
|
||||
sed -i "s|_APPNAME_|$APP_NAME|g" $APACHE_CONF_DIR/$base_url.conf
|
||||
sed -i "s|_BASEURL_|$base_url|g" $APACHE_CONF_DIR/$base_url.conf
|
||||
sed -i "s|_DOCROOTIN_|$doc_root_in|g" $APACHE_CONF_DIR/$base_url.conf
|
||||
|
||||
echo -n "The apache2 $base_url configuration must be enabled. Would you like to do that now? [Y/n] :"
|
||||
read enconf
|
||||
if [[ "$enconf" == "" || "$enconf" == "Y" || "$enconf" == "y" ]]
|
||||
|
||||
Reference in New Issue
Block a user