1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/bozon_ynh.git synced 2024-09-03 18:16:09 +02:00
bozon_ynh/scripts/restore

46 lines
1.3 KiB
Text
Raw Normal View History

2016-03-23 19:30:43 +01:00
#! /bin/bash
2016-04-04 22:35:43 +02:00
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -e
2016-05-23 20:59:08 +02:00
# causes the shell to exit if you try to use an uninitialised variable
set -u
2016-04-04 22:35:43 +02:00
2016-05-23 21:40:55 +02:00
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
#retrieve arguments
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME
else
app=bozon
fi
save_path=$1
domain=$(sudo yunohost app setting $app domain)
2016-04-04 20:01:54 +02:00
# definie useful vars
2016-03-23 19:30:43 +01:00
app=bozon
2016-04-04 20:01:54 +02:00
parent_path=/var/www
final_path=$parent_path/$app
2016-04-05 20:03:26 +02:00
data_path=/home/yunohost.app/$app
2016-04-04 20:01:54 +02:00
2016-04-05 20:03:26 +02:00
# restore sources & data
sudo mv $save_path/www/. $final_path/
sudo mv $save_path/datas/. $data_path/
2016-04-04 20:01:54 +02:00
# restore permissions
sudo chown -R root: $final_path
sudo find $final_path -type f | xargs sudo chmod 644
sudo find $final_path -type d | xargs sudo chmod 755
sudo chown -R www-data: $final_path/private
2016-04-05 20:03:26 +02:00
sudo chown -R www-data: $data_path/uploads
sudo chown -R www-data: $data_path/thumbs
2016-03-23 19:30:43 +01:00
2016-05-23 20:59:08 +02:00
# restore php-fpm, Nginx and YunoHost parameters
2016-04-05 20:03:26 +02:00
sudo cp -a $save_path/yunohost/. /etc/yunohost/apps/$app/
2016-04-04 20:01:54 +02:00
sudo cp -a $save_path/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
2016-05-23 20:59:08 +02:00
sudo cp -a $save_path/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf
# Restart services
sudo service php5-fpm restart || true
sudo service nginx restart || true
sudo yunohost app ssowatconf