From 20f0fc66b78eee05503a5e77653e0c15b3ec9918 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 7 Sep 2023 20:03:49 +0200 Subject: [PATCH 1/9] Update install --- scripts/install | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index b82298b..2ad638f 100755 --- a/scripts/install +++ b/scripts/install @@ -59,14 +59,13 @@ export PATH="$PATH:$install_dir/.cargo/bin:$install_dir/.local/bin:/usr/local/sb else sudo -u "$app" bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=stable --profile=minimal' fi - fi pushd $install_dir python3 -m venv $install_dir/venv source $install_dir/venv/bin/activate - ynh_exec_warn_less pip install --upgrade pip - ynh_exec_warn_less pip install fittrackee==$fittrackee_version toml pyyaml + ynh_exec_warn_less pip install --upgrade pip wheel toml pyyaml + ynh_exec_warn_less pip install fittrackee==$fittrackee_version popd #================================================= From 9de094a743e197297ea43ae95aa70115e99558b5 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 7 Sep 2023 20:05:49 +0200 Subject: [PATCH 2/9] Update upgrade --- scripts/upgrade | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 4cfe6f1..747c3b2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -70,17 +70,13 @@ export PATH="$PATH:$install_dir/.cargo/bin:$install_dir/.local/bin:/usr/local/sb else sudo -u "$app" bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=stable --profile=minimal' fi - -sudo -u "$app" env PATH=$PATH rustup install stable -sudo -u "$app" env PATH=$PATH rustup default stable - fi pushd $install_dir python3 -m venv $install_dir/venv source $install_dir/venv/bin/activate - ynh_exec_warn_less pip install --upgrade pip - ynh_exec_warn_less pip install fittrackee==$fittrackee_version toml pyyaml + ynh_exec_warn_less pip install --upgrade pip wheel toml pyyaml + ynh_exec_warn_less pip install fittrackee==$fittrackee_version popd From 9af0df22e8293c99e60b4c22b5bd01e425d32a8a Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 14 Sep 2023 19:03:30 +0200 Subject: [PATCH 3/9] upgrade to 0.7.23 --- conf/.env.production | 2 +- manifest.toml | 2 +- scripts/_common.sh | 2 +- tests.toml | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/conf/.env.production b/conf/.env.production index 1765397..613fe47 100644 --- a/conf/.env.production +++ b/conf/.env.production @@ -29,7 +29,7 @@ REDIS_URL=redis:// # WORKERS_PROCESSES= # Workouts -TILE_SERVER_URL=https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png +TILE_SERVER_URL=https://tile.openstreetmap.org/{z}/{x}/{y}.png MAP_ATTRIBUTION='© OpenStreetMap contributors' DEFAULT_STATICMAP=False STATICMAP_SUBDOMAINS='' diff --git a/manifest.toml b/manifest.toml index 9d3a986..edbe575 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "FitTrackee" description.en = "Self-hosted outdoor activity tracker đźš´" description.fr = "Traqueur d’activitĂ©s extĂ©rieures auto-hĂ©bergĂ© đźš´" -version = "0.7.22~ynh1" +version = "0.7.23~ynh1" maintainers = ["Thovi98"] diff --git a/scripts/_common.sh b/scripts/_common.sh index 25a0b39..b1e329a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES #================================================= -fittrackee_version="0.7.22" +fittrackee_version="0.7.23" #================================================= # PERSONAL HELPERS diff --git a/tests.toml b/tests.toml index 99f274e..30a3b32 100644 --- a/tests.toml +++ b/tests.toml @@ -18,3 +18,4 @@ test_format = 1.0 test_upgrade_from.ca02214.name = "0.7.18" test_upgrade_from.9c094f9.name = "0.7.21" + test_upgrade_from.e49294c.name = "0.7.22" From aacd79414470829aa1ec594a1066da4ae41d5ec9 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 14 Sep 2023 17:03:34 +0000 Subject: [PATCH 4/9] 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 d30cec0..b784d67 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ FitTrackee allows you to track your outdoor activities (workouts) from gpx files No mobile app has been developed yet, but several existing mobile apps can store workouts data locally and export them into a gpx file. -**Shipped version:** 0.7.22~ynh1 +**Shipped version:** 0.7.23~ynh1 ## Screenshots diff --git a/README_fr.md b/README_fr.md index d232bb8..3797282 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po FitTrackee vous permet de suivre vos activitĂ©s de plein air (sĂ©ances d'entraĂ®nement) Ă  partir de fichiers gpx et de conserver vos donnĂ©es sur votre propre serveur. Aucune application mobile n'a encore Ă©tĂ© dĂ©veloppĂ©e, mais plusieurs applications mobiles existantes peuvent stocker localement les donnĂ©es des sĂ©ances d'entraĂ®nement et les exporter dans un fichier gpx. -**Version incluse :** 0.7.22~ynh1 +**Version incluse :** 0.7.23~ynh1 ## Captures d’écran From 1159bd34a0e0ac6821b86dbca5097843603630e2 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 14 Sep 2023 19:16:04 +0200 Subject: [PATCH 5/9] prepare mails (add redis) --- conf/.env.production | 2 +- scripts/_common.sh | 38 ++++++++++++++++++++++++++++++++++++++ scripts/change_url | 6 +++--- scripts/install | 5 +++++ scripts/remove | 9 +++++++++ scripts/upgrade | 11 +++++++++++ 6 files changed, 67 insertions(+), 4 deletions(-) diff --git a/conf/.env.production b/conf/.env.production index 613fe47..462fb7b 100644 --- a/conf/.env.production +++ b/conf/.env.production @@ -17,7 +17,7 @@ DATABASE_URL=postgresql://__DB_USER__:__DB_PWD__@:5432/__DB_NAME__ # DATABASE_DISABLE_POOLING= # Redis (required for API rate limits and email sending) -REDIS_URL=redis:// +REDIS_URL=redis://127.0.0.1:6379/__REDIS_DB__ # API rate limits # API_RATE_LIMITS="300 per 5 minutes" diff --git a/scripts/_common.sh b/scripts/_common.sh index b1e329a..7a0450e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -14,6 +14,44 @@ fittrackee_version="0.7.23" # EXPERIMENTAL HELPERS #================================================= +# 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 +} + #================================================= # FUTURE OFFICIAL HELPERS #================================================= diff --git a/scripts/change_url b/scripts/change_url index cb2a4b2..9304544 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -36,10 +36,10 @@ ynh_change_url_nginx_config #================================================= # MODIFY THE CONFIG FILE #================================================= -#ynh_script_progression --message="Modifying a config file..." --weight=1 +ynh_script_progression --message="Modifying a config file..." --weight=1 -#domain=$new_domain -#ynh_add_config --template="../conf/env.production" --destination="$install_dir/config/.env" +domain=$new_domain +ynh_add_config --template="../conf/env.production" --destination="$install_dir/config/.env" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/install b/scripts/install index 2ad638f..b3fe050 100755 --- a/scripts/install +++ b/scripts/install @@ -30,6 +30,11 @@ chown -R $app:www-data /var/log/$app/ # CONFIGURE THE INSTALL SCRIPT #================================================= +# Configure redis +redis_db=$(ynh_redis_get_free_db) +ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" + + # key for the .env __KEY__ key=$(ynh_string_random --length=45 | base64) ynh_app_setting_set --app=$app --key=key --value=$key diff --git a/scripts/remove b/scripts/remove index 4116866..469f9c3 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,6 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." + +redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #================================================= # STANDARD REMOVE @@ -47,6 +53,9 @@ ynh_remove_logrotate # Remove the log files ynh_secure_remove --file="/var/log/$app" +# Remove the redis database +ynh_redis_remove_db "$redis_db" + #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 747c3b2..2950d86 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_redis source /usr/share/yunohost/helpers #================================================= @@ -22,6 +23,16 @@ admin_mail=$(ynh_user_get_info --username=$admin --key=mail) upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# ENSURE 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 + #================================================= # STANDARD UPGRADE STEPS #================================================= From f23e5ab0f3af24ce44a4c0421e8804194ad9de89 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 14 Sep 2023 19:48:55 +0200 Subject: [PATCH 6/9] fix --- scripts/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2950d86..551957b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_redis source /usr/share/yunohost/helpers #================================================= From da810a7d348c2852bd960406ff32d2912dc9812b Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Fri, 15 Sep 2023 08:37:44 +0200 Subject: [PATCH 8/9] Update upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 551957b..e152831 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -27,7 +27,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # If redis_db doesn't exist, create it -if [ -z "$redis_db" ]; then +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 From 2e5044205ad9b6fbcee0d4190a0e0c5e4a1e9934 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Fri, 15 Sep 2023 08:57:02 +0200 Subject: [PATCH 9/9] Update upgrade --- scripts/upgrade | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index e152831..3d62385 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,16 +22,6 @@ admin_mail=$(ynh_user_get_info --username=$admin --key=mail) upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE 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 - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -57,6 +47,7 @@ chown -R $app: "$install_dir" #================================================= ynh_script_progression --message="Installing service script..." --weight=1 +redis_db=$(ynh_redis_get_free_db) ynh_add_config --template="../conf/.env.production" --destination="$install_dir/.env" chmod 600 $install_dir/.env chown $app: "$install_dir/.env"