diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index cccc8e2..85b538b 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -3,6 +3,9 @@ ; pool name ('www' here) [__NAMETOCHANGE__] +open_basedir = none +date.timezone = "YHTZ" + ; Per pool prefix ; It only applies on the following directives: ; - 'slowlog' diff --git a/conf/php-fpm.ini b/conf/php-fpm.ini deleted file mode 100644 index b1221c2..0000000 --- a/conf/php-fpm.ini +++ /dev/null @@ -1,2 +0,0 @@ -open_basedir = none -date.timezone = "YHTZ" \ No newline at end of file diff --git a/manifest.json b/manifest.json index b528fc6..40446ef 100644 --- a/manifest.json +++ b/manifest.json @@ -62,15 +62,17 @@ }, { "name": "language", + "type": "string", "ask": { - "en": "Pod language", - "fr": "Langue du pod" + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application" }, "choices" : ["ar", "de", "en", "es", "fr", "it", "ja", "nl", "ru"], - "default" : "en" + "default" : "fr" }, { "name": "ssoenabled", + "type": "string", "ask": { "en": "Enable SSO support (autologin)?", "fr": "Activer le support SSO (connexin auto) ?" diff --git a/scripts/install b/scripts/install index 8a69808..7b5d969 100644 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN +is_public=$YNH_APP_ARG_IS_PUBLIC password=$YNH_APP_ARG_PASSWORD language=$YNH_APP_ARG_LANGUAGE ssoenabled=$YNH_APP_ARG_SSOENABLED @@ -49,6 +50,7 @@ ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin +ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=ssoenabled --value=$ssoenabled #================================================= @@ -119,7 +121,8 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Configuring php-fpm..." --time --weight=1 # Create a dedicated php-fpm config -ynh_replace_string "YHTZ" "$timezone" ../conf/php-fpm.ini +ynh_replace_string --match_string="YHTZ" --replace_string="$timezone" --target_file=../conf/php-fpm.conf + ynh_add_fpm_config #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 939f1f0..9bf0a80 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,47 +12,63 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME # Retrieve app settings -domain=$(ynh_app_setting_get "$app" domain) -path_url=$(ynh_app_setting_get "$app" path) -port=$(ynh_app_setting_get "$app" port) -ssoenabled=$(ynh_app_setting_get "$app" ssoenabled) -public_site=$(ynh_app_setting_get "$app" public_site) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +port=$(ynh_app_setting_get --app=$app --key=port) +ssoenabled=$(ynh_app_setting_get --app=$app --key=ssoenabled) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) timezone=$(cat /etc/timezone) -final_path=$(ynh_app_setting_get "$app" final_path) -db_name=$(ynh_app_setting_get "$app" db_name) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path="/var/www/$app" - ynh_app_setting_set "$app" final_path "$final_path" +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=0 + is_public=0 fi - # If db_name doesn't exist, create it if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid "$app") - ynh_app_setting_set "$app" db_name "$db_name" + db_name=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name +fi + +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi #================================================= -# ACTIVE TRAP +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 -# TODO: activate backup # Backup the current version of the app -# ynh_backup_before_upgrade -# ynh_clean_setup () { +ynh_backup_before_upgrade +ynh_clean_setup () { # restore it if the upgrade fails - # ynh_restore_upgradebackup -# } + ynh_restore_upgradebackup +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -63,44 +79,58 @@ ynh_abort_if_errors # Normalize the URL path syntax path_url=$(ynh_normalize_url_path $path_url) - #================================================= # STANDARD UPGRADE STEPS #================================================= - -#================================================= -# UPGRADE DEPENDENCIES +# STOP SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 -ynh_install_app_dependencies php-gd php-curl php-imagick php-cli php-zmq +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_setup_source "$final_path" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --time --weight=1 -## TODO: consider installation in a subpath -ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \ + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" + + ## TODO: consider installation in a subpath + ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \ "${final_path}/app/assets/js/movim_websocket.js" +fi #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create "$app" +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 # Create a dedicated php-fpm config ynh_add_fpm_config @@ -173,13 +203,28 @@ fi #================================================= # Create a dedicated systemd config -ynh_replace_string "__URL__" "${domain}${path_url}" ../conf/systemd.service -ynh_replace_string "__PORT__" "${port}" ../conf/systemd.service + +ynh_replace_string --match_string="__URL__" --replace_string="${domain}${path_url}" --target_file=../conf/systemd.service +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file=../conf/systemd.service + ynh_add_systemd_config #================================================= -# RELOAD SERVICES +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT #================================================= -# Reload services -service nginx reload +ynh_script_progression --message="Upgrade of $app completed" --time --last \ No newline at end of file