diff --git a/manifest.json b/manifest.json index 34040ba..3974e8b 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "gofannon@riseup.net" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.1.7" }, "multi_instance": true, "services": [ @@ -25,29 +25,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for Airsonic", - "fr": "Choisissez un nom de domaine pour Airsonic" - }, "example": "example.com" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for Airsonic", - "fr": "Choisissez un chemin pour Airsonic" - }, "example": "/airsonic", "default": "/airsonic" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l’administrateur" - }, "help": { "en": "This user will have full control on this application and will be able to configure it.", "fr": "Cet utilisateur aura le controle total de l'application et pourra la configurer." @@ -57,10 +45,6 @@ { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": true } ] diff --git a/pull_request_template.md b/pull_request_template.md index 369c4b5..6c28fc5 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -11,12 +11,6 @@ - [ ] Upgrade from last version tested. - [ ] Can be reviewed and tested. -## Validation ---- -- [ ] **Code review** -- [ ] **Approval (LGTM)** -*Code review and approval have to be from a member of @YunoHost/apps group* - ## Package_check results --- * An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/backup b/scripts/backup index 02481ad..b985e2c 100644 --- a/scripts/backup +++ b/scripts/backup @@ -28,7 +28,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) -service_config=$(ynh_app_setting_get --app=$app --key=service_config) +#service_config=$(ynh_app_setting_get --app=$app --key=service_config) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -60,7 +60,7 @@ ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= ynh_backup --src_path="/etc/systemd/system/$app.service" -ynh_backup --src_path="$service_config" +ynh_backup --src_path="/etc/default/$app" #================================================= # BACKUP DATA diff --git a/scripts/change_url b/scripts/change_url index 2a4ea92..087e3d4 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,9 +28,26 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -service_config=$(ynh_app_setting_get --app=$app --key=service_config) +# service_config=$(ynh_app_setting_get --app=$app --key=service_config) port=$(ynh_app_setting_get --app=$app --key=port) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -95,14 +112,16 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=3 # Create a dedicated systemd config ynh_add_systemd_config -ynh_backup_if_checksum_is_different --file="$service_config" +# ynh_backup_if_checksum_is_different --file="$service_config" # Copy config. template to right location -cp ../conf/systemd-sysconfig $service_config +# cp ../conf/systemd-sysconfig $service_config -ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="$service_config" -ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="$service_config" -ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="$service_config" +# ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="$service_config" +# ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="$service_config" +# ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="$service_config" + +ynh_add_config --template="../conf/systemd-sysconfig" --destination="/etc/default/$app" #================================================= # GENERIC FINALISATION @@ -111,7 +130,7 @@ ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=12 -ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/airsonic.log" --line_match="Started Application in" +ynh_systemd_action --service_name=$app --action=start --log_path="$final_path/airsonic.log" --line_match="Started Application in" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 7c43309..b2ce83b 100644 --- a/scripts/install +++ b/scripts/install @@ -49,7 +49,6 @@ 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 #================================================= # STANDARD MODIFICATIONS @@ -156,27 +155,23 @@ ynh_add_systemd_config #================================================= # Path of the systemd service configuration -service_config="/etc/default/$app" +# service_config="/etc/default/$app" -ynh_app_setting_set --app=$app --key=service_config --value=$service_config +# ynh_app_setting_set --app=$app --key=service_config --value=$service_config # Copy config. template to right location -cp ../conf/systemd-sysconfig $service_config +# cp ../conf/systemd-sysconfig $service_config -ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="$service_config" -ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="$service_config" -ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="$service_config" +# ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="$service_config" +# ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="$service_config" +# ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="$service_config" + +ynh_add_config --template="../conf/systemd-sysconfig" --destination="/etc/default/$app" # Copy configuration file of airsonic cp ../conf/airsonic.properties $final_path/airsonic.properties - -#================================================= -# STORE THE CONFIG FILES CHECKSUM -#================================================= - # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$final_path/airsonic.properties" -ynh_store_file_checksum --file="$service_config" #================================================= # GENERIC FINALIZATION @@ -207,7 +202,7 @@ yunohost service add $app --description="Airsonic daemon" --log="$final_path/$ap ynh_script_progression --message="Starting a systemd service..." --weight=12 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/$app.log" --line_match="Started Application in" +ynh_systemd_action --service_name=$app --action=start --log_path="$final_path/$app.log" --line_match="Started Application in" #================================================= # SETUP APPLICATION WITH CURL @@ -219,6 +214,8 @@ ynh_permission_update --permission="main" --add="visitors" # Reload Nginx ynh_systemd_action --service_name=nginx --action=reload +ynh_script_progression --message="Finalizing installation..." --weight=10 + mailadmin=$(ynh_user_get_info --username=$admin --key=mail) #http://www.subsonic.org/pages/api.jsp diff --git a/scripts/remove b/scripts/remove index dc438a9..e09307a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -19,7 +19,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -service_config=$(ynh_app_setting_get --app=$app --key=service_config) +#service_config=$(ynh_app_setting_get --app=$app --key=service_config) #================================================= # STANDARD REMOVE @@ -80,7 +80,7 @@ ynh_remove_logrotate # REMOVE FILES #================================================= -ynh_secure_remove --file="$service_config" +ynh_secure_remove --file="/etc/default/$app" #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index be2f4c6..87b37ae 100644 --- a/scripts/restore +++ b/scripts/restore @@ -30,7 +30,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -service_config=$(ynh_app_setting_get --app=$app --key=service_config) +#service_config=$(ynh_app_setting_get --app=$app --key=service_config) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -108,7 +108,7 @@ chown $app: $final_path/transcode ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -ynh_restore_file --origin_path="$service_config" +ynh_restore_file --origin_path="/etc/default/$app" systemctl enable $app.service --quiet #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6b1fd23..bd9a225 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,9 +20,8 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) is_public=$(ynh_app_setting_get --app=$app --key=is_public) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) -service_config=$(ynh_app_setting_get --app=$app --key=service_config) +#service_config=$(ynh_app_setting_get --app=$app --key=service_config) #================================================= # CHECK VERSION @@ -35,25 +34,23 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# 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 final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/opt/yunohost/$app ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi -# If service_config doesn't exist, create it -if [ -z "$service_config" ]; then - service_config="/etc/default/$app" - ynh_app_setting_set --app=$app --key=service_config --value=$service_config +# # If service_config doesn't exist, create it +# if [ -z "$service_config" ]; then +# service_config="/etc/default/$app" +# ynh_app_setting_set --app=$app --key=service_config --value=$service_config +# 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 #================================================= @@ -200,14 +197,16 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config -ynh_backup_if_checksum_is_different --file="$service_config" +# ynh_backup_if_checksum_is_different --file="$service_config" -# Copy config. template to right location -cp ../conf/systemd-sysconfig $service_config +# # Copy config. template to right location +# cp ../conf/systemd-sysconfig $service_config -ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="$service_config" -ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="$service_config" -ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="$service_config" +# ynh_replace_string --match_string="__FINALPATH__" --replace_string=$final_path --target_file="$service_config" +# ynh_replace_string --match_string="__PORT__" --replace_string=$port --target_file="$service_config" +# ynh_replace_string --match_string="__PATH__" --replace_string=$path_url --target_file="$service_config" + +ynh_add_config --template="../conf/systemd-sysconfig" --destination="/etc/default/$app" #================================================= # GENERIC FINALIZATION