From e3281a23c8c7ec56db5534026be06f21c204cada Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 20 Apr 2024 03:33:21 +0200 Subject: [PATCH 1/5] Upgrade to v1.21.11-1 https://codeberg.org/forgejo/forgejo/releases/tag/v1.21.11-1 --- manifest.toml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/manifest.toml b/manifest.toml index a47c6cd..f061ff7 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Forgejo" description.en = "Lightweight software forge" description.fr = "Forge logiciel légère" -version = "1.21.8-0~ynh2" +version = "1.21.11-1~ynh1" maintainers = [ "Emmanuel Averty" ] @@ -48,12 +48,12 @@ ram.runtime = "2G" [resources] [resources.sources.main] - amd64.url = "https://codeberg.org/forgejo/forgejo/releases/download/v1.21.8-0/forgejo-1.21.8-0-linux-amd64.xz" - amd64.sha256 = "b5e8c6a460099d8f7d315dbb15f2bb4075a185f876e0b38166d3217e71d10aae" - arm64.url = "https://codeberg.org/forgejo/forgejo/releases/download/v1.21.8-0/forgejo-1.21.8-0-linux-arm64.xz" - arm64.sha256 = "3755ed2e0c3829d9dafb690662c152206900cd386107bd3a30d0fbc2b95c6946" - armhf.url = "https://codeberg.org/forgejo/forgejo/releases/download/v1.21.8-0/forgejo-1.21.8-0-linux-arm-6.xz" - armhf.sha256 = "b06ebea57f72a00ff41f355c9d95c5e48a95a2b18c4c9e795eb04b5786b2f9a7" + amd64.url = "https://codeberg.org/forgejo/forgejo/releases/download/v1.21.11-1/forgejo-1.21.11-1-linux-amd64.xz" + amd64.sha256 = "5c22ea2249292c315712266d7785af0e18a8a5d36cce5f8924c18ab7ea97b7bd" + arm64.url = "https://codeberg.org/forgejo/forgejo/releases/download/v1.21.11-1/forgejo-1.21.11-1-linux-arm64.xz" + arm64.sha256 = "0b9975c14b20b49572dd6c8f9458baf0702c237724d532a4d06e434a2feb1eb6" + armhf.url = "https://codeberg.org/forgejo/forgejo/releases/download/v1.21.11-1/forgejo-1.21.11-1-linux-arm-6.xz" + armhf.sha256 = "0958784dba5fcb00069e46001d5d830ccaac350541d41bff3a7e0ed414cd5026" format = "whatever" extract = false # will be extracted during install script rename = "forgejo.xz" From 760e1453463833199e7a51d1f80012c1038b3ca2 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 20 Apr 2024 01:33:24 +0000 Subject: [PATCH 2/5] Auto-update READMEs --- ALL_README.md | 3 ++- README.md | 4 +-- README_eu.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++ README_fr.md | 2 +- README_gl.md | 2 +- README_zh_Hans.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 README_eu.md create mode 100644 README_zh_Hans.md diff --git a/ALL_README.md b/ALL_README.md index 3d6c579..a01b345 100644 --- a/ALL_README.md +++ b/ALL_README.md @@ -1,6 +1,7 @@ # All available README files by language - [Read the README in English](README.md) +- [Irakurri README euskaraz](README_eu.md) - [Lire le README en français](README_fr.md) - [Le o README en galego](README_gl.md) -- [Leggi il “README” in italiano](README_it.md) +- [阅读中文(简体)的 README](README_zh_Hans.md) diff --git a/README.md b/README.md index 193707f..85e038c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ It shall NOT be edited by hand. [![Install Forgejo with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=forgejo) -*[Read this README is other languages.](./ALL_README.md)* +*[Read this README in other languages.](./ALL_README.md)* > *This package allows you to install Forgejo quickly and simply on a YunoHost server.* > *If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.* @@ -34,7 +34,7 @@ Brought to you by an inclusive community under the umbrella of Codeberg e.V., a - Customize HTML templates, static files and many others. -**Shipped version:** 1.21.8-0~ynh2 +**Shipped version:** 1.21.11-1~ynh1 ## Screenshots diff --git a/README_eu.md b/README_eu.md new file mode 100644 index 0000000..49bc42a --- /dev/null +++ b/README_eu.md @@ -0,0 +1,64 @@ + + +# Forgejo YunoHost-erako + +[![Integrazio maila](https://dash.yunohost.org/integration/forgejo.svg)](https://dash.yunohost.org/appci/app/forgejo) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/forgejo.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/forgejo.maintain.svg) + +[![Instalatu Forgejo YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=forgejo) + +*[Irakurri README hau beste hizkuntzatan.](./ALL_README.md)* + +> *Pakete honek Forgejo YunoHost zerbitzari batean azkar eta zailtasunik gabe instalatzea ahalbidetzen dizu.* +> *YunoHost ez baduzu, kontsultatu [gida](https://yunohost.org/install) nola instalatu ikasteko.* + +## Aurreikuspena + +Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job. + +Brought to you by an inclusive community under the umbrella of Codeberg e.V., a democratic non-profit organization, Forgejo can be trusted to be exclusively Free Software. It focuses on security, scaling, federation and privacy. + +### Features + +- User dashboard, user profile and activity timeline. +- User, organization and repository management. +- Repository and organization webhooks, including Slack, Discord and Dingtalk. +- Repository Git hooks, deploy keys and Git LFS. +- Repository issues, pull requests, wiki, protected branches and collaboration. +- Migrate and mirror repositories with wiki from other code hosts. +- Web editor for quick editing repository files and wiki. +- Jupyter Notebook and PDF rendering. +- Authentication via SMTP, LDAP. +- Customize HTML templates, static files and many others. + + +**Paketatutako bertsioa:** 1.21.11-1~ynh1 + +## Pantaila-argazkiak + +![Forgejo(r)en pantaila-argazkia](./doc/screenshots/screenshot.png) + +## Dokumentazioa eta baliabideak + +- Aplikazioaren webgune ofiziala: +- Erabiltzaileen dokumentazio ofiziala: +- Administratzaileen dokumentazio ofiziala: +- Jatorrizko aplikazioaren kode-gordailua: +- YunoHost Denda: +- Eman errore baten berri: + +## Garatzaileentzako informazioa + +Bidali `pull request`a [`testing` abarrera](https://github.com/YunoHost-Apps/forgejo_ynh/tree/testing). + +`testing` abarra probatzeko, ondorengoa egin: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/forgejo_ynh/tree/testing --debug +edo +sudo yunohost app upgrade forgejo -u https://github.com/YunoHost-Apps/forgejo_ynh/tree/testing --debug +``` + +**Informazio gehiago aplikazioaren paketatzeari buruz:** diff --git a/README_fr.md b/README_fr.md index d1d43ae..748bd7a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -34,7 +34,7 @@ Présenté par une communauté inclusive sous l'égide de Codeberg e.V., une org - Modèle personnalisé HTML, de fichiers statiques et de nombreux autres. -**Version incluse :** 1.21.8-0~ynh2 +**Version incluse :** 1.21.11-1~ynh1 ## Captures d’écran diff --git a/README_gl.md b/README_gl.md index 43c0590..dfdc12f 100644 --- a/README_gl.md +++ b/README_gl.md @@ -34,7 +34,7 @@ Brought to you by an inclusive community under the umbrella of Codeberg e.V., a - Customize HTML templates, static files and many others. -**Versión proporcionada:** 1.21.8-0~ynh2 +**Versión proporcionada:** 1.21.11-1~ynh1 ## Capturas de pantalla diff --git a/README_zh_Hans.md b/README_zh_Hans.md new file mode 100644 index 0000000..8351d3d --- /dev/null +++ b/README_zh_Hans.md @@ -0,0 +1,64 @@ + + +# YunoHost 的 Forgejo + +[![集成程度](https://dash.yunohost.org/integration/forgejo.svg)](https://dash.yunohost.org/appci/app/forgejo) ![工作状态](https://ci-apps.yunohost.org/ci/badges/forgejo.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/forgejo.maintain.svg) + +[![使用 YunoHost 安装 Forgejo](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=forgejo) + +*[阅读此 README 的其它语言版本。](./ALL_README.md)* + +> *通过此软件包,您可以在 YunoHost 服务器上快速、简单地安装 Forgejo。* +> *如果您还没有 YunoHost,请参阅[指南](https://yunohost.org/install)了解如何安装它。* + +## 概况 + +Forgejo is a self-hosted lightweight software forge. Easy to install and low maintenance, it just does the job. + +Brought to you by an inclusive community under the umbrella of Codeberg e.V., a democratic non-profit organization, Forgejo can be trusted to be exclusively Free Software. It focuses on security, scaling, federation and privacy. + +### Features + +- User dashboard, user profile and activity timeline. +- User, organization and repository management. +- Repository and organization webhooks, including Slack, Discord and Dingtalk. +- Repository Git hooks, deploy keys and Git LFS. +- Repository issues, pull requests, wiki, protected branches and collaboration. +- Migrate and mirror repositories with wiki from other code hosts. +- Web editor for quick editing repository files and wiki. +- Jupyter Notebook and PDF rendering. +- Authentication via SMTP, LDAP. +- Customize HTML templates, static files and many others. + + +**分发版本:** 1.21.11-1~ynh1 + +## 截图 + +![Forgejo 的截图](./doc/screenshots/screenshot.png) + +## 文档与资源 + +- 官方应用网站: +- 官方用户文档: +- 官方管理文档: +- 上游应用代码库: +- YunoHost 商店: +- 报告 bug: + +## 开发者信息 + +请向 [`testing` 分支](https://github.com/YunoHost-Apps/forgejo_ynh/tree/testing) 发送拉取请求。 + +如要尝试 `testing` 分支,请这样操作: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/forgejo_ynh/tree/testing --debug +或 +sudo yunohost app upgrade forgejo -u https://github.com/YunoHost-Apps/forgejo_ynh/tree/testing --debug +``` + +**有关应用打包的更多信息:** From c8a3dc6611cbd403475c8e96ff030e635c303ae2 Mon Sep 17 00:00:00 2001 From: YunoHost Bot Date: Sat, 4 May 2024 01:06:36 +0200 Subject: [PATCH 3/5] Upgrade to v7.0.2 (#97) --- README.md | 2 +- README_eu.md | 2 +- README_fr.md | 2 +- README_gl.md | 2 +- README_zh_Hans.md | 2 +- manifest.toml | 14 +++++++------- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 85e038c..a9f5717 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Brought to you by an inclusive community under the umbrella of Codeberg e.V., a - Customize HTML templates, static files and many others. -**Shipped version:** 1.21.11-1~ynh1 +**Shipped version:** 7.0.2~ynh1 ## Screenshots diff --git a/README_eu.md b/README_eu.md index 49bc42a..b1e37e7 100644 --- a/README_eu.md +++ b/README_eu.md @@ -34,7 +34,7 @@ Brought to you by an inclusive community under the umbrella of Codeberg e.V., a - Customize HTML templates, static files and many others. -**Paketatutako bertsioa:** 1.21.11-1~ynh1 +**Paketatutako bertsioa:** 7.0.2~ynh1 ## Pantaila-argazkiak diff --git a/README_fr.md b/README_fr.md index 748bd7a..a5b5f8a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -34,7 +34,7 @@ Présenté par une communauté inclusive sous l'égide de Codeberg e.V., une org - Modèle personnalisé HTML, de fichiers statiques et de nombreux autres. -**Version incluse :** 1.21.11-1~ynh1 +**Version incluse :** 7.0.2~ynh1 ## Captures d’écran diff --git a/README_gl.md b/README_gl.md index dfdc12f..ccd85ce 100644 --- a/README_gl.md +++ b/README_gl.md @@ -34,7 +34,7 @@ Brought to you by an inclusive community under the umbrella of Codeberg e.V., a - Customize HTML templates, static files and many others. -**Versión proporcionada:** 1.21.11-1~ynh1 +**Versión proporcionada:** 7.0.2~ynh1 ## Capturas de pantalla diff --git a/README_zh_Hans.md b/README_zh_Hans.md index 8351d3d..ca2c3ab 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -34,7 +34,7 @@ Brought to you by an inclusive community under the umbrella of Codeberg e.V., a - Customize HTML templates, static files and many others. -**分发版本:** 1.21.11-1~ynh1 +**分发版本:** 7.0.2~ynh1 ## 截图 diff --git a/manifest.toml b/manifest.toml index f061ff7..4088a8c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Forgejo" description.en = "Lightweight software forge" description.fr = "Forge logiciel légère" -version = "1.21.11-1~ynh1" +version = "7.0.2~ynh1" maintainers = [ "Emmanuel Averty" ] @@ -48,12 +48,12 @@ ram.runtime = "2G" [resources] [resources.sources.main] - amd64.url = "https://codeberg.org/forgejo/forgejo/releases/download/v1.21.11-1/forgejo-1.21.11-1-linux-amd64.xz" - amd64.sha256 = "5c22ea2249292c315712266d7785af0e18a8a5d36cce5f8924c18ab7ea97b7bd" - arm64.url = "https://codeberg.org/forgejo/forgejo/releases/download/v1.21.11-1/forgejo-1.21.11-1-linux-arm64.xz" - arm64.sha256 = "0b9975c14b20b49572dd6c8f9458baf0702c237724d532a4d06e434a2feb1eb6" - armhf.url = "https://codeberg.org/forgejo/forgejo/releases/download/v1.21.11-1/forgejo-1.21.11-1-linux-arm-6.xz" - armhf.sha256 = "0958784dba5fcb00069e46001d5d830ccaac350541d41bff3a7e0ed414cd5026" + amd64.url = "https://codeberg.org/forgejo/forgejo/releases/download/v7.0.2/forgejo-7.0.2-linux-amd64.xz" + amd64.sha256 = "f0424f424e670769ac5bf1fad57576585eb7630f44b9cfe620697a2b17fb159e" + arm64.url = "https://codeberg.org/forgejo/forgejo/releases/download/v7.0.2/forgejo-7.0.2-linux-arm64.xz" + arm64.sha256 = "0db0be5827bac884e4a045a30a896d53d713e71ca49afdde214a4a7a8226d797" + armhf.url = "https://codeberg.org/forgejo/forgejo/releases/download/v7.0.2/forgejo-7.0.2-linux-arm-6.xz" + armhf.sha256 = "73043f7d19b00d4759a07f866b555c61350c8edb3084f68cd1b4e41038b74c93" format = "whatever" extract = false # will be extracted during install script rename = "forgejo.xz" From 15dd23b3361d826d1dc9eff19502c59c27fa79cb Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 4 May 2024 01:24:34 +0200 Subject: [PATCH 4/5] fix many SC2086 linter warning --- scripts/_common.sh | 20 +++++++++--------- scripts/change_url | 6 +++--- scripts/install | 26 +++++++++++------------ scripts/remove | 4 ++-- scripts/restore | 14 ++++++------- scripts/upgrade | 52 +++++++++++++++++++++++----------------------- 6 files changed, 61 insertions(+), 61 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index e115cb4..dad63d9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,26 +7,26 @@ function set_forgejo_login_source() { ynh_print_info --message="Creating forgejo login source" pushd "$install_dir" - ynh_exec_as $app ./forgejo admin auth add-ldap-simple --security-protocol "Unencrypted" --name "YunoHost LDAP" --host "localhost" --port "389" --skip-tls-verify --user-search-base "ou=users,dc=yunohost,dc=org" --user-dn "uid=%s,ou=Users,dc=yunohost,dc=org" --user-filter "(&(objectclass=posixAccount)(uid=%s)(permission=cn=$app.main,ou=permission,dc=yunohost,dc=org))" --admin-filter "(permission=cn=forgejo.admin,ou=permission,dc=yunohost,dc=org)" --username-attribute "uid" --firstname-attribute "givenName" --surname-attribute "sn" --email-attribute "mail" + ynh_exec_as "$app" ./forgejo admin auth add-ldap-simple --security-protocol "Unencrypted" --name "YunoHost LDAP" --host "localhost" --port "389" --skip-tls-verify --user-search-base "ou=users,dc=yunohost,dc=org" --user-dn "uid=%s,ou=Users,dc=yunohost,dc=org" --user-filter "(&(objectclass=posixAccount)(uid=%s)(permission=cn=$app.main,ou=permission,dc=yunohost,dc=org))" --admin-filter "(permission=cn=forgejo.admin,ou=permission,dc=yunohost,dc=org)" --username-attribute "uid" --firstname-attribute "givenName" --surname-attribute "sn" --email-attribute "mail" popd } function enable_login_source_sync() { ynh_print_info --message="Set forgejo login source as synchronizable" # Enable login source synchronisation manualy because forgejo command does not allow it (https://codeberg.org/forgejo/forgejo/issues/952) - ynh_psql_execute_as_root --database $db_name --sql "update login_source set is_sync_enabled = true where type = 5 and name = 'YunoHost LDAP'" + ynh_psql_execute_as_root --database "$db_name" --sql "update login_source set is_sync_enabled = true where type = 5 and name = 'YunoHost LDAP'" } function create_forgejo_api_user() { ynh_print_info --message="Creating forgejo api user" forgejo_api_user=yunohost_api forgejo_api_pwd=$(ynh_string_random --length=24) - ynh_app_setting_set --app=$app --key=forgejo_api_user --value=$forgejo_api_user - ynh_app_setting_set --app=$app --key=forgejo_api_pwd --value=$forgejo_api_pwd + ynh_app_setting_set --app="$app" --key=forgejo_api_user --value="$forgejo_api_user" + ynh_app_setting_set --app="$app" --key=forgejo_api_pwd --value="$forgejo_api_pwd" pushd "$install_dir" - ynh_exec_as $app ./forgejo admin user create --username $forgejo_api_user --password $forgejo_api_pwd --email admin@${domain} --admin --must-change-password=false - forgejo_api_token=$(ynh_exec_as $app ./forgejo admin user generate-access-token --username $forgejo_api_user --token-name "admin" --scopes "write:admin" --raw | tail -1) - ynh_app_setting_set --app=$app --key=forgejo_api_token --value=$forgejo_api_token + ynh_exec_as "$app" ./forgejo admin user create --username "$forgejo_api_user" --password "$forgejo_api_pwd" --email "admin@${domain}" --admin --must-change-password=false + forgejo_api_token=$(ynh_exec_as "$app" ./forgejo admin user generate-access-token --username "$forgejo_api_user" --token-name "admin" --scopes "write:admin" --raw | tail -1) + ynh_app_setting_set --app="$app" --key=forgejo_api_token --value="$forgejo_api_token" popd } @@ -35,18 +35,18 @@ function set_users_login_source() { for username in $(ynh_user_list); do ynh_print_info --message="Updating forgejo user login type for ${username}" - ynh_psql_execute_as_root --database $db_name --sql "update public.user set login_source = (select id from login_source where name = 'YunoHost LDAP' and type = 5), login_name = name, login_type = 5 where name = '${username}'" + ynh_psql_execute_as_root --database "$db_name" --sql "update public.user set login_source = (select id from login_source where name = 'YunoHost LDAP' and type = 5), login_name = name, login_type = 5 where name = '${username}'" done } function synchronize_users() { ynh_print_info --message="Synchronizing forgejo users" # Fetch the token independently such that it's redacted by Yunohost logging mechanism - forgejo_api_token=$(ynh_app_setting_get --app=$app --key=forgejo_api_token) + forgejo_api_token=$(ynh_app_setting_get --app="$app" --key=forgejo_api_token) # Remove trailing slash from path local no_trailing_slash_path=${path%/} # User synchronization must be launched using API : no cli exists for this purpose (https://codeberg.org/forgejo/forgejo/issues/953) - curl --url https://${domain}${no_trailing_slash_path}/api/v1/admin/cron/sync_external_users -X POST -H "Authorization: token $forgejo_api_token" -kfsS + curl --url "https://${domain}${no_trailing_slash_path}/api/v1/admin/cron/sync_external_users" -X POST -H "Authorization: token $forgejo_api_token" -kfsS } diff --git a/scripts/change_url b/scripts/change_url index b834b48..7f6e399 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=2 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/forgejo.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/forgejo.log" #================================================= # MODIFY URL IN NGINX CONF @@ -34,7 +34,7 @@ ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+") ynh_exec_warn_less ynh_add_config --template="../conf/app.ini" --destination="$install_dir/custom/conf/app.ini" chmod 640 "$install_dir/custom/conf/app.ini" -chown $app:$app "$install_dir/custom/conf/app.ini" +chown "$app:$app" "$install_dir/custom/conf/app.ini" #================================================= # GENERIC FINALISATION @@ -43,7 +43,7 @@ chown $app:$app "$install_dir/custom/conf/app.ini" #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 4441ee9..871236e 100644 --- a/scripts/install +++ b/scripts/install @@ -20,20 +20,20 @@ chmod +x "$install_dir/forgejo" mkdir -p "$install_dir/custom/conf" chmod -R o-rwx "$install_dir/custom" -chown -R $app:$app "$install_dir/custom" +chown -R "$app:$app" "$install_dir/custom" #================================================= # KEYS GENERATION #================================================= -secret_key=$($install_dir/forgejo generate secret SECRET_KEY) -lfs_jwt_secret=$($install_dir/forgejo generate secret JWT_SECRET) -internal_token=$($install_dir/forgejo generate secret INTERNAL_TOKEN) -oauth2_jwt_secret=$($install_dir/forgejo generate secret JWT_SECRET) -ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key -ynh_app_setting_set --app=$app --key=lfs_jwt_secret --value=$lfs_jwt_secret -ynh_app_setting_set --app=$app --key=internal_token --value=$internal_token -ynh_app_setting_set --app=$app --key=oauth2_jwt_secret --value=$oauth2_jwt_secret +secret_key=$("$install_dir/forgejo" generate secret SECRET_KEY) +lfs_jwt_secret=$("$install_dir/forgejo" generate secret JWT_SECRET) +internal_token=$("$install_dir/forgejo" generate secret INTERNAL_TOKEN) +oauth2_jwt_secret=$("$install_dir/forgejo" generate secret JWT_SECRET) +ynh_app_setting_set --app="$app" --key=secret_key --value="$secret_key" +ynh_app_setting_set --app="$app" --key=lfs_jwt_secret --value="$lfs_jwt_secret" +ynh_app_setting_set --app="$app" --key=internal_token --value="$internal_token" +ynh_app_setting_set --app="$app" --key=oauth2_jwt_secret --value="$oauth2_jwt_secret" #================================================= # ADD A CONFIGURATION @@ -44,7 +44,7 @@ ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+") ynh_add_config --template="app.ini" --destination="$install_dir/custom/conf/app.ini" chmod 640 "$install_dir/custom/conf/app.ini" -chown $app:$app "$install_dir/custom/conf/app.ini" +chown "$app:$app" "$install_dir/custom/conf/app.ini" #================================================= # SETUP SYSTEMD @@ -70,7 +70,7 @@ ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate --logfile "/var/log/$app" --nonappend -chown -R $app:$app "/var/log/$app" +chown -R "$app:$app" "/var/log/$app" chmod u=rwX,g=rX,o= "/var/log/$app" #================================================= @@ -78,7 +78,7 @@ chmod u=rwX,g=rX,o= "/var/log/$app" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 -yunohost service add $app --description="Forgejo" --log="/var/log/$app/forgejo.log" +yunohost service add "$app" --description="Forgejo" --log="/var/log/$app/forgejo.log" #================================================= # START SYSTEMD SERVICE @@ -86,7 +86,7 @@ yunohost service add $app --description="Forgejo" --log="/var/log/$app/forgejo.l ynh_script_progression --message="Starting a systemd service..." --weight=3 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:" #================================================= # SETUP FAIL2BAN diff --git a/scripts/remove b/scripts/remove index 1f56823..0686a3c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -16,10 +16,10 @@ source /usr/share/yunohost/helpers #================================================= # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null +if ynh_exec_warn_less yunohost service status "$app" >/dev/null then ynh_script_progression --message="Removing $app service integration..." --weight=1 - yunohost service remove $app + yunohost service remove "$app" fi # Remove the dedicated systemd config diff --git a/scripts/restore b/scripts/restore index a79ec3b..f2ee8f0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,20 +26,20 @@ ynh_script_progression --message="Restoring $app main directory..." --weight=10 ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" +chown -R "$app:$app" "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_restore_file --origin_path="$data_dir" --not_mandatory -chown -R $app:$app "$data_dir" +chown -R "$app:$app" "$data_dir" #================================================= # RESTORE THE LOG DIRECTORY #================================================= ynh_restore_file --origin_path="/var/log/$app" -chown -R $app:$app "/var/log/$app" +chown -R "$app:$app" "/var/log/$app" chmod u=rwX,g=rX,o= "/var/log/$app" #================================================= @@ -56,7 +56,7 @@ ynh_systemd_action --action=restart --service_name=fail2ban #================================================= ynh_script_progression --message="Restoring the database..." --weight=6 -ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name +ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # RESTORE SYSTEMD @@ -64,7 +64,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name ynh_script_progression --message="Restoring the systemd configuration..." --weight=5 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet +systemctl enable "$app.service" --quiet #================================================= # RESTORE THE LOGROTATE CONFIGURATION @@ -78,14 +78,14 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Forgejo" --log="/var/log/$app/forgejo.log" +yunohost service add "$app" --description="Forgejo" --log="/var/log/$app/forgejo.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=3 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index a4490af..f75b289 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,7 @@ upgrade_type=$(ynh_check_app_version_changed) # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=2 -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -30,18 +30,18 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # Update forgejo login source (1.19.3-0~ynh2) pushd "$install_dir" - old_login_source_id=$(ynh_exec_as $app ./forgejo admin auth list | grep "YunoHost LDAP" | grep "via BindDN" | cut -f 1) - if [ ! -z $old_login_source_id ]; then + old_login_source_id=$(ynh_exec_as "$app" ./forgejo admin auth list | grep "YunoHost LDAP" | grep "via BindDN" | cut -f 1) + if [ -n "$old_login_source_id" ]; then ynh_print_info --message="Delete obsolete forgejo login source (LDAP via BindDN)" # Ensure no user have this obsolete login source - ynh_psql_execute_as_root --database $db_name --sql "update public.user set login_source = 0, login_type = 0 where login_source = ${old_login_source_id}" + ynh_psql_execute_as_root --database "$db_name" --sql "update public.user set login_source = 0, login_type = 0 where login_source = ${old_login_source_id}" # Delete old login source - ynh_exec_as $app ./forgejo admin auth delete --id $old_login_source_id + ynh_exec_as "$app" ./forgejo admin auth delete --id "$old_login_source_id" fi - ynh_exec_as $app ./forgejo admin auth list | grep "YunoHost LDAP" | grep -q "LDAP (simple auth)" || + ynh_exec_as "$app" ./forgejo admin auth list | grep "YunoHost LDAP" | grep -q "LDAP (simple auth)" || # create new login source if not existing set_forgejo_login_source popd @@ -53,31 +53,31 @@ enable_login_source_sync # .ssh directory should move from old home dir (data_dir) to new one # (/var/www/$app is the default value for home in resources.system_user) if [ -d "$data_dir/.ssh" ]; then - mv "$data_dir/.ssh" /var/www/$app + mv "$data_dir/.ssh" "/var/www/$app" fi # If secret_key doesn't exist, create it -if [ -z ${secret_key:-} ]; then - secret_key=$($install_dir/forgejo generate secret SECRET_KEY) - ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key +if [ -z "${secret_key:-}" ]; then + secret_key=$("$install_dir/forgejo" generate secret SECRET_KEY) + ynh_app_setting_set --app="$app" --key=secret_key --value="$secret_key" fi # If lfs_jwt_secret doesn't exist, create it -if [ -z ${lfs_jwt_secret:-} ]; then - lfs_jwt_secret=$($install_dir/forgejo generate secret JWT_SECRET) - ynh_app_setting_set --app=$app --key=lfs_jwt_secret --value=$lfs_jwt_secret +if [ -z "${lfs_jwt_secret:-}" ]; then + lfs_jwt_secret=$("$install_dir/forgejo" generate secret JWT_SECRET) + ynh_app_setting_set --app="$app" --key=lfs_jwt_secret --value="$lfs_jwt_secret" fi # If internal_token doesn't exist, create it -if [ -z ${internal_token:-} ]; then - internal_token=$($install_dir/forgejo generate secret INTERNAL_TOKEN) - ynh_app_setting_set --app=$app --key=internal_token --value=$internal_token +if [ -z "${internal_token:-}" ]; then + internal_token=$("$install_dir/forgejo" generate secret INTERNAL_TOKEN) + ynh_app_setting_set --app="$app" --key=internal_token --value="$internal_token" fi # If oauth2_jwt_secret doesn't exist, create it -if [ -z ${oauth2_jwt_secret:-} ]; then - oauth2_jwt_secret=$($install_dir/forgejo generate secret JWT_SECRET) - ynh_app_setting_set --app=$app --key=oauth2_jwt_secret --value=$oauth2_jwt_secret +if [ -z "${oauth2_jwt_secret:-}" ]; then + oauth2_jwt_secret=$("$install_dir/forgejo" generate secret JWT_SECRET) + ynh_app_setting_set --app="$app" --key=oauth2_jwt_secret --value="$oauth2_jwt_secret" fi #================================================= @@ -85,11 +85,11 @@ fi #================================================= ynh_script_progression --message="Setting up source files..." --weight=3 -ynh_setup_source --dest_dir=$install_dir --full_replace=1 --keep="custom .ssh" +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="custom .ssh" xz -f -d "$install_dir/forgejo.xz" chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" +chown -R "$app:$app" "$install_dir" chmod +x "$install_dir/forgejo" #================================================= @@ -101,7 +101,7 @@ ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+") ynh_add_config --template="app.ini" --destination="$install_dir/custom/conf/app.ini" chmod 640 "$install_dir/custom/conf/app.ini" -chown $app:$app "$install_dir/custom/conf/app.ini" +chown "$app:$app" "$install_dir/custom/conf/app.ini" #================================================= # SETUP SYSTEMD @@ -127,7 +127,7 @@ ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate --logfile "/var/log/$app" --nonappend -chown -R $app:$app "/var/log/$app" +chown -R "$app:$app" "/var/log/$app" chmod u=rwX,g=rX,o= "/var/log/$app" #================================================= @@ -135,7 +135,7 @@ chmod u=rwX,g=rX,o= "/var/log/$app" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 -yunohost service add $app --description="Forgejo" --log="/var/log/$app/forgejo.log" +yunohost service add "$app" --description="Forgejo" --log="/var/log/$app/forgejo.log" #================================================= # START SYSTEMD SERVICE @@ -143,13 +143,13 @@ yunohost service add $app --description="Forgejo" --log="/var/log/$app/forgejo.l ynh_script_progression --message="Starting a systemd service..." --weight=3 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/forgejo.log" --line_match="Starting new Web server: tcp:127.0.0.1:" #================================================= # Synchronize users (backward compatibility 1.19.3-0~ynh3) #================================================= -if [ -z ${forgejo_api_user:-} ]; then +if [ -z "${forgejo_api_user:-}" ]; then create_forgejo_api_user fi From ca86c7dbd2b366c7af9571c435c35073b1931b16 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 4 May 2024 01:24:45 +0200 Subject: [PATCH 5/5] test upgrade from the latest v1 --- tests.toml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests.toml b/tests.toml index 91daf17..44c91d8 100644 --- a/tests.toml +++ b/tests.toml @@ -2,6 +2,8 @@ test_format = 1.0 [default] - # ------------ - # Tests to run - # ------------ \ No newline at end of file +# ------------------------------- +# Commits to test upgrade from +# ------------------------------- + +test_upgrade_from.eebeab47.name = "Upgrade from 1.21.11-1~ynh1" \ No newline at end of file