From 192914ebc27f09adb51fb184fb36346fd8d01a51 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Sun, 5 Feb 2023 19:49:10 +0100 Subject: [PATCH 01/12] Fix URL in updater --- .github/workflows/updater.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index 6516311..e63b297 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -45,5 +45,5 @@ jobs: title: 'Upgrade to version ${{ env.VERSION }}' body: | Upgrade to v${{ env.VERSION }} - Changelog: https://github.com/invoiceninja/invoiceninja/releases/tag/v${{ env.VERSION }} + Changelog: https://github.com/zyachel/libremdb/releases/tag/v${{ env.VERSION }} draft: false From 6c72975ec673d8c59ee74570ff852dbae5e38177 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 15 Apr 2023 16:50:03 +0000 Subject: [PATCH 02/12] Upgrade to v3.0.0 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index becc165..7a3a741 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Free & open source IMDb front-end", "fr": "Frontal IMDb gratuit et open source" }, - "version": "2.2.2~ynh1", + "version": "3.0.0~ynh1", "url": "https://libremdb.iket.me/", "upstream": { "license": "AGPL-3.0", From 07be3a6665d21437fb734c38072bf8ab382408b6 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 15 Apr 2023 16:50:09 +0000 Subject: [PATCH 03/12] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e1aee4f..4f8cc5c 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ A free & open source IMDb front-end. -**Shipped version:** 2.2.2~ynh1 +**Shipped version:** 3.0.0~ynh1 **Demo:** https://libremdb.iket.me/about diff --git a/README_fr.md b/README_fr.md index e9d5bcf..0a57a6a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -27,7 +27,7 @@ A free & open source IMDb front-end. -**Version incluse :** 2.2.2~ynh1 +**Version incluse :** 3.0.0~ynh1 **Démo :** https://libremdb.iket.me/about From 047e2ee98ed7152ef7e50c94a2773c9d116f23e6 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Wed, 19 Apr 2023 11:02:00 +0200 Subject: [PATCH 04/12] simplify automatic updater --- .github/workflows/updater.sh | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index 37ea19c..e5700a5 100644 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -21,7 +21,7 @@ current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') # Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) +assets="https://github.com/$repo/archive/refs/tags/$version.tar.gz" # Later down the script, we assume the version has only digits and dots # Sometimes the release name starts with a "v", so let's filter it out. @@ -44,7 +44,7 @@ if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then # Proceed only if a PR for this new version does not already exist elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then echo "::warning ::A branch already exists for this update" - exit 0 + #exit 0 fi # Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) @@ -54,23 +54,8 @@ echo "${#assets[@]} available asset(s)" # UPDATE SOURCE FILES #================================================= -# Here we use the $assets variable to get the resources published in the upstream release. -# Let's loop over the array of assets URLs -for asset_url in ${assets[@]}; do - -echo "Handling asset at $asset_url" - -# Assign the asset to a source file in conf/ directory -# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) -# Leave $src empty to ignore the asset -case $asset_url in - *"libremdb") - src="app" - ;; - *) - src="" - ;; -esac +asset_url=$assets +src="app" # If $src is not empty, let's process the asset if [ ! -z "$src" ]; then @@ -99,8 +84,9 @@ SOURCE_URL=$asset_url SOURCE_SUM=$checksum SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=$extension -SOURCE_IN_SUBDIR=false +SOURCE_IN_SUBDIR=true SOURCE_FILENAME= +SOURCE_EXTRACT=true EOT echo "... conf/$src.src updated" @@ -108,8 +94,6 @@ else echo "... asset ignored" fi -done - #================================================= # SPECIFIC UPDATE STEPS #================================================= From 09aa1e3c286c16a1ee1a43e789d0cda803c676ae Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Wed, 19 Apr 2023 11:04:22 +0200 Subject: [PATCH 05/12] update to 3.0.0 in app.src --- conf/app.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index 945e407..2ef8f0d 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/zyachel/libremdb/archive/refs/tags/v2.2.2.tar.gz -SOURCE_SUM=0f58b9d9f1a0a9787352c3c358806d3729db611888ae23e166e870cb049ca151 +SOURCE_URL=https://github.com/zyachel/libremdb/archive/refs/tags/v3.0.0.tar.gz +SOURCE_SUM=8519c55ed0f74189270c3d09e85f2509301bb66e3749503e4b015c90142a1a8a SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true From 2246dbfef6dd9a44a48b9192268ff0604df52541 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Wed, 19 Apr 2023 11:04:49 +0200 Subject: [PATCH 06/12] add new env-vars from upstream --- conf/.env.local.example | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/conf/.env.local.example b/conf/.env.local.example index b36a887..8abc878 100644 --- a/conf/.env.local.example +++ b/conf/.env.local.example @@ -26,3 +26,12 @@ NEXT_TELEMETRY_DISABLED=1 # USE_REDIS=true ## for docker, just set the domain to the container name, default is 'libremdb_redis' REDIS_URL=localhost:6379 + + +################################################################################ +### 4. INSTANCE META FIELDS(not required but good to have) +################################################################################ +## example: 'https://iket.me'. +NEXT_PUBLIC_INSTANCE_MAIN_URL=https://__DOMAIN__ +## eg: 'zyachel' +NEXT_PUBLIC_INSTANCE_NAME=__DOMAIN__ From 4c70f0b767ba7d285006126dbb26c67e4e25a8e7 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Wed, 19 Apr 2023 11:05:55 +0200 Subject: [PATCH 07/12] add port-var to and env-file to upgrade script --- scripts/backup | 3 ++- scripts/install | 3 ++- scripts/restore | 1 + scripts/upgrade | 11 +++++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/backup b/scripts/backup index fb3c925..757a874 100755 --- a/scripts/backup +++ b/scripts/backup @@ -28,8 +28,9 @@ ynh_print_info --message="Loading installation settings..." 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) +port=$(ynh_app_setting_get --app=$app --key=port) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP diff --git a/scripts/install b/scripts/install index 6d4556f..5b5fc9a 100755 --- a/scripts/install +++ b/scripts/install @@ -24,11 +24,12 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +app=$YNH_APP_INSTANCE_NAME + domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC -app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS diff --git a/scripts/restore b/scripts/restore index 62b370a..b2de830 100755 --- a/scripts/restore +++ b/scripts/restore @@ -29,6 +29,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) diff --git a/scripts/upgrade b/scripts/upgrade index 13890c4..e4a5aac 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,6 +17,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -84,6 +85,16 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +ynh_add_config --template="../conf/.env.local.example" --destination="$final_path/.env.local" + +chmod 400 "$final_path/.env.local" +chown $app:$app "$final_path/.env.local" + #================================================= # NGINX CONFIGURATION #================================================= From 68c7f4d6743decbcc558b3bb9355db2719571935 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Wed, 19 Apr 2023 11:20:57 +0200 Subject: [PATCH 08/12] add redis config --- conf/.env.local.example | 3 +-- scripts/install | 8 ++++++++ scripts/remove | 9 +++++++++ scripts/upgrade | 13 +++++++++++++ scripts/ynh_redis | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 scripts/ynh_redis diff --git a/conf/.env.local.example b/conf/.env.local.example index 8abc878..6823063 100644 --- a/conf/.env.local.example +++ b/conf/.env.local.example @@ -23,11 +23,10 @@ NEXT_TELEMETRY_DISABLED=1 ### 3. REDIS CONFIG(optional if you don't need redis) ################################################################################ ## if you want to use redis to speed up the media proxy, set this to true -# USE_REDIS=true +USE_REDIS=true ## for docker, just set the domain to the container name, default is 'libremdb_redis' REDIS_URL=localhost:6379 - ################################################################################ ### 4. INSTANCE META FIELDS(not required but good to have) ################################################################################ diff --git a/scripts/install b/scripts/install index 5b5fc9a..fa3ca82 100755 --- a/scripts/install +++ b/scripts/install @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_redis source /usr/share/yunohost/helpers #================================================= @@ -101,6 +102,13 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# CONFIGURE REDIS +#================================================= + +redis_db=$(ynh_redis_get_free_db) +ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" + #================================================= # INSTALL LIBREMDB #================================================= diff --git a/scripts/remove b/scripts/remove index b06c61a..ca0f08d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_redis source /usr/share/yunohost/helpers #================================================= @@ -19,6 +20,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) +redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #================================================= # STANDARD REMOVE @@ -57,6 +59,13 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# REMOVE THE REDIS DATABASE +#================================================= +ynh_script_progression --message="Removing the redis database..." + +ynh_redis_remove_db "$redis_db" + #================================================= # REMOVE DEPENDENCIES #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index e4a5aac..7ca3c65 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_redis source /usr/share/yunohost/helpers #================================================= @@ -20,6 +21,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #================================================= # CHECK VERSION @@ -50,6 +52,17 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." + +# If redis_db doesn't exist, create it +if [ -z "$redis_db" ]; then + redis_db=$(ynh_redis_get_free_db) + ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" +fi + #================================================= # CREATE DEDICATED USER #================================================= diff --git a/scripts/ynh_redis b/scripts/ynh_redis new file mode 100644 index 0000000..9d6257d --- /dev/null +++ b/scripts/ynh_redis @@ -0,0 +1,39 @@ +#!/bin/bash + +# get the first available redis database +# +# usage: ynh_redis_get_free_db +# | returns: the database number to use +ynh_redis_get_free_db() { + local result max db + result=$(redis-cli INFO keyspace) + + # get the num + max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+") + + db=0 + # default Debian setting is 15 databases + for i in $(seq 0 "$max") + do + if ! echo "$result" | grep -q "db$i" + then + db=$i + break 1 + fi + db=-1 + done + + test "$db" -eq -1 && ynh_die --message="No available Redis databases..." + + echo "$db" +} + +# Create a master password and set up global settings +# Please always call this script in install and restore scripts +# +# usage: ynh_redis_remove_db database +# | arg: database - the database to erase +ynh_redis_remove_db() { + local db=$1 + redis-cli -n "$db" flushall +} From aadae35ac62c06bd829228082acd834716730683 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Wed, 19 Apr 2023 11:40:01 +0200 Subject: [PATCH 09/12] do not test for sub-url installation, as it's not supported yet --- check_process | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index 951eb70..9a30227 100644 --- a/check_process +++ b/check_process @@ -6,7 +6,7 @@ port="666" ; Checks pkg_linter=1 - setup_sub_dir=1 + setup_sub_dir=0 setup_root=1 setup_nourl=0 setup_private=1 @@ -15,7 +15,7 @@ #upgrade=1 from_commit=CommitHash backup_restore=1 multi_instance=1 - port_already_use=0 + port_already_use=1 (8095) change_url=1 ;;; Options Email= From 0594d3d69998efc855bef2f244e08d83cab6b0c2 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Wed, 19 Apr 2023 11:40:14 +0200 Subject: [PATCH 10/12] add env-file to change_url script --- scripts/change_url | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index b286df6..7d5a665 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -100,6 +100,16 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi +#================================================= +# CHANGE APP CONFIGURATION +#================================================= +ynh_script_progression --message="Changing app configuration file..." --weight=1 + +ynh_add_config --template="../conf/.env.local.example" --destination="$final_path/.env.local" + +chmod 400 "$final_path/.env.local" +chown $app:$app "$final_path/.env.local" + #================================================= # GENERIC FINALISATION #================================================= From b330b585a53ca0c4cab3aa591d988343e6596400 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Wed, 19 Apr 2023 11:41:02 +0200 Subject: [PATCH 11/12] add redis-server to manifest to use it --- manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 7a3a741..126cb9b 100644 --- a/manifest.json +++ b/manifest.json @@ -24,7 +24,8 @@ }, "multi_instance": true, "services": [ - "nginx" + "nginx", + "redis-server" ], "arguments": { "install": [ From 876cffc4403e7f6315cd6daefc1740631c5ff46c Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Wed, 19 Apr 2023 12:30:10 +0200 Subject: [PATCH 12/12] add domain-var to change_url --- scripts/change_url | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 7d5a665..b6607be 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -105,6 +105,8 @@ fi #================================================= ynh_script_progression --message="Changing app configuration file..." --weight=1 +domain="$old_domain" + ynh_add_config --template="../conf/.env.local.example" --destination="$final_path/.env.local" chmod 400 "$final_path/.env.local"