1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/teampass_ynh.git synced 2024-09-03 20:26:37 +02:00
teampass_ynh/scripts/restore

58 lines
1.7 KiB
Text
Raw Normal View History

#!/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)
# 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
2016-12-14 16:02:43 +01:00
# Restore YunoHost parameters
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-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
sudo service nginx reload