From cd4b6fa7bc8c10aabaf6e38c64a1dff319115625 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 24 May 2019 04:43:59 +0200 Subject: [PATCH 1/9] Add notification mail --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index f753394d..ea6439c7 100644 --- a/check_process +++ b/check_process @@ -27,5 +27,5 @@ Level 9=0 Level 10=0 ;;; Options -Email=jean-baptiste@holcroft.fr +Email=jean-baptiste@holcroft.fr;yalh@yahoo.com Notification=all From a30f5b3d50394f2d4e90dac5ca627a8a1663704e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 24 May 2019 16:55:36 +0200 Subject: [PATCH 2/9] Adding root domain information --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index a8940e9e..fb0b7dcc 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ The federated image sharing service Pixelfed, for YunoHost **Shipped version:** 0.9.0 +## Important points to read before installing + +1. **Pixelfed** require a dedicated **root domain**, eg. pixelfed.domain.tld + ## Screenshots ![](https://camo.githubusercontent.com/c1c2e74057dcff57e103fcbb3239840802fcf752/68747470733a2f2f706978656c6665642e6e7963332e63646e2e6469676974616c6f6365616e7370616365732e636f6d2f6d656469612f53637265656e25323053686f74253230323031392d30322d30352532306174253230362e33342e3539253230504d2e706e67) From 935c33fefa2ab13465ba5a299fff70790af864e2 Mon Sep 17 00:00:00 2001 From: lapineige Date: Thu, 30 May 2019 09:38:20 +0200 Subject: [PATCH 3/9] Add config instructions about php commands and php version See https://github.com/YunoHost-Apps/pixelfed_ynh/issues/48#issuecomment-497235849 --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index a8940e9e..6e2a4e4a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ The federated image sharing service Pixelfed, for YunoHost ![](https://camo.githubusercontent.com/c1c2e74057dcff57e103fcbb3239840802fcf752/68747470733a2f2f706978656c6665642e6e7963332e63646e2e6469676974616c6f6365616e7370616365732e636f6d2f6d656469612f53637265656e25323053686f74253230323031392d30322d30352532306174253230362e33342e3539253230504d2e706e67) ## Configuration +[Official documentation](https://docs.pixelfed.org/master/configuration.html) ### Administrator @@ -27,6 +28,11 @@ After being first registered, you need to execute the folloing command to promot and respond yes to the question ` Add admin privileges to this user?` +### Pixelfed php commands and php version + +Pixelfed might require some command line instructions if you make manual changes to your configuration. +By default php 7.0 is currently used when you type `php`. You need to use `php7.2 [command]` instead. + ### Allow/Close registration Registrations are open by default. From ca85a560ce962505ad417bde5bd73cdc5a1d8187 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 30 May 2019 17:52:53 +0200 Subject: [PATCH 4/9] add horizon-service --- conf/horizon.service | 14 ++++++++++++++ manifest.json | 2 +- scripts/backup | 23 +++++++++++++++++++++++ scripts/install | 22 ++++++++++++++++++++++ scripts/remove | 19 +++++++++++++++++++ scripts/restore | 21 +++++++++++++++++++++ scripts/upgrade | 29 +++++++++++++++++++++++++++++ 7 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 conf/horizon.service diff --git a/conf/horizon.service b/conf/horizon.service new file mode 100644 index 00000000..bd630724 --- /dev/null +++ b/conf/horizon.service @@ -0,0 +1,14 @@ +[Unit] +Description=__APP__ Horizon Service +After=network.target + +[Service] +Type=simple +User=__APP__ +Group=__APP__ +WorkingDirectory=__FINALPATH__/ +ExecStart=/usr/bin/php7.2 __FINALPATH__/artisan horizon >> /var/log/__APP__/__APP__-horizon.log 2>&1 +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index 866af077..96c2c074 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "ActivityPub Federated Image Sharing" }, - "version": "0.9.0~ynh2", + "version": "0.9.0~ynh3", "url": "https://pixelfed.org/", "license": "AGPL-3.0-or-later", "maintainer": [ diff --git a/scripts/backup b/scripts/backup index 3d76e413..86588a8e 100644 --- a/scripts/backup +++ b/scripts/backup @@ -30,6 +30,13 @@ db_name=$(ynh_app_setting_get --app="$app" --key=db_name) #================================================= # STANDARD BACKUP STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name="${app}-horizon" --action="stop" --log_path="/var/log/$app/${app}-horizon.log" + #================================================= # BACKUP THE APP MAIN DIR #================================================= @@ -58,6 +65,22 @@ ynh_print_info --message="Backing up the PostgreSQL database..." ynh_psql_dump_db --database="$db_name" > db.sql +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP SYSTEMD +#================================================= +ynh_print_info --message="Backing up systemd configuration..." + +ynh_backup --src_path="/etc/systemd/system/${app}-horizon.service" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path="/var/log/$app/${app}-horizon.log" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 1bd26616..0bf73e95 100644 --- a/scripts/install +++ b/scripts/install @@ -122,6 +122,14 @@ ynh_install_composer --phpversion="7.2" --workdir="$final_path" #================================================= # SPECIFIC SETUP +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_print_info --message="Configuring a systemd service..." + +# Create a dedicated systemd config +ynh_add_systemd_config --service="${app}-horizon" --template=horizon + #================================================= # MODIFY A CONFIG FILE #================================================= @@ -169,6 +177,20 @@ popd chown -R root: "$final_path" chown -R "$app": "$final_path/storage/" +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add "${app}-horizon" --description "${app}-horizon daemon for $app" --log "/var/log/$app/${app}-horizon.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +# Start a systemd service +ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path="/var/log/$app/${app}-horizon.log" + #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/remove b/scripts/remove index 59a20ab1..c2d055b8 100644 --- a/scripts/remove +++ b/scripts/remove @@ -23,6 +23,25 @@ final_path=$(ynh_app_setting_get --app="$app" --key=final_path) #================================================= # STANDARD REMOVE +#================================================= +# REMOVE SERVICE FROM ADMIN PANEL +#================================================= + +# Remove a service from the admin panel, added by `yunohost service add` +if ynh_exec_warn_less yunohost service status ${app}-horizon >/dev/null +then + ynh_print_info --message="Removing ${app}-horizon service..." + yunohost service remove "${app}-horizon" +fi + +#================================================= +# STOP AND REMOVE SERVICE +#================================================= +ynh_print_info --message="Stopping and removing the systemd service..." + +# Remove the dedicated systemd config +ynh_remove_systemd_config --service="${app}-horizon" + #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/restore b/scripts/restore index d6d993c2..c0d739aa 100644 --- a/scripts/restore +++ b/scripts/restore @@ -103,6 +103,27 @@ ynh_psql_test_if_first_run ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" +#================================================= +# RESTORE SYSTEMD +#================================================= +ynh_print_info --message="Restoring the systemd configuration..." + +ynh_restore_file --origin_path="/etc/systemd/system/${app}-horizon.service" +systemctl enable ${app}-horizon.service + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add "${app}-horizon" --log "/var/log/$app/${app}-horizon.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path="/var/log/$app/${app}-horizon.log" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c8c33017..34899eca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,6 +81,13 @@ ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Stopping a systemd service..." + +ynh_systemd_action --service_name="${app}-horizon" --action="stop" --log_path="/var/log/$app/${app}-horizon.log" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -180,6 +187,20 @@ ynh_backup_if_checksum_is_different --file="$config" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$config" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_print_info --message="Upgrading systemd configuration..." + +# Create a dedicated systemd config +ynh_add_systemd_config --service="${app}-horizon" --template=horizon + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add "${app}-horizon" --description "${app}-horizon daemon for $app" --log "/var/log/$app/${app}-horizon.log" + #================================================= # GENERIC FINALIZATION #================================================= @@ -201,6 +222,14 @@ then ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/" fi +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +# Start a systemd service +ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path="/var/log/$app/${app}-horizon.log" + #================================================= # RELOAD NGINX #================================================= From ce6d5f0f7b9a9b132697d372bd74341ddfcfaa20 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 30 May 2019 18:06:38 +0200 Subject: [PATCH 5/9] fix ynh_script_progression --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 86588a8e..e01ad177 100644 --- a/scripts/backup +++ b/scripts/backup @@ -33,7 +33,7 @@ db_name=$(ynh_app_setting_get --app="$app" --key=db_name) #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_print_info --message="Stopping a systemd service..." ynh_systemd_action --service_name="${app}-horizon" --action="stop" --log_path="/var/log/$app/${app}-horizon.log" From f275c56c44e4264b06c6e20be8596cd305aa54b9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 30 May 2019 18:07:50 +0200 Subject: [PATCH 6/9] Update upgrade --- scripts/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 34899eca..ab3a29b7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -227,7 +227,6 @@ fi #================================================= ynh_print_info --message="Starting a systemd service..." -# Start a systemd service ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path="/var/log/$app/${app}-horizon.log" #================================================= From 632d20f3ddb726fcf1eeef04b6ebc8f5f8d628f5 Mon Sep 17 00:00:00 2001 From: lapineige Date: Thu, 30 May 2019 18:19:01 +0200 Subject: [PATCH 7/9] Reorganise the instructions + add more details --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6e2a4e4a..e3bec282 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ The federated image sharing service Pixelfed, for YunoHost ![](https://camo.githubusercontent.com/c1c2e74057dcff57e103fcbb3239840802fcf752/68747470733a2f2f706978656c6665642e6e7963332e63646e2e6469676974616c6f6365616e7370616365732e636f6d2f6d656469612f53637265656e25323053686f74253230323031392d30322d30352532306174253230362e33342e3539253230504d2e706e67) ## Configuration -[Official documentation](https://docs.pixelfed.org/master/configuration.html) ### Administrator @@ -28,15 +27,17 @@ After being first registered, you need to execute the folloing command to promot and respond yes to the question ` Add admin privileges to this user?` -### Pixelfed php commands and php version - -Pixelfed might require some command line instructions if you make manual changes to your configuration. -By default php 7.0 is currently used when you type `php`. You need to use `php7.2 [command]` instead. - ### Allow/Close registration Registrations are open by default. To change that setting, edit `/var/www/pixelfed/.env` and set `OPEN_REGISTRATION=false` instead of `true`. +Then run `php7.2 artisan config:cache` to reload the settings. + +### Pixelfed php commands and php version + +Pixelfed might require some command line instructions if you want to make manual changes to your configuration. +By default php 7.0 is currently used when you type `php`. You need to use `php7.2 [command]` instead. +Those commands can be found in the official documentation. ## Documentation From 9678133a6eaa14ceb4191647f50fab11009b149b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 31 May 2019 17:03:53 +0200 Subject: [PATCH 8/9] fix services --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 0bf73e95..0e6d31d5 100644 --- a/scripts/install +++ b/scripts/install @@ -128,7 +128,7 @@ ynh_install_composer --phpversion="7.2" --workdir="$final_path" ynh_print_info --message="Configuring a systemd service..." # Create a dedicated systemd config -ynh_add_systemd_config --service="${app}-horizon" --template=horizon +ynh_add_systemd_config --service="${app}-horizon" --template=horizon.service #================================================= # MODIFY A CONFIG FILE diff --git a/scripts/upgrade b/scripts/upgrade index ab3a29b7..9ca2a713 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -193,7 +193,7 @@ ynh_store_file_checksum --file="$config" ynh_print_info --message="Upgrading systemd configuration..." # Create a dedicated systemd config -ynh_add_systemd_config --service="${app}-horizon" --template=horizon +ynh_add_systemd_config --service="${app}-horizon" --template=horizon.service #================================================= # ADVERTISE SERVICE IN ADMIN PANEL From 18cb5fe0ea4f971f21e4cdedd1db0b0ed573aae2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 31 May 2019 18:37:48 +0200 Subject: [PATCH 9/9] fix service --- conf/horizon.service | 2 +- scripts/backup | 4 ++-- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 9 +++++++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/conf/horizon.service b/conf/horizon.service index bd630724..61da93a4 100644 --- a/conf/horizon.service +++ b/conf/horizon.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ -ExecStart=/usr/bin/php7.2 __FINALPATH__/artisan horizon >> /var/log/__APP__/__APP__-horizon.log 2>&1 +ExecStart=/usr/bin/php7.2 __FINALPATH__/artisan horizon Restart=on-failure [Install] diff --git a/scripts/backup b/scripts/backup index e01ad177..e2e62033 100644 --- a/scripts/backup +++ b/scripts/backup @@ -35,7 +35,7 @@ db_name=$(ynh_app_setting_get --app="$app" --key=db_name) #================================================= ynh_print_info --message="Stopping a systemd service..." -ynh_systemd_action --service_name="${app}-horizon" --action="stop" --log_path="/var/log/$app/${app}-horizon.log" +ynh_systemd_action --service_name="${app}-horizon" --action="stop" --log_path=systemd #================================================= # BACKUP THE APP MAIN DIR @@ -79,7 +79,7 @@ ynh_backup --src_path="/etc/systemd/system/${app}-horizon.service" #================================================= ynh_print_info --message="Starting a systemd service..." -ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path="/var/log/$app/${app}-horizon.log" +ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path=systemd #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 0e6d31d5..8a234fa2 100644 --- a/scripts/install +++ b/scripts/install @@ -189,7 +189,7 @@ yunohost service add "${app}-horizon" --description "${app}-horizon daemon for $ ynh_print_info --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path="/var/log/$app/${app}-horizon.log" +ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path=systemd #================================================= # SETUP SSOWAT diff --git a/scripts/restore b/scripts/restore index c0d739aa..87f941ae 100644 --- a/scripts/restore +++ b/scripts/restore @@ -122,7 +122,7 @@ yunohost service add "${app}-horizon" --log "/var/log/$app/${app}-horizon.log" #================================================= ynh_print_info --message="Starting a systemd service..." -ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path="/var/log/$app/${app}-horizon.log" +ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path=systemd #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 9ca2a713..2cd21207 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -65,6 +65,10 @@ if [ -z "$app_key" ]; then ynh_app_setting_set --app="$app" --key=app_key --value="$app_key" fi +if dpkg --compare-versions "0.9.0~ynh3" gt "$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0)" ; then + ynh_add_systemd_config --service="${app}-horizon" --template=horizon.service +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -73,6 +77,7 @@ ynh_print_info --message="Backing up the app before upgrading (may take a while) # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + read -p "key" # restore it if the upgrade fails ynh_restore_upgradebackup } @@ -86,7 +91,7 @@ ynh_abort_if_errors #================================================= ynh_print_info --message="Stopping a systemd service..." -ynh_systemd_action --service_name="${app}-horizon" --action="stop" --log_path="/var/log/$app/${app}-horizon.log" +ynh_systemd_action --service_name="${app}-horizon" --action="stop" --log_path=systemd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -227,7 +232,7 @@ fi #================================================= ynh_print_info --message="Starting a systemd service..." -ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path="/var/log/$app/${app}-horizon.log" +ynh_systemd_action --service_name="${app}-horizon" --action="start" --log_path=systemd #================================================= # RELOAD NGINX