2017-04-28 04:34:16 +02:00
|
|
|
# No set -eu for this particular app restore script (see comment near the end)
|
|
|
|
#set -eu
|
|
|
|
|
|
|
|
restore_dir=$1
|
|
|
|
app=$2
|
|
|
|
|
|
|
|
# Get old parameter of the app
|
2019-08-17 22:50:45 +02:00
|
|
|
domain=$(sudo yunohost app setting $app domain)
|
|
|
|
path=$(sudo yunohost app setting $app path)
|
2017-04-28 04:34:16 +02:00
|
|
|
|
|
|
|
# Restore www directory
|
|
|
|
sudo cp -a "${restore_dir}/var/www/$app" /var/www/$app
|
|
|
|
|
|
|
|
# Restore nginx conf
|
|
|
|
nginx_conf=/etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
sudo cp -a "${restore_dir}/conf/nginx.conf" $nginx_conf
|
|
|
|
|
|
|
|
# Restore custom file
|
|
|
|
sudo cp -a "${restore_dir}/importantfile" /etc/importantfile
|
|
|
|
|
2019-08-17 22:50:45 +02:00
|
|
|
sudo yunohost app checkport 12345
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
echo "Ogod noez the port 12345 aint available!!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-04-28 04:34:16 +02:00
|
|
|
# Restore the database
|
|
|
|
db_user=$app
|
2019-08-17 22:50:45 +02:00
|
|
|
db_pwd=$(sudo yunohost app setting $app mysqlpwd)
|
|
|
|
sudo yunohost app initdb $db_user -p $db_pwd
|
2017-04-28 04:34:16 +02:00
|
|
|
sudo su -c "mysql -u $db_user -p$db_pwd $app < ${restore_dir}/db.sql"
|
|
|
|
# Some scripts wanted to delete the db.sql... This won't make the script crash
|
|
|
|
# even if restore_dir is in read-only as long as there's no set -eu activated...
|
|
|
|
sudo rm ${restore_dir}/db.sql
|
|
|
|
|
2019-08-23 18:20:41 +02:00
|
|
|
# Set the app as public
|
|
|
|
sudo yunohost app setting $app unprotected_uris -v "/"
|
|
|
|
|
2017-04-28 04:34:16 +02:00
|
|
|
# Reload/reconfigure services
|
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|