From b98c767cc0203d2eb0acdcd0866c51300d553fc0 Mon Sep 17 00:00:00 2001 From: aquaxp Date: Fri, 21 Mar 2014 20:59:06 +0700 Subject: [PATCH] upgrade script with database backup --- TODO.md | 2 +- scripts/install | 6 +----- scripts/remove | 12 ++++++++++-- scripts/upgrade | 40 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/TODO.md b/TODO.md index a494f97..b4bca5b 100644 --- a/TODO.md +++ b/TODO.md @@ -2,4 +2,4 @@ TODO ---- Adding LDAP usernames -Auto setup admin account and other system defined things. \ No newline at end of file +Auto setup admin account and other system defined things. diff --git a/scripts/install b/scripts/install index c3e1807..97a3654 100644 --- a/scripts/install +++ b/scripts/install @@ -30,6 +30,7 @@ sudo chmod 755 $final_path/Specific/db/db.sqlite sudo sed -i "s@PATHTOCHANGE@$path@g" /etc/nginx/conf.d/$domain.d/baikal.conf sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/baikal.conf +# Change variables in Baikal sources for correct work in subpathes sudo sed -i "s@PROJECT_BASEURI_@\"$path/\"@g" $final_path/Core/Frameworks/Baikal/Model/Config/System.php # Reload Nginx and regenerate SSOwat conf @@ -37,8 +38,3 @@ sudo service php5-fpm restart sudo service nginx reload sudo yunohost app setting baikal skipped_uris -v "/" sudo yunohost app ssowatconf - -# Unprotect URIs -#sudo yunohost app setting owncloud skipped_uris -v "/public.php,/core,/apps/files,/index.php/apps/files" -#sudo yunohost app setting owncloud unprotected_uris -v "/remote.php,/cron.php,/status.php" -#sudo yunohost app ssowatconf \ No newline at end of file diff --git a/scripts/remove b/scripts/remove index 76a8ca9..54674d1 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,8 +1,16 @@ #!/bin/bash +# Backuping db +backup_path=/var/cache/yunohost/backups/baikal +final_path=/var/www/baikal/ + +mkdir -p $backup_path +sudo cp -a $final_path/Specific/* $backup_path + +# Removing executable files sudo rm -rf /var/www/baiakl sudo rm -f /etc/nginx/conf.d/$domain.d/baikal.conf - +# Restarting services sudo service php5-fpm restart -sudo service nginx reload \ No newline at end of file +sudo service nginx reload diff --git a/scripts/upgrade b/scripts/upgrade index 6888ec4..552584b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,3 +1,41 @@ #!/bin/bash -#nothing to do \ No newline at end of file +# Retrieve arguments +domain=$(sudo yunohost app setting owncloud domain) +path=$(sudo yunohost app setting owncloud path) + +# Remove trailing "/" for next commands +path=${path%/} + +# Backuping db +backup_path=/var/cache/yunohost/backups/baikal +final_path=/var/www/baikal/ + +mkdir -p $backup_path +sudo cp -a $final_path/Specific/* $backup_path + +# Copy files to the right place +sudo mkdir -p $final_path +sudo cp -a ../sources/* $final_path +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/baikal.conf +sudo chown -R www-data:www-data $final_path +sudo find $final_path -type d -exec chmod 755 {} \; +sudo touch $final_path/Specific/ENABLE_INSTALL +#sudo chmod 755 $final_path/Specific +#sudo chmod 755 $final_path/Specific/db +#sudo chmod 755 $final_path/Specific/db/db.sqlite + +# Change variables in Baikal configuration +sudo sed -i "s@PATHTOCHANGE@$path@g" /etc/nginx/conf.d/$domain.d/baikal.conf +sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" /etc/nginx/conf.d/$domain.d/baikal.conf + +sudo sed -i "s@PROJECT_BASEURI_@\"$path/\"@g" $final_path/Core/Frameworks/Baikal/Model/Config/System.php + +# Restoring backup +sudo cp -a $backup_path/* $final_path/Specific + +# Reload Nginx and regenerate SSOwat conf +sudo service php5-fpm restart +sudo service nginx reload +sudo yunohost app setting baikal skipped_uris -v "/" +sudo yunohost app ssowatconf