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/upgrade
Maniack Crudelis a11a88dfbf Refactoring et upgrade 2.1.26-final
L'upgrade depuis la précédente version a été testé, mais une sauvegarde préalable n'est pas inutile
2017-08-05 23:16:02 +02:00

93 lines
2.9 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
BACKUP_BEFORE_UPGRADE # Backup the current version of the app
ynh_clean_setup () {
BACKUP_FAIL_UPGRADE # restore it if the upgrade fails
}
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
#=================================================
# CHECK THE PATH
#=================================================
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path.
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_system_user_create $app # Create the dedicated user, if not exist
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_add_fpm_config # Créer le fichier de configuration du pool php-fpm et le configure.
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ...
#=================================================
#=================================================
# CREATE A CRON FILE FOR AUTOMATIC BACKUP
#=================================================
echo "0 0 * * 0 $app cd $final_path/backups && php script.backup.php" > /etc/cron.d/teampass
#=================================================
# GENERIC FINALISATION
#=================================================
# SECURING FILES AND DIRECTORIES
#=================================================
# Les fichiers appartiennent à root
sudo chown -R root: $final_path
# Sauf les dossiers files et upload
sudo chown -R $app: $final_path/files $final_path/upload
# Restreint l'accès au dossier de backup
sudo chmod 750 $final_path/backups
#=================================================
# RELOAD NGINX
#=================================================
sudo systemctl reload nginx