diff --git a/scripts/_common.sh b/scripts/_common.sh index 061e39c..b5ec7ad 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,8 +1,17 @@ #!/bin/bash +#================================================= +# SET ALL CONSTANTS +#================================================= + app=$YNH_APP_INSTANCE_NAME +final_path="/var/www/$app" gollem_data_dir="/home/yunohost.app/$app" +#================================================= +# DEFINE ALL COMMON FONCTIONS +#================================================= + install_dependance() { ynh_install_app_dependencies php-pear expect php5-imagick php5-tidy } diff --git a/scripts/backup b/scripts/backup index 8068fe0..1c29b38 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,5 +1,9 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= + # Source YunoHost helpers source /usr/share/yunohost/helpers @@ -10,13 +14,14 @@ ynh_abort_if_errors source ../settings/scripts/experimental_helper.sh source ../settings/scripts/_common.sh -# LOAD SETTINGS -app=$YNH_APP_INSTANCE_NAME - final_path=$(ynh_app_setting_get $app final_path) domain=$(ynh_app_setting_get $app domain) db_name=$(ynh_app_setting_get $app db_name) +#================================================= +# STANDARD BACKUP STEPS +#================================================= + # BACKUP THE APP MAIN DIR ynh_backup "$final_path" diff --git a/scripts/change_url b/scripts/change_url index 9449e69..5cd8cd0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,5 +1,9 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= + # IMPORT GENERIC HELPERS source /usr/share/yunohost/helpers @@ -50,23 +54,13 @@ then change_path=1 fi +#================================================= +# STANDARD MODIFICATIONS +#================================================= + # MODIFY URL IN NGINX CONF nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file -# if [ $change_path -eq 1 ] -# then -# # Make a backup of the original nginx config file if modified -# ynh_backup_if_checksum_is_different "$nginx_conf_path" -# # Replace locations starting with old_path -# # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) -# ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path" -# # Replace path in "return" directives -# ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" -# # Calculate and store the nginx config file checksum -# ynh_store_file_checksum "$nginx_conf_path" -# fi - # Change the domain for nginx if [ $change_domain -eq 1 ] then diff --git a/scripts/install b/scripts/install index 8fa0324..f5af2e6 100755 --- a/scripts/install +++ b/scripts/install @@ -1,5 +1,9 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= + # IMPORT GENERIC HELPERS source /usr/share/yunohost/helpers @@ -64,6 +68,10 @@ then optionnal_apps_list="$optionnal_apps_list horde/wicked" fi +#================================================= +# STANDARD MODIFICATIONS +#================================================= + # Enable all necessary locales if [[ "$language" != "en" ]] then @@ -127,6 +135,10 @@ config_nginx # Create a dedicated php-fpm config ynh_add_fpm_config +#================================================= +# GENERIC FINALIZATION +#================================================= + # SECURE FILES AND DIRECTORIES set_permission diff --git a/scripts/remove b/scripts/remove index 3f77ef8..031caad 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,5 +1,9 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= + # Source YunoHost helpers source /usr/share/yunohost/helpers @@ -16,6 +20,10 @@ db_name=$(ynh_app_setting_get $app db_name) db_user=$(ynh_app_setting_get $app db_user) final_path=$(ynh_app_setting_get $app final_path) +#================================================= +# STANDARD REMOVE +#================================================= + # Remove metapackage and its dependencies ynh_remove_app_dependencies diff --git a/scripts/restore b/scripts/restore index 78ed786..b283543 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,5 +1,9 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= + # Source YunoHost helpers source /usr/share/yunohost/helpers @@ -10,9 +14,6 @@ ynh_abort_if_errors source ../settings/scripts/experimental_helper.sh source ../settings/scripts/_common.sh -# 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) @@ -24,6 +25,10 @@ ynh_webpath_available $domain $path_url \ test ! -d $final_path \ || ynh_die "There is already a directory: $final_path " +#================================================= +# STANDARD RESTORATION STEPS +#================================================= + # Define and install dependencies install_dependance @@ -38,6 +43,10 @@ db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_mysql_setup_db $db_name $db_name $db_pwd ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql +#================================================= +# GENERIC FINALIZATION +#================================================= + # SECURE FILES AND DIRECTORIES set_permission diff --git a/scripts/upgrade b/scripts/upgrade index bae1873..fbb4477 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,5 +1,9 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= + # IMPORT GENERIC HELPERS source /usr/share/yunohost/helpers @@ -10,7 +14,6 @@ ynh_abort_if_errors source ./experimental_helper.sh source ./_common.sh - # LOAD SETTINGS domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_normalize_url_path $(ynh_app_setting_get $app path)) @@ -33,6 +36,10 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# STANDARD UPGRADE STEPS +#================================================= + # INSTALL DEPENDENCIES install_dependance @@ -50,5 +57,9 @@ config_horde # NGINX CONFIGURATION config_nginx +#================================================= +# GENERIC FINALIZATION +#================================================= + # SECURE FILES AND DIRECTORIES set_permission \ No newline at end of file