diff --git a/check_process b/check_process index 2033705..7d3022c 100644 --- a/check_process +++ b/check_process @@ -1,7 +1,7 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) + domain="domain.tld" + path="/path" name="YunoJappix" language="en" ; Checks diff --git a/conf/app.src b/conf/app.src index f465b4a..9977248 100644 --- a/conf/app.src +++ b/conf/app.src @@ -4,4 +4,3 @@ SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=true SOURCE_FILENAME= - diff --git a/manifest.json b/manifest.json index d01b7c1..0282c73 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "titoko@titoko.fr" }, "requirements": { - "yunohost": ">> 4.1.7" + "yunohost": ">> 4.2.4" }, "multi_instance": false, "services": [ diff --git a/scripts/install b/scripts/install index b5b43eb..9a325a9 100644 --- a/scripts/install +++ b/scripts/install @@ -47,6 +47,14 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=name --value=$name ynh_app_setting_set --app=$app --key=language --value=$language +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -56,14 +64,9 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" -mkdir -p "$final_path/store/conf" -cp ../conf/*.xml "$final_path/store/conf/" - -#================================================= -# Set permissions to jappix directory -#================================================= - -chown -R www-data: $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -77,8 +80,11 @@ ynh_add_nginx_config # Set Jappix configuration #================================================= +mkdir -p "$final_path/store/conf" + ynh_add_config --template="../conf/hosts.xml" --destination="$final_path/store/conf/hosts.xml" ynh_add_config --template="../conf/main.xml" --destination="$final_path/store/conf/main.xml" +ynh_add_config --template="../conf/installed.xml" --destination="$final_path/store/conf/installed.xml" #================================================= # RELOAD NGINX diff --git a/scripts/remove b/scripts/remove index d75fc80..0865efe 100644 --- a/scripts/remove +++ b/scripts/remove @@ -35,6 +35,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated nginx config ynh_remove_nginx_config +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 + +# Delete a system user +ynh_system_user_delete --username=$app + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 359d7a9..b76fde8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -44,6 +44,14 @@ test ! -d $final_path \ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -51,6 +59,10 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path=$final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b6aa826..fc7d9f5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,12 @@ name=$(ynh_app_setting_get "$app" name) language=$(ynh_app_setting_get "$app" language) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -41,6 +47,26 @@ if [ -z "$name" ]; then ynh_app_setting_set --app=$app --key=name --value=$name fi +# If db_name doesn't exist, create it +if [ -z "$final_path/store/conf" ]; then + mkdir -p "$final_path/store/conf" +fi + +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -55,28 +81,22 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# Copy files to the right place -#================================================= - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=6 -ynh_setup_source --dest_dir=$final_path +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --weight=1 -mkdir -p "${final_path}/store/conf" -cp ../conf/*.xml "${final_path}/store/conf/" + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" +fi -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to jappix directory -chown -R www-data: $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -92,6 +112,7 @@ ynh_add_nginx_config ynh_add_config --template="../conf/hosts.xml" --destination="$final_path/store/conf/hosts.xml" ynh_add_config --template="../conf/main.xml" --destination="$final_path/store/conf/main.xml" +ynh_add_config --template="../conf/installed.xml" --destination="$final_path/store/conf/installed.xml" #================================================= # RELOAD NGINX