2015-05-30 19:37:21 +02:00
|
|
|
#!/bin/bash
|
2015-12-18 14:11:35 +01:00
|
|
|
|
|
|
|
# Récupère les infos de l'application.
|
2016-12-14 16:02:43 +01:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
# Source app helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
2015-05-30 19:37:21 +02:00
|
|
|
|
|
|
|
# The parameter $1 is the uncompressed restore directory location
|
|
|
|
backup_dir=$1/apps/$app
|
|
|
|
|
2016-12-14 16:02:43 +01:00
|
|
|
# Restore Nginx
|
|
|
|
conf=/etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
if [ -f $conf ]; then
|
|
|
|
echo "There is already a nginx conf file at this path: $conf " >&2
|
|
|
|
ynh_die
|
|
|
|
fi
|
|
|
|
sudo cp -a $backup_dir/nginx.conf $conf
|
2015-05-30 19:37:21 +02:00
|
|
|
|
2016-12-14 16:02:43 +01:00
|
|
|
# Restore YunoHost parameters
|
2015-05-30 19:37:21 +02:00
|
|
|
sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app
|
2016-12-14 16:02:43 +01:00
|
|
|
|
|
|
|
# Restore sources & data
|
|
|
|
sudo cp -a "$backup_dir/sources/." $final_path
|
|
|
|
|
|
|
|
# Créer la base de donnée et la restaure
|
|
|
|
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
|
|
|
db_user=$app
|
|
|
|
ynh_mysql_create_db $db_user $db_user $db_pwd
|
|
|
|
mysql --debug-check -u $db_user -p$db_pwd $db_user < ${backup_dir}/db.sql
|
2015-05-30 19:37:21 +02:00
|
|
|
|
2015-12-18 14:11:35 +01:00
|
|
|
# Copy dedicated php-fpm process from backup folder to the right location
|
|
|
|
sudo cp -a $backup_dir/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf
|
|
|
|
sudo cp -a $backup_dir/php-fpm.ini /etc/php5/fpm/conf.d/20-$app.ini
|
2016-12-14 16:02:43 +01:00
|
|
|
|
|
|
|
# ADD_SYS_USER # Créer un user système dédié pour l'application
|
|
|
|
if ! ynh_system_user_exists "$app" # Test l'existence de l'utilisateur
|
|
|
|
then
|
|
|
|
sudo useradd -d /var/www/$app --system --user-group $app --shell /usr/sbin/nologin || (echo "Unable to create $app system account" >&2 && false)
|
|
|
|
fi
|
2015-12-18 14:11:35 +01:00
|
|
|
|
|
|
|
# Copie du fichier sk.php
|
2016-12-14 16:02:43 +01:00
|
|
|
sudo mkdir /etc/teampass
|
2015-12-18 14:11:35 +01:00
|
|
|
sudo cp -a $backup_dir/sk.php /etc/teampass/sk.php
|
2016-12-14 16:02:43 +01:00
|
|
|
sudo chown -R root:$app /etc/teampass/sk.php
|
|
|
|
|
|
|
|
# Les fichiers appartiennent à root
|
|
|
|
sudo chown -R root:$app $final_path
|
|
|
|
|
|
|
|
# And Reload service
|
|
|
|
sudo service php5-fpm reload
|
2015-12-18 14:11:35 +01:00
|
|
|
|
2016-12-14 16:02:43 +01:00
|
|
|
# Reload webserver
|
2015-05-30 19:37:21 +02:00
|
|
|
sudo service nginx reload
|