mirror of
https://github.com/YunoHost-Apps/bozon_ynh.git
synced 2024-09-03 18:16:09 +02:00
commit
4d5fdc04b5
6 changed files with 22 additions and 65 deletions
|
@ -20,26 +20,8 @@
|
||||||
upgrade=1 from_commit=03e787291ba1104f195fdeb5103071b9546b4ad5
|
upgrade=1 from_commit=03e787291ba1104f195fdeb5103071b9546b4ad5
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=0
|
multi_instance=0
|
||||||
wrong_user=1
|
|
||||||
wrong_path=1
|
|
||||||
incorrect_path=1
|
|
||||||
corrupt_source=1
|
|
||||||
fail_download_source=1
|
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
final_path_already_use=1
|
|
||||||
change_url=1
|
change_url=1
|
||||||
;;; Levels
|
|
||||||
Level 1=auto
|
|
||||||
Level 2=auto
|
|
||||||
Level 3=auto
|
|
||||||
# Level 4: No ldap support (https://github.com/broncowdd/BoZoN/issues/197)
|
|
||||||
Level 4=na
|
|
||||||
Level 5=auto
|
|
||||||
Level 6=auto
|
|
||||||
Level 7=auto
|
|
||||||
Level 8=0
|
|
||||||
Level 9=0
|
|
||||||
Level 10=0
|
|
||||||
;;; Options
|
;;; Options
|
||||||
Email=
|
Email=
|
||||||
Notification=none
|
Notification=none
|
||||||
|
|
|
@ -22,22 +22,10 @@ myynh_create_dir () {
|
||||||
[ -d "$1" ] || mkdir -p "$1"
|
[ -d "$1" ] || mkdir -p "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if enough disk space available on backup storage
|
|
||||||
myynh_check_disk_space () {
|
|
||||||
file_to_analyse=$1
|
|
||||||
backup_size=$(du --summarize "$1" | cut -f1)
|
|
||||||
free_space=$(df --output=avail "/home/yunohost.backup" | sed 1d)
|
|
||||||
if [ $free_space -le $backup_size ]; then
|
|
||||||
WARNING echo "Not enough backup disk space for: $1"
|
|
||||||
WARNING echo "Space available: $(HUMAN_SIZE $free_space)"
|
|
||||||
ynh_die --message="Space needed: $(HUMAN_SIZE $backup_size)"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Clean & copy files needed to final folder
|
# Clean & copy files needed to final folder
|
||||||
myynh_clean_source () {
|
myynh_clean_source () {
|
||||||
find "$tmpdir" -type f -name ".htaccess" | xargs rm
|
find "$tmpdir" -type f -name ".htaccess" | xargs rm
|
||||||
[ -e "$tmpdir/.gitignore" ] && rm -r "$tmpdir/.gitignore"
|
[ -e "$tmpdir/.gitignore" ] && ynh_secure_remove "$tmpdir/.gitignore"
|
||||||
}
|
}
|
||||||
|
|
||||||
myynh_set_permissions () {
|
myynh_set_permissions () {
|
||||||
|
|
|
@ -21,7 +21,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
|
@ -32,21 +32,20 @@ data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
|
ynh_script_progression --message="Backing up the main app directory..."
|
||||||
if [ -e "$final_path" ]; then
|
if [ -e "$final_path" ]; then
|
||||||
myynh_check_disk_space "$final_path"
|
|
||||||
ynh_backup --src_path="$final_path"
|
ynh_backup --src_path="$final_path"
|
||||||
fi
|
fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
|
ynh_script_progression --message="Backing up nginx web server configuration..."
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE PHP-FPM CONFIGURATION
|
# BACKUP THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1
|
ynh_script_progression --message="Backing up php-fpm configuration..."
|
||||||
ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
##=================================================
|
##=================================================
|
||||||
|
@ -58,7 +57,6 @@ ynh_script_progression --message="Backing up data directory..."
|
||||||
if [ -e "$data_path" ]; then
|
if [ -e "$data_path" ]; then
|
||||||
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
|
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
|
||||||
if [ $backup_core_only -eq 0 ]; then
|
if [ $backup_core_only -eq 0 ]; then
|
||||||
myynh_check_disk_space "$data_path"
|
|
||||||
ynh_backup --src_path="$data_path" --is_big
|
ynh_backup --src_path="$data_path" --is_big
|
||||||
else
|
else
|
||||||
echo "Data dir will not be saved, because backup_core_only is set to true." >&2
|
echo "Data dir will not be saved, because backup_core_only is set to true." >&2
|
||||||
|
|
|
@ -13,47 +13,36 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP OF APP AND DATAS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Backing up app and datas..." --time --weight=3
|
|
||||||
if [ $(yunohost app list -i -f "$app" | wc -l) -gt 1 ]; then
|
|
||||||
ynh_app_setting_set --app="$app" --key=backup_core_only --value=0
|
|
||||||
app_bck=${app//_/-}
|
|
||||||
yunohost backup create --apps "$app" --name "${app_bck}_$(date '+%Y%m%d-%H%M%S')"
|
|
||||||
echo "BoZon fully backuped." >&2
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing app main directory..." --time --weight=1
|
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||||
ynh_secure_remove --file="$final_path"
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
|
ynh_script_progression --message="Removing nginx web server configuration..." --weight=1
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE PHP-FPM CONFIGURATION
|
# REMOVE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
|
ynh_script_progression --message="Removing php-fpm configuration..." --weight=1
|
||||||
ynh_remove_fpm_config
|
ynh_remove_fpm_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -66,10 +55,10 @@ ynh_secure_remove --file="$data_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
|
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||||
ynh_system_user_delete --username="$app"
|
ynh_system_user_delete --username="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removal of $app completed" --time --last
|
ynh_script_progression --message="Removal of $app completed" --last
|
||||||
|
|
|
@ -22,7 +22,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
||||||
|
@ -33,7 +33,7 @@ data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
|
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||||
ynh_webpath_available --domain="$domain" --path_url="$path_url" || ynh_die --message="Path not available: ${domain}${path_url}"
|
ynh_webpath_available --domain="$domain" --path_url="$path_url" || ynh_die --message="Path not available: ${domain}${path_url}"
|
||||||
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path"
|
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path"
|
||||||
|
|
||||||
|
@ -47,13 +47,13 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||||
ynh_system_user_create --username="$app"
|
ynh_system_user_create --username="$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -66,13 +66,13 @@ ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DATA DIR
|
# RESTORE THE DATA DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the data directory..." --time --weight=2
|
ynh_script_progression --message="Restoring the data directory..." --weight=2
|
||||||
if [ ! -d "$data_path" ]; then
|
if [ ! -d "$data_path" ]; then
|
||||||
if [ $backup_core_only -eq 0 ]; then
|
if [ $backup_core_only -eq 0 ]; then
|
||||||
ynh_restore_file --origin_path="$data_path"
|
ynh_restore_file --origin_path="$data_path"
|
||||||
|
@ -94,12 +94,12 @@ myynh_set_permissions
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM
|
# RELOAD NGINX AND PHP-FPM
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
|
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --weight=1
|
||||||
ynh_systemd_action --service_name=php7.0-fpm --action=reload
|
ynh_systemd_action --service_name=php7.0-fpm --action=reload
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoration completed for $app" --time --last
|
ynh_script_progression --message="Restoration completed for $app" --last
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ data_path=$(ynh_app_setting_get --app="$app" --key=data_path)
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
# If final_path doesn't exist, create it
|
# If final_path doesn't exist, create it
|
||||||
if [ -z "$final_path" ]; then
|
if [ -z "$final_path" ]; then
|
||||||
final_path="/var/www/$app"
|
final_path="/var/www/$app"
|
||||||
|
@ -87,7 +87,7 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue