1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mopidy_ynh.git synced 2024-09-03 19:46:21 +02:00

Ajout des script update, restore, backup

This commit is contained in:
magikcypress 2017-03-08 13:11:33 +01:00
parent 56b76d9fa3
commit 12eaa4986d
3 changed files with 101 additions and 0 deletions

27
scripts/backup Normal file
View file

@ -0,0 +1,27 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
# The parameter $1 is the backup directory location dedicated to the app
backup_dir=$1
# The parameter $2 is theid of the app instance
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)
# Copy the app web files
sudo mkdir -p ${backup_dir}/var/www
sudo cp -a $final_path "${backup_dir}/var/www/$app"
# Copy the music files
sudo mkdir -p ${backup_dir}/var/lib/$app/
sudo cp -a $final_path "${backup_dir}/var/lib/$app"
# Copy the conf files
sudo mkdir -p "${backup_dir}/conf"
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf "${backup_dir}/conf/nginx.conf"

41
scripts/restore Normal file
View file

@ -0,0 +1,41 @@
#!/bin/bash
# This restore script is adapted to Yunohost >=2.4
# Exit on command errors and treat unset variables as an error
set -eu
# The parameter $1 is the backup directory location dedicated to the app
backup_dir=$1
# The parameter $2 is the id of the app instance ex: ynhexample__2
app=$YNH_APP_INSTANCE_NAME
# Source app helpers
source /usr/share/yunohost/helpers
# Get old parameter of the app
domain=$(ynh_app_setting_get $app domain)
path=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path)
if [ -d $final_path ]; then
ynh_die "There is already a directory: $final_path"
fi
conf=/etc/nginx/conf.d/$domain.d/$app.conf
if [ -f $conf ]; then
ynh_die "There is already a nginx conf file at this path: $conf"
fi
# Restore conf files
sudo cp -a "${backup_dir}/conf/nginx.conf" $conf
# Reload Nginx
sudo service nginx reload
sudo cp -a "${backup_dir}/var/www/$app" $final_path
sudo cp -a "${backup_dir}/var/lib/$app" "/var/lib/$app"
# Set permissions
sudo chown -R www-data: $final_path
sudo yunohost app ssowatconf

33
scripts/upgrade Normal file
View file

@ -0,0 +1,33 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
source .fonctions # Loads the generic functions usually used in the script
source /usr/share/yunohost/helpers # Source YunoHost helpers
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
admin=$(ynh_app_setting_get "$app" admin)
CHECK_PATH # Checks and corrects the syntax of the path.
# Check if admin is not null
if [[ "$admin" = "" ]]; then
echo "Unable to upgrade, please contact support"
ynh_die
fi
final_path=/var/www/$app
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@__PATHTOCHANGE__@$app@g" ../conf/nginx.conf*
sed -i "s@__FINALPATH__@$final_path/@g" ../conf/nginx.conf*
sed -i "s@__DOMAINNAME__@$domain/@g" ../conf/nginx.conf*
# Reload Nginx
sudo service nginx reload