From dd1fdca7038ffa3c6014f3faaf0e7445be4f5c93 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Mon, 24 Aug 2015 15:22:41 +0200 Subject: [PATCH] Added upgrade script --- scripts/upgrade | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 scripts/upgrade diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..9a9877b --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,59 @@ +#!/bin/bash + + +debianversionname=$(lsb_release -a | grep Codename | awk -F' ' '{print $2}') + +# Retrieve arguments +domain=$(sudo yunohost app setting syncthing domain) +path=$(sudo yunohost app setting syncthing path) +db_user=ampache +db_pwd=$(sudo yunohost app setting syncthing mysqlpwd) +admin_ampache=$(sudo yunohost app setting syncthing admin) + +# Remove trailing "/" for next commands +path=${path%/} + + +# first make a copy of the db +mysqldump -u $db_user -p$db_pwd --add-drop-table --allow-keywords ampache > $final_path/ampache-db-backup.sql + +# Copy files to the right place +final_path=/var/www/ampache +sudo cp -a ../sources/* $final_path +sudo cp ../conf/ampache.cfg.php $final_path/config/ampache.cfg.php + +# Change variables in Ampache configuration +sudo sed -i "s/yunouser/$db_user/g" $final_path/config/ampache.cfg.php +sudo sed -i "s/yunopass/$db_pwd/g" $final_path/config/ampache.cfg.php +sudo sed -i "s/yunobase/$db_user/g" $final_path/config/ampache.cfg.php +sed -i "s@PATHTOCHANGE@$path@g" $final_path/config/ampache.cfg.php +sed -i "s@DOMAINTOCHANGE@$domain@g" $final_path/config/ampache.cfg.php + + +# Set permissions to roundcube directory +sudo chown -R www-data: $final_path + +# Modify Nginx configuration file and copy it to Nginx conf directory +sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf* +sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf* +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/ampache.conf + + +# Reload Nginx and regenerate SSOwat conf +sudo service nginx reload +sudo yunohost app setting ampache skipped_uris -v "/" +sudo yunohost app ssowatconf + +# Ampache installation +echo "127.0.0.1 $domain #yunoampache" | sudo tee -a /etc/hosts +sleep 1 +curl -kL -X POST http://$domain$path/update.php?action=update > /dev/null 2>&1 +sleep 5 +[ "$debianversionname" == "wheezy" ] && \ +sudo sed -i 's/;transcode_cmd = "ffmpeg"/transcode_cmd = "ffmpeg"/g' /var/www/ampache/config/ampache.cfg.php && \ +sudo sed -i 's/^transcode_cmd = "avconv"/;transcode_cmd = "avconv"/g' /var/www/ampache/config/ampache.cfg.php +sudo yunohost app setting ampache skipped_uris -d +sudo yunohost app setting ampache skipped_uris -v "/rest" +sudo yunohost app ssowatconf +sudo sed '/yunoampache/d' /etc/hosts > /tmp/hosts.tmp +sudo cp /tmp/hosts.tmp /etc/hosts ; sudo rm -f /tmp/hosts.tmp