From 61fabf77a7c31f2521b60689183781fde3dde596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 11:59:13 +0100 Subject: [PATCH 01/17] Manifest v2 --- .github/workflows/updater.sh | 64 ------------ .github/workflows/updater.yml | 50 ---------- check_process | 31 ------ conf/cron | 2 + conf/nginx.conf | 4 +- conf/systemd.service | 5 +- conf/yunorunner.config.py | 4 +- manifest.json | 70 ------------- manifest.toml | 85 ++++++++++++++++ scripts/_common.sh | 181 ++++++++++++++-------------------- scripts/backup | 26 +---- scripts/change_url | 120 +--------------------- scripts/install | 166 ++++++------------------------- scripts/remove | 70 +------------ scripts/restore | 110 ++++----------------- scripts/upgrade | 164 +++++++----------------------- tests.toml | 16 +++ 17 files changed, 282 insertions(+), 886 deletions(-) delete mode 100644 .github/workflows/updater.sh delete mode 100644 .github/workflows/updater.yml delete mode 100644 check_process create mode 100644 conf/cron delete mode 100644 manifest.json create mode 100644 manifest.toml create mode 100644 tests.toml diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100644 index 80d4473..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -#================================================= -# PACKAGE UPDATING HELPER -#================================================= - -# This script is meant to be run by GitHub Actions -# The YunoHost-Apps organisation offers a template Action to run this script periodically - -#================================================= -# FETCHING LATEST RELEASE AND ITS ASSETS -#================================================= - -# Fetching information -current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') -current_yunorunner_release=$(grep -Po 'yunorunner_release="\K.*?(?=")' scripts/_common.sh) -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/commits/master" | jq -r '.commit.committer.date | split("T")[0] | gsub("-";".")') -yunorunner_release=$(curl --silent "https://api.github.com/repos/$repo/commits/master" | jq -r '.sha') - -# Setting up the environment variables -echo "Current version: $current_version" -echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV -# For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV - -# Proceed only if the retrieved version is greater than the current one -if [[ ! "$version" > "$current_version" ]]; then - echo "::warning ::No new version available" - exit 0 -# 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 -fi - -#================================================= -# UPDATE SOURCE FILES -#================================================= - -sed -i "s/$current_yunorunner_release/$yunorunner_release/gi" scripts/_common.sh - -#================================================= -# SPECIFIC UPDATE STEPS -#================================================= - -# Any action on the app's source code can be done. -# The GitHub Action workflow takes care of committing all changes after this script ends. - -#================================================= -# GENERIC FINALIZATION -#================================================= - -# Replace new version in manifest -echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json - -# No need to update the README, yunohost-bot takes care of it - -# The Action will proceed only if the PROCEED environment variable is set to true -echo "PROCEED=true" >> $GITHUB_ENV -exit 0 - diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml deleted file mode 100644 index 08ec1b3..0000000 --- a/.github/workflows/updater.yml +++ /dev/null @@ -1,50 +0,0 @@ -# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. -# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. -# This file should be enough by itself, but feel free to tune it to your needs. -# It calls updater.sh, which is where you should put the app-specific update steps. -name: Check for new upstream releases -on: - # Allow to manually trigger the workflow - workflow_dispatch: - # Run it every day at 6:00 UTC - schedule: - - cron: '0 6 * * *' -jobs: - updater: - runs-on: ubuntu-latest - steps: - - name: Fetch the source code - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Run the updater script - id: run_updater - run: | - # Setting up Git user - git config --global user.name 'yunohost-bot' - git config --global user.email 'yunohost-bot@users.noreply.github.com' - # Run the updater script - /bin/bash .github/workflows/updater.sh - - name: Commit changes - id: commit - if: ${{ env.PROCEED == 'true' }} - run: | - git commit -am "Upgrade to v$VERSION" - - name: Create Pull Request - id: cpr - if: ${{ env.PROCEED == 'true' }} - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update to version ${{ env.VERSION }} - committer: 'yunohost-bot ' - author: 'yunohost-bot ' - signoff: false - base: testing - branch: ci-auto-update-v${{ env.VERSION }} - delete-branch: true - title: 'Upgrade to version ${{ env.VERSION }}' - body: | - Upgrade to v${{ env.VERSION }} - draft: false - diff --git a/check_process b/check_process deleted file mode 100644 index 7f5c3c4..0000000 --- a/check_process +++ /dev/null @@ -1,31 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - context="personal-ci" - mode="manual" - cluster="no" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=0 - setup_public=1 - upgrade=1 - # 2021-03-05~ynh1 - upgrade=1 from_commit=f0e9373aa2403bf04f84c67646ac5d34376b7959 - # 2021-09-22~ynh1 - upgrade=1 from_commit=fea498cd83a7da12a102efe2f47397dace3cddda - backup_restore=1 - multi_instance=1 - port_already_use=1 (4242) - change_url=1 -;;; Options -Email= -Notification=down -;;; Upgrade options - ; commit=f0e9373aa2403bf04f84c67646ac5d34376b7959 - name=2021-03-05~ynh1 - ; commit=fea498cd83a7da12a102efe2f47397dace3cddda - name=2021-09-22~ynh1 diff --git a/conf/cron b/conf/cron new file mode 100644 index 0000000..2bf2ef9 --- /dev/null +++ b/conf/cron @@ -0,0 +1,2 @@ +# self-upgrade every night +0 3 * * * root "__INSTALL_DIR__/maintenance/self_upgrade.sh" >> "__INSTALL_DIR__/maintenance/self_upgrade.log" 2>&1 diff --git a/conf/nginx.conf b/conf/nginx.conf index 8fb8d61..ce2b44e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -11,13 +11,13 @@ location __PATH__/ { include conf.d/yunohost_panel.conf.inc; location __PATH__/logs { - alias __FINALPATH__/results/logs/; + alias __INSTALL_DIR__/results/logs/; autoindex on; default_type "text/plain"; } location __PATH__/summary/ { - alias __FINALPATH__/results/summary/; + alias __INSTALL_DIR__/results/summary/; autoindex on; etag off; more_set_headers "Cache-control: max-age=300, s-maxage=300"; diff --git a/conf/systemd.service b/conf/systemd.service index ad977e3..12e1fae 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,8 +7,9 @@ Type=simple Restart=always User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/python ./run.py +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/python ./run.py +Environment=YNHDEV_BACKEND=__BACKEND__ # Sandboxing options to harden security # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html diff --git a/conf/yunorunner.config.py b/conf/yunorunner.config.py index 354c7fe..5b2adea 100644 --- a/conf/yunorunner.config.py +++ b/conf/yunorunner.config.py @@ -1,6 +1,8 @@ +#!/usr/bin/env python3 + BASE_URL = "https://__DOMAIN____PATH__" PORT = __PORT__ -PACKAGE_CHECK_DIR = "__FINALPATH__/package_check/" +PACKAGE_CHECK_DIR = "__INSTALL_DIR__/package_check/" MONITOR_APPS_LIST = __AUTO__ MONITOR_GIT = __AUTO__ MONITOR_ONLY_GOOD_QUALITY_APPS = False diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 37af0ce..0000000 --- a/manifest.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "YunoRunner", - "id": "yunorunner", - "packaging_format": 1, - "description": { - "en": "CI runner of YunoHost", - "fr": "Runner d'intégration continue de YunoHost" - }, - "version": "2023.04.05~ynh1", - "url": "https://github.com/YunoHost/yunorunner", - "upstream": { - "license": "GPL-3.0-or-later", - "code": "https://github.com/YunoHost/yunorunner" - }, - "license": "GPL-3.0-or-later", - "maintainer": { - "name": "" - }, - "previous_maintainer": { - "name": "Maniack Crudelis", - "email": "maniackc_dev@crudelis.fr" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": true, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "default": "/ci" - }, - { - "name": "context", - "type": "select", - "choices": ["personal-ci", "official-infra"], - "default": "personal-ci", - "ask": { - "en": "Leave it to 'personal-ci'. If set to 'official-infra', Yunorunner will take over your server and disable vital services to run alone." - } - }, - { - "name": "mode", - "type": "select", - "choices": ["auto", "manual"], - "default": "manual", - "ask": { - "en": "Should the jobs be automatically run from the apps list? In manual mode, Yunorunner will expect to be triggered by the `ciclic` command or webhooks (like ci-apps-dev). In auto mode, all apps of the catalog will be scheduled to be tested at least once a month and upon any change in their designated main branch (like ci-apps)." - } - }, - { - "name": "cluster", - "type": "select", - "choices": ["cluster", "no"], - "default": "no", - "ask": { - "en": "Should an LXD cluster be created with this server as first node? (cluster mode is experimental)" - } - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..eae9aac --- /dev/null +++ b/manifest.toml @@ -0,0 +1,85 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "yunorunner" +name = "YunoRunner" +description.en = "CI runner of YunoHost" +description.fr = "Runner d'intégration continue de YunoHost" + +version = "2023.04.05~ynh2" + +maintainers = [] + +[upstream] +license = "GPL-3.0-or-later" +code = "https://github.com/YunoHost/yunorunner" +website = "https://github.com/YunoHost/yunorunner" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = true +ldap = "not_relevant" +sso = "not_relevant" +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/ci" + + [install.init_main_permission] + type = "group" + default = "visitors" + + [install.context] + ask.en = "Leave it to 'personal-ci'. If set to 'official-infra', Yunorunner will take over your server and disable vital services to run alone." + type = "select" + choices.personal_ci = "Personal CI" + choices.official_infra = "Official infra" + default = "personal_ci" + + [install.mode] + ask.en = "Should the jobs be automatically run from the apps list? In manual mode, Yunorunner will expect to be triggered by the `ciclic` command or webhooks (like ci-apps-dev). In auto mode, all apps of the catalog will be scheduled to be tested at least once a month and upon any change in their designated main branch (like ci-apps)." + type = "select" + choices.auto = "Automatically from the catalog" + choices.manual = "Manually via ciclic or webhook" + default = "manual" + + [install.cluster] + ask.en = "Should an LXD cluster be created with this server as first node? (cluster mode is experimental)" + type = "boolean" + default = false + + [install.backend] + ask.en = "Should you use LXD or Incus (LXD support will be removed soon)" + type = "select" + choices = ["lxd", "incus"] + default = "incus" + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.ports] + main.default = 8095 + + [resources.apt] + packages = [ + "python3-venv", + "python3-dev", + "python3-pip", + "sqlite3", + "wkhtmltopdf", + "optipng", + ] diff --git a/scripts/_common.sh b/scripts/_common.sh index dd5a08b..b45be1c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="python3-venv python3-dev python3-pip sqlite3 wkhtmltopdf optipng" - yunorunner_repository="https://github.com/YunoHost/yunorunner" yunorunner_release="52ef23a2cb37cb4fe13debca58eb589bb2f4d927" @@ -15,42 +12,48 @@ yunorunner_release="52ef23a2cb37cb4fe13debca58eb589bb2f4d927" # PERSONAL HELPERS #================================================= -function tweak_yunohost() { - +tweak_yunohost() { # Idk why this is needed but wokay I guess >_> echo -e "\n127.0.0.1 $domain #CI_APP" >> /etc/hosts ynh_print_info "Disabling unecessary services to save up RAM..." - for SERVICE in mysql php7.4-fpm metronome rspamd dovecot postfix redis-server postsrsd yunohost-api avahi-daemon - do + for SERVICE in mysql php7.4-fpm metronome rspamd dovecot postfix redis-server postsrsd yunohost-api avahi-daemon; do systemctl stop $SERVICE systemctl disable $SERVICE --quiet done yunohost app makedefault -d "$domain" $app - } -function setup_lxd() { - if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "lxd")' >/dev/null - then +setup_lxd() { + if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "lxd")' >/dev/null; then ynh_script_progression --message="Installing LXD... (this make take a long time!" yunohost app install --force https://github.com/YunoHost-Apps/lxd_ynh fi - mkdir .lxd - pushd .lxd - ynh_print_info "Configuring lxd..." - if [ "$cluster" == "cluster" ] - then - local free_space=$(df --output=avail / | sed 1d) - local btrfs_size=$(( $free_space * 90 / 100 / 1024 / 1024 )) - local lxc_network=$((1 + $RANDOM % 254)) + if [ "$cluster" == "cluster" ]; then + setup_lxd + else + lxd init --auto # --storage-backend=dir + fi - yunohost firewall allow TCP 8443 - cat >./preseed.conf <"$tmpfile" <> "/etc/cron.d/yunorunner" << EOF -# self-upgrade every night -0 3 * * * root "$final_path/maintenance/self_upgrade.sh" >> "$final_path/maintenance/self_upgrade.log" 2>&1 -EOF + lxc config set core.https_address "[::]" } #================================================= @@ -130,78 +114,63 @@ EOF #================================================= ynh_maintenance_mode_ON () { - # Load value of $path_url and $domain from the config if their not set - if [ -z $path_url ]; then - path_url=$(ynh_app_setting_get $app path) - fi - if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) - fi - - # Create an html to serve as maintenance notice - echo " + # Create an html to serve as maintenance notice + cat > "/var/www/html/maintenance.$app.html" < - - -Your app $app is currently under maintenance! - - - -

Your app $app is currently under maintenance!

-

This app has been put under maintenance by your administrator at $(date)

-

Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.

+ + + Your app $app is currently under maintenance! + + + +

Your app $app is currently under maintenance!

+

This app has been put under maintenance by your administrator at $(date)

+

Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.

+ + +EOF - -" > "/var/www/html/maintenance.$app.html" - - # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. - echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice -rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect; + # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. + cat > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" < "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - - # The current config file will redirect all requests to the root of the app. - # To keep the full path, we can use the following rewrite rule: - # rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect; - # The difference will be in the $1 at the end, which keep the following queries. - # But, if it works perfectly for a html request, there's an issue with any php files. - # This files are treated as simple files, and will be downloaded by the browser. - # Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was. - - systemctl reload nginx + # The current config file will redirect all requests to the root of the app. + # To keep the full path, we can use the following rewrite rule: + # rewrite ^${path}/(.*)$ ${path}_maintenance/\$1? redirect; + # The difference will be in the $1 at the end, which keep the following queries. + # But, if it works perfectly for a html request, there's an issue with any php files. + # This files are treated as simple files, and will be downloaded by the browser. + # Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was. + systemctl reload nginx } ynh_maintenance_mode_OFF () { - # Load value of $path_url and $domain from the config if their not set - if [ -z $path_url ]; then - path_url=$(ynh_app_setting_get $app path) - fi - if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) - fi + # Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app. + echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" + systemctl reload nginx - # Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app. - echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - systemctl reload nginx + # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. + sleep 4 - # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. - sleep 4 + # Then remove the temporary files used for the maintenance. + rm "/var/www/html/maintenance.$app.html" + rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - # Then remove the temporary files used for the maintenance. - rm "/var/www/html/maintenance.$app.html" - rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - - systemctl reload nginx + systemctl reload nginx } diff --git a/scripts/backup b/scripts/backup index d72c557..1b0da06 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,26 +8,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -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) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -39,7 +17,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION @@ -55,6 +33,8 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/etc/cron.d/$app" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index d9ca583..921ae41 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,135 +7,27 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -port=$(ynh_app_setting_get --app=$app --key=port) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." - -# 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 - -#================================================= -# ACTIVATE MAINTENANCE MODE -#================================================= - -path_url=$old_path -domain=$old_domain -ynh_maintenance_mode_ON - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped YunoRunner CI" --timeout=30 +ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --line_match="Stopped YunoRunner CI" --timeout=30 #================================================= # MODIFY URL IN NGINX CONF #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +ynh_change_url_nginx_config -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - - # Store path_url setting - ynh_app_setting_set --app=$app --key=path_url --value="$path_url" - - # Create a dedicated NGINX config - ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." - -ynh_systemd_action --service_name=nginx --action=reload - -#================================================= -# DEACTIVE MAINTENANCE MODE -#================================================= - -path_url=$old_path -domain=$old_domain -ynh_maintenance_mode_OFF +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 5445d22..cf9b2a1 100644 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,116 +7,36 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -context=$YNH_APP_ARG_CONTEXT -mode=$YNH_APP_ARG_MODE -cluster=$YNH_APP_ARG_CLUSTER - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." - -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." - -# Find an available port -port=$(ynh_find_port --port=8095) -ynh_app_setting_set --app=$app --key=port --value=$port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." -ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -mkdir "$final_path" -chown $app:$app "$final_path" -pushd "$final_path" - ynh_exec_as $app git init - ynh_exec_as $app git remote add origin "$yunorunner_repository" - ynh_exec_as $app git fetch --quiet --depth=1 origin "$yunorunner_release" - ynh_exec_as $app git reset --quiet --hard FETCH_HEAD - setup_lxd - git clone https://github.com/YunoHost/package_check "./package_check" -popd +ynh_exec_as "$app" git -C "$install_dir" init +ynh_exec_as "$app" git -C "$install_dir" remote add origin "$yunorunner_repository" +ynh_exec_as "$app" git -C "$install_dir" fetch --quiet --depth=1 origin "$yunorunner_release" +ynh_exec_as "$app" git -C "$install_dir" reset --quiet --hard FETCH_HEAD +ynh_exec_as "$app" git clone https://github.com/YunoHost/package_check "$install_dir/package_check" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app "$final_path" -chown $app:www-data "$final_path" -chown -R $app:www-data "$final_path/results" +chown "$app:$app" "$install_dir" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." +setup_lxd -# Create a dedicated NGINX config -ynh_add_nginx_config +chmod -R o-rwx "$install_dir" +chown -R "$app:$app" "$install_dir" +chown "$app:www-data" "$install_dir" +chown -R "$app:www-data" "$install_dir/results" -#================================================= -# SPECIFIC SETUP #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= ynh_script_progression --message="Installing Python dependencies..." -pushd $final_path - python3 -m venv venv - venv/bin/pip install --upgrade pip - venv/bin/pip install -r requirements-frozen.txt +pushd "$install_dir" + python3 -m venv venv + venv/bin/pip install --upgrade pip + venv/bin/pip install -r requirements-frozen.txt popd #================================================= @@ -127,66 +45,46 @@ popd ynh_script_progression --message="Adding a config file..." if [ $mode = "auto" ]; then - auto="True" + auto="True" else - auto="False" + auto="False" fi -ynh_add_config --template="yunorunner.config.py" --destination="$final_path/config.py" +ynh_add_config --template="yunorunner.config.py" --destination="$install_dir/config.py" -chmod 400 "$final_path/config.py" -chown $app:$app "$final_path/config.py" +chmod 400 "$install_dir/config.py" +chown "$app:$app" "$install_dir/config.py" #================================================= # FINISH INSTALL #================================================= ynh_script_progression --message="Run Yunorunner's finish_install script..." -if [ $context != "personal-ci" ] && [ ${PACKAGE_CHECK_EXEC:-0} -ne 0 ]; then - tweak_yunohost +if [ $context != "personal-ci" ] && [ "${PACKAGE_CHECK_EXEC:-0}" -ne 0 ]; then + tweak_yunohost fi -add_cron_jobs +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." +# Create a dedicated NGINX config +ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config +yunohost service add "$app" --description="$app daemon for YunoRunner" -#================================================= -# GENERIC FINALIZATION -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description="$app daemon for YunoRunner" +ynh_add_config --template="cron" --destination="/etc/cron.d/$app" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" --timeout=30 - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." - -# Make app public -ynh_permission_update --permission="main" --add="visitors" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" --timeout=30 #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 524c878..47a0324 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,81 +8,21 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -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) - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # 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 -then - ynh_script_progression --message="Removing $app service integration..." - yunohost service remove $app +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index a51a6ae..2b5f6c4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,123 +8,53 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -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) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." - -test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " - #================================================= # ACTIVATE MAINTENANCE MODE #================================================= ynh_maintenance_mode_ON -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:$app" "$install_dir" #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= ynh_script_progression --message="Installing Python dependencies..." -pushd $final_path - python3 -m venv venv - venv/bin/pip install --upgrade pip - venv/bin/pip install -r requirements-frozen.txt +pushd "$install_dir" + python3 -m venv venv + venv/bin/pip install --upgrade pip + venv/bin/pip install -r requirements-frozen.txt popd #================================================= -# RESTORE SYSTEMD +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet +systemctl enable "$app.service" --quiet +yunohost service add "$app" --description="$app daemon for YunoRunner" + +ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= -# INTEGRATE SERVICE IN YUNOHOST +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -yunohost service add $app --description="$app daemon for YunoRunner" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" --timeout=30 - -#================================================= -# DEACTIVE MAINTENANCE MODE -#================================================= - -ynh_maintenance_mode_OFF - -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" --timeout=30 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 17a41ac..b280edf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,146 +7,60 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." - -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) -port=$(ynh_app_setting_get --app=$app --key=port) - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port" - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --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 () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # ACTIVATE MAINTENANCE MODE #================================================= ynh_maintenance_mode_ON -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped YunoRunner CI" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --line_match="Stopped YunoRunner CI" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -# If port doesn't exist, create it -if [ -z "$port" ]; then - port=4242 - ynh_app_setting_set --app=$app --key=port --value=$port +if [ ! -d "$install_dir/.git/" ]; then + ynh_exec_as "$app" git -C "$install_dir" init + git -C "$install_dir" remote add origin "$yunorunner_repository" fi -if [[ ! -d "$final_path/.git/" ]] -then - git init "$final_path" - pushd "$final_path" - git remote add origin "$yunorunner_repository" - popd -fi - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public +# Close a legacy port +if yunohost firewall list | grep -q "\- $port$"; then + ynh_exec_warn_less yunohost firewall disallow TCP "$port" fi # Remove Pythonz -ynh_secure_remove --file="$final_path/.pythonz" - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_secure_remove --file="$install_dir/.pythonz" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." +# Download, check integrity, uncompress and patch the source from app.src +pushd "$install_dir" + ynh_exec_as "$app" git fetch --quiet --depth=1 origin "$yunorunner_release" + ynh_exec_as "$app" git reset --quiet --hard FETCH_HEAD +popd - # Download, check integrity, uncompress and patch the source from app.src - pushd "$final_path" - ynh_exec_as $app git fetch --quiet --depth=1 origin "$yunorunner_release" - ynh_exec_as $app git reset --quiet --hard FETCH_HEAD - popd -fi +chmod -R o-rwx "$install_dir" +chown -R "$app:$app" "$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." - -# Create a dedicated NGINX config -ynh_add_nginx_config - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# SPECIFIC UPGRADE #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= ynh_script_progression --message="Installing Python dependencies..." -pushd $final_path - python3 -m venv venv - venv/bin/pip install --upgrade pip - venv/bin/pip install -r requirements-frozen.txt +pushd "$install_dir" + python3 -m venv venv + venv/bin/pip install --upgrade pip + venv/bin/pip install -r requirements-frozen.txt popd #================================================= @@ -156,34 +68,31 @@ popd #================================================= ynh_script_progression --message="Updating a config file..." -ynh_backup_if_checksum_is_different --file="$final_path/config.py" +ynh_backup_if_checksum_is_different --file="$install_dir/config.py" -chmod 400 "$final_path/config.py" -chown $app:$app "$final_path/config.py" +chmod 400 "$install_dir/config.py" +chown "$app:$app" "$install_dir/config.py" #================================================= -# SETUP SYSTEMD +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config +yunohost service add "$app" --description="$app daemon for YunoRunner" -#================================================= -# GENERIC FINALIZATION -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description="$app daemon for YunoRunner" +ynh_add_config --template="cron" --destination="/etc/cron.d/$app" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" --timeout=30 +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" --timeout=30 #================================================= # DEACTIVE MAINTENANCE MODE @@ -191,13 +100,6 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l ynh_maintenance_mode_OFF -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..40b75ac --- /dev/null +++ b/tests.toml @@ -0,0 +1,16 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + args.context = "personal-ci" + args.mode = "manual" + args.cluster = false + + # ------------ + # Tests to run + # ------------ + + test_upgrade_from.f0e9373aa2403bf04f84c67646ac5d34376b7959.name = "2021-03-05~ynh1" + test_upgrade_from.fea498cd83a7da12a102efe2f47397dace3cddda.name = "2021-09-22~ynh1" From 2c549fe00bf6a294a8b731eff5292736f7220b3c Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 15 Mar 2024 10:59:19 +0000 Subject: [PATCH 02/17] Auto-update README --- README.md | 14 +++++++------- README_fr.md | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index bdeab68..47ce0bc 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview CI runner of YunoHost - -**Shipped version:** 2023.04.05~ynh1 +**Shipped version:** 2023.04.05~ynh2 ## Screenshots @@ -26,9 +25,10 @@ CI runner of YunoHost ## Documentation and resources -* Upstream app code repository: -* YunoHost Store: -* Report a bug: +- Official app website: +- Upstream app code repository: +- YunoHost Store: +- Report a bug: ## Developer info @@ -36,10 +36,10 @@ Please send your pull request to the [testing branch](https://github.com/YunoHos To try the testing branch, please proceed like that. -``` bash +```bash sudo yunohost app install https://github.com/YunoHost-Apps/yunorunner_ynh/tree/testing --debug or sudo yunohost app upgrade yunorunner -u https://github.com/YunoHost-Apps/yunorunner_ynh/tree/testing --debug ``` -**More info regarding app packaging:** \ No newline at end of file +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md index 7154096..69d1651 100644 --- a/README_fr.md +++ b/README_fr.md @@ -17,8 +17,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble Runner d'intégration continue de YunoHost - -**Version incluse :** 2023.04.05~ynh1 +**Version incluse :** 2023.04.05~ynh2 ## Captures d’écran @@ -26,9 +25,10 @@ Runner d'intégration continue de YunoHost ## Documentations et ressources -* Dépôt de code officiel de l’app : -* YunoHost Store: -* Signaler un bug : +- Site officiel de l’app : +- Dépôt de code officiel de l’app : +- YunoHost Store : +- Signaler un bug : ## Informations pour les développeurs @@ -36,10 +36,10 @@ Merci de faire vos pull request sur la [branche testing](https://github.com/Yuno Pour essayer la branche testing, procédez comme suit. -``` bash +```bash sudo yunohost app install https://github.com/YunoHost-Apps/yunorunner_ynh/tree/testing --debug ou sudo yunohost app upgrade yunorunner -u https://github.com/YunoHost-Apps/yunorunner_ynh/tree/testing --debug ``` -**Plus d’infos sur le packaging d’applications :** \ No newline at end of file +**Plus d’infos sur le packaging d’applications :** From 2146effb72902a107834c2034ab776d05de1bb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 13:03:09 +0100 Subject: [PATCH 03/17] Fix argument using _ not - --- scripts/install | 2 +- scripts/upgrade | 6 ++++++ tests.toml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index cf9b2a1..86675d7 100644 --- a/scripts/install +++ b/scripts/install @@ -60,7 +60,7 @@ chown "$app:$app" "$install_dir/config.py" #================================================= ynh_script_progression --message="Run Yunorunner's finish_install script..." -if [ $context != "personal-ci" ] && [ "${PACKAGE_CHECK_EXEC:-0}" -ne 0 ]; then +if [ "$context" == "official_infra" ] && [ "${PACKAGE_CHECK_EXEC:-0}" -ne 0 ]; then tweak_yunohost fi diff --git a/scripts/upgrade b/scripts/upgrade index b280edf..33ca2f4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -35,6 +35,12 @@ if yunohost firewall list | grep -q "\- $port$"; then ynh_exec_warn_less yunohost firewall disallow TCP "$port" fi +# Values now use underscore +if echo "$context" | grep -- -; then + context=$(echo "$context" | tr - _) + ynh_app_setting_set --app="$app" --key="context" --value="$context" +fi + # Remove Pythonz ynh_secure_remove --file="$install_dir/.pythonz" diff --git a/tests.toml b/tests.toml index 40b75ac..51ba052 100644 --- a/tests.toml +++ b/tests.toml @@ -4,7 +4,7 @@ test_format = 1.0 [default] - args.context = "personal-ci" + args.context = "personal_ci" args.mode = "manual" args.cluster = false From 240403cbd34f38aa1bddfe03b78f0d5a7a8e3bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 13:10:46 +0100 Subject: [PATCH 04/17] Fix linter, fix cluster now being a boolean --- manifest.toml | 1 - scripts/_common.sh | 8 +++++++- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 12 +++++++++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/manifest.toml b/manifest.toml index eae9aac..9bd5e9a 100644 --- a/manifest.toml +++ b/manifest.toml @@ -14,7 +14,6 @@ maintainers = [] [upstream] license = "GPL-3.0-or-later" code = "https://github.com/YunoHost/yunorunner" -website = "https://github.com/YunoHost/yunorunner" [integration] yunohost = ">= 11.2" diff --git a/scripts/_common.sh b/scripts/_common.sh index b45be1c..700239b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -33,7 +33,7 @@ setup_lxd() { ynh_print_info "Configuring lxd..." - if [ "$cluster" == "cluster" ]; then + if [ "$cluster" -eq 1 ]; then setup_lxd else lxd init --auto # --storage-backend=dir @@ -45,6 +45,12 @@ setup_lxd() { ynh_exec_as "$app" lxc remote add yunohost https://devbaseimgs.yunohost.org --public --accept-certificate } +exposed_ports_if_cluster() { + if [ "$cluster" -eq 1 ]; then + echo "8443" + fi +} + setup_lxd_cluster() { local free_space=$(df --output=avail / | sed 1d) local btrfs_size=$(( free_space * 90 / 100 / 1024 / 1024 )) diff --git a/scripts/install b/scripts/install index 86675d7..8fd832c 100644 --- a/scripts/install +++ b/scripts/install @@ -74,7 +74,7 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -yunohost service add "$app" --description="$app daemon for YunoRunner" +yunohost service add "$app" --description="$app daemon for YunoRunner" --needs_exposed_ports="$(exposed_ports_if_cluster)" ynh_add_config --template="cron" --destination="/etc/cron.d/$app" diff --git a/scripts/restore b/scripts/restore index 2b5f6c4..9c080e0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -45,7 +45,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet -yunohost service add "$app" --description="$app daemon for YunoRunner" +yunohost service add "$app" --description="$app daemon for YunoRunner" --needs_exposed_ports="$(exposed_ports_if_cluster)" ynh_restore_file --origin_path="/etc/cron.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 33ca2f4..1405fec 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -41,6 +41,16 @@ if echo "$context" | grep -- -; then ynh_app_setting_set --app="$app" --key="context" --value="$context" fi +# cluster is now a boolean +if [[ "$cluster" == "cluster" ]] || [[ "$cluster" == "no" ]]; then + if [[ "$cluster" == "cluster" ]]; then + cluster=1 + else + cluster=0 + fi + ynh_app_setting_set --app="$app" --key="cluster" --value="$cluster" +fi + # Remove Pythonz ynh_secure_remove --file="$install_dir/.pythonz" @@ -89,7 +99,7 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -yunohost service add "$app" --description="$app daemon for YunoRunner" +yunohost service add "$app" --description="$app daemon for YunoRunner" --needs_exposed_ports="$(exposed_ports_if_cluster)" ynh_add_config --template="cron" --destination="/etc/cron.d/$app" From 4afb8c2ff4081faf17648f25e302eb8f75bb5a78 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 15 Mar 2024 12:10:52 +0000 Subject: [PATCH 05/17] Auto-update README --- README.md | 1 - README_fr.md | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index 47ce0bc..3217293 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ CI runner of YunoHost ## Documentation and resources -- Official app website: - Upstream app code repository: - YunoHost Store: - Report a bug: diff --git a/README_fr.md b/README_fr.md index 69d1651..7ca25ad 100644 --- a/README_fr.md +++ b/README_fr.md @@ -25,7 +25,6 @@ Runner d'intégration continue de YunoHost ## Documentations et ressources -- Site officiel de l’app : - Dépôt de code officiel de l’app : - YunoHost Store : - Signaler un bug : From 6d27163e0264572fe2442a0118c96165fb77ed3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 13:12:26 +0100 Subject: [PATCH 06/17] Move install lxd outside common.sh --- scripts/_common.sh | 5 ----- scripts/install | 9 +++++++++ scripts/restore | 9 +++++++++ scripts/upgrade | 9 +++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 700239b..6b08913 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -26,11 +26,6 @@ tweak_yunohost() { } setup_lxd() { - if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "lxd")' >/dev/null; then - ynh_script_progression --message="Installing LXD... (this make take a long time!" - yunohost app install --force https://github.com/YunoHost-Apps/lxd_ynh - fi - ynh_print_info "Configuring lxd..." if [ "$cluster" -eq 1 ]; then diff --git a/scripts/install b/scripts/install index 8fd832c..ca837ac 100644 --- a/scripts/install +++ b/scripts/install @@ -7,6 +7,15 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INSTALL LXD +#================================================= +ynh_script_progression --message="Installing LXD... (this make take a long time!)" + +if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "lxd")' >/dev/null; then + yunohost app install --force https://github.com/YunoHost-Apps/lxd_ynh +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= diff --git a/scripts/restore b/scripts/restore index 9c080e0..e39b5eb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,6 +14,15 @@ source /usr/share/yunohost/helpers ynh_maintenance_mode_ON +#================================================= +# INSTALL LXD +#================================================= +ynh_script_progression --message="Installing LXD... (this make take a long time!)" + +if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "lxd")' >/dev/null; then + yunohost app install --force https://github.com/YunoHost-Apps/lxd_ynh +fi + #================================================= # RESTORE THE APP MAIN DIR #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 1405fec..fdcf795 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -13,6 +13,15 @@ source /usr/share/yunohost/helpers ynh_maintenance_mode_ON +#================================================= +# INSTALL LXD +#================================================= +ynh_script_progression --message="Installing LXD... (this make take a long time!)" + +if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "lxd")' >/dev/null; then + yunohost app install --force https://github.com/YunoHost-Apps/lxd_ynh +fi + #================================================= # STOP SYSTEMD SERVICE #================================================= From 2f3fc40f8c56b8acf5f6e7d25dd5b0f677c61acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 13:13:48 +0100 Subject: [PATCH 07/17] Add description.md --- doc/DESCRIPTION.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/DESCRIPTION.md diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..ec06d8e --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1,3 @@ +Yunorunner is a CI server for YunoHost apps. + +It is based on LXD/LXC and uses [package_check](https://github.com/YunoHost/package_check). From f4296f094a4169ef638a0a4726083dad20c0473c Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 15 Mar 2024 12:13:54 +0000 Subject: [PATCH 08/17] Auto-update README --- README.md | 5 ++++- README_fr.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3217293..a1af2d2 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,10 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -CI runner of YunoHost +Yunorunner is a CI server for YunoHost apps. + +It is based on LXD/LXC and uses [package_check](https://github.com/YunoHost/package_check). + **Shipped version:** 2023.04.05~ynh2 ## Screenshots diff --git a/README_fr.md b/README_fr.md index 7ca25ad..efbb4e2 100644 --- a/README_fr.md +++ b/README_fr.md @@ -16,7 +16,10 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble -Runner d'intégration continue de YunoHost +Yunorunner is a CI server for YunoHost apps. + +It is based on LXD/LXC and uses [package_check](https://github.com/YunoHost/package_check). + **Version incluse :** 2023.04.05~ynh2 ## Captures d’écran From a7b6a5b94682efe885a0ec102b2bfb63cb3c5dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 13:15:59 +0100 Subject: [PATCH 09/17] Add init branch at git init --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index ca837ac..a9c81ca 100644 --- a/scripts/install +++ b/scripts/install @@ -22,7 +22,7 @@ fi ynh_script_progression --message="Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_exec_as "$app" git -C "$install_dir" init +ynh_exec_as "$app" git -C "$install_dir" init -b main ynh_exec_as "$app" git -C "$install_dir" remote add origin "$yunorunner_repository" ynh_exec_as "$app" git -C "$install_dir" fetch --quiet --depth=1 origin "$yunorunner_release" ynh_exec_as "$app" git -C "$install_dir" reset --quiet --hard FETCH_HEAD diff --git a/scripts/upgrade b/scripts/upgrade index fdcf795..4316ac6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -35,7 +35,7 @@ ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" -- ynh_script_progression --message="Ensuring downward compatibility..." if [ ! -d "$install_dir/.git/" ]; then - ynh_exec_as "$app" git -C "$install_dir" init + ynh_exec_as "$app" git -C "$install_dir" init -b main git -C "$install_dir" remote add origin "$yunorunner_repository" fi From a2851e14a3215d62c79d171b054c024dbd33252d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 13:30:40 +0100 Subject: [PATCH 10/17] fix needs exposed ports --- scripts/_common.sh | 2 +- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 6b08913..e362c27 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -42,7 +42,7 @@ setup_lxd() { exposed_ports_if_cluster() { if [ "$cluster" -eq 1 ]; then - echo "8443" + echo "--needs_exposed_ports=8443" fi } diff --git a/scripts/install b/scripts/install index a9c81ca..8ef9750 100644 --- a/scripts/install +++ b/scripts/install @@ -83,7 +83,7 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -yunohost service add "$app" --description="$app daemon for YunoRunner" --needs_exposed_ports="$(exposed_ports_if_cluster)" +yunohost service add "$app" --description="$app daemon for YunoRunner" "$(exposed_ports_if_cluster)" ynh_add_config --template="cron" --destination="/etc/cron.d/$app" diff --git a/scripts/restore b/scripts/restore index e39b5eb..da6f121 100644 --- a/scripts/restore +++ b/scripts/restore @@ -54,7 +54,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet -yunohost service add "$app" --description="$app daemon for YunoRunner" --needs_exposed_ports="$(exposed_ports_if_cluster)" +yunohost service add "$app" --description="$app daemon for YunoRunner" "$(exposed_ports_if_cluster)" ynh_restore_file --origin_path="/etc/cron.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 4316ac6..f84551c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -108,7 +108,7 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -yunohost service add "$app" --description="$app daemon for YunoRunner" --needs_exposed_ports="$(exposed_ports_if_cluster)" +yunohost service add "$app" --description="$app daemon for YunoRunner" "$(exposed_ports_if_cluster)" ynh_add_config --template="cron" --destination="/etc/cron.d/$app" From e937e5037e667483ea14c1db33ee27900a333fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 13:44:10 +0100 Subject: [PATCH 11/17] Fix again argument exposed port --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 8ef9750..521ed11 100644 --- a/scripts/install +++ b/scripts/install @@ -83,7 +83,7 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -yunohost service add "$app" --description="$app daemon for YunoRunner" "$(exposed_ports_if_cluster)" +yunohost service add "$app" --description="$app daemon for YunoRunner" $(exposed_ports_if_cluster) ynh_add_config --template="cron" --destination="/etc/cron.d/$app" diff --git a/scripts/restore b/scripts/restore index da6f121..41c6cae 100644 --- a/scripts/restore +++ b/scripts/restore @@ -54,7 +54,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet -yunohost service add "$app" --description="$app daemon for YunoRunner" "$(exposed_ports_if_cluster)" +yunohost service add "$app" --description="$app daemon for YunoRunner" $(exposed_ports_if_cluster) ynh_restore_file --origin_path="/etc/cron.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index f84551c..eef0851 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -108,7 +108,7 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -yunohost service add "$app" --description="$app daemon for YunoRunner" "$(exposed_ports_if_cluster)" +yunohost service add "$app" --description="$app daemon for YunoRunner" $(exposed_ports_if_cluster) ynh_add_config --template="cron" --destination="/etc/cron.d/$app" From ea04b4c63c5af31f02d919da3155970d546bc595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 13:54:06 +0100 Subject: [PATCH 12/17] Fix post_install doc --- doc/POST_INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index 074585b..33d21fd 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -1,6 +1,6 @@ If you want to enable Matrix notification, you should look at -the instructions inside `__FINAL_PATH__lib/chat_notify.sh` to deploy matrix-commander. +the instructions inside `__INSTALL_DIR__/lib/chat_notify.sh` to deploy matrix-commander. -You may also want to tweak the `__FINAL_PATH__/config.py` file to run test with a different branch or architecture. +You may also want to tweak the `__INSTALL_DIR__/config.py` file to run test with a different branch or architecture. When you're ready to start the CI, restart its service via the webadmin or run `systemctl restart __APP__`. From 0456e52e217b2c0f5e57d0598fc712116431dcde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 14:34:01 +0100 Subject: [PATCH 13/17] Fix upgrade from old version --- scripts/upgrade | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index eef0851..d4c8305 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -44,6 +44,24 @@ if yunohost firewall list | grep -q "\- $port$"; then ynh_exec_warn_less yunohost firewall disallow TCP "$port" fi +if [[ -z "$context" ]]; then + if grep -q "CI_APP" /etc/hosts; then + context=official_infra + else + context=personal_ci + fi + ynh_app_setting_set --app="$app" --key="context" --value="$context" +fi + +if [[ -z "$cluster" ]]; then + if incus cluster list >/dev/null 2>&1; then + cluster=1 + else + cluster=0 + fi + ynh_app_setting_set --app="$app" --key="cluster" --value="$cluster" +fi + # Values now use underscore if echo "$context" | grep -- -; then context=$(echo "$context" | tr - _) From da9ee94a384d20aa9d483909e193799db1a61280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 14:35:00 +0100 Subject: [PATCH 14/17] Remove broken test_upgrade_from --- tests.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests.toml b/tests.toml index 51ba052..65b942b 100644 --- a/tests.toml +++ b/tests.toml @@ -12,5 +12,4 @@ test_format = 1.0 # Tests to run # ------------ - test_upgrade_from.f0e9373aa2403bf04f84c67646ac5d34376b7959.name = "2021-03-05~ynh1" test_upgrade_from.fea498cd83a7da12a102efe2f47397dace3cddda.name = "2021-09-22~ynh1" From 02153981ee8ceea2b819913876a184898489eb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 14:35:31 +0100 Subject: [PATCH 15/17] Fix missing variable in upgrade --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index d4c8305..66bfe5b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -44,7 +44,7 @@ if yunohost firewall list | grep -q "\- $port$"; then ynh_exec_warn_less yunohost firewall disallow TCP "$port" fi -if [[ -z "$context" ]]; then +if [[ -z "${context:-}" ]]; then if grep -q "CI_APP" /etc/hosts; then context=official_infra else @@ -53,7 +53,7 @@ if [[ -z "$context" ]]; then ynh_app_setting_set --app="$app" --key="context" --value="$context" fi -if [[ -z "$cluster" ]]; then +if [[ -z "${cluster:-}" ]]; then if incus cluster list >/dev/null 2>&1; then cluster=1 else From 0cdad2a23dd6af631dd58bde814d31c4d6d6ba8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 14:45:06 +0100 Subject: [PATCH 16/17] Fix missing lxd key --- manifest.toml | 4 ++-- scripts/upgrade | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/manifest.toml b/manifest.toml index 9bd5e9a..9f2bde0 100644 --- a/manifest.toml +++ b/manifest.toml @@ -59,8 +59,8 @@ ram.runtime = "50M" [install.backend] ask.en = "Should you use LXD or Incus (LXD support will be removed soon)" type = "select" - choices = ["lxd", "incus"] - default = "incus" + choices = ["lxd"] + default = "lxd" [resources] [resources.system_user] diff --git a/scripts/upgrade b/scripts/upgrade index 66bfe5b..56128bb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -54,7 +54,7 @@ if [[ -z "${context:-}" ]]; then fi if [[ -z "${cluster:-}" ]]; then - if incus cluster list >/dev/null 2>&1; then + if lxc cluster list >/dev/null 2>&1; then cluster=1 else cluster=0 @@ -62,6 +62,11 @@ if [[ -z "${cluster:-}" ]]; then ynh_app_setting_set --app="$app" --key="cluster" --value="$cluster" fi +if [[ -z "${backend:-}" ]]; then + backend=lxd + ynh_app_setting_set --app="$app" --key="lxd" --value="$lxd" +fi + # Values now use underscore if echo "$context" | grep -- -; then context=$(echo "$context" | tr - _) From 5e2b97073d019531afa5cf31df878411a1a0786a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Mar 2024 14:46:30 +0100 Subject: [PATCH 17/17] Oops --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 56128bb..61ca3b7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -64,7 +64,7 @@ fi if [[ -z "${backend:-}" ]]; then backend=lxd - ynh_app_setting_set --app="$app" --key="lxd" --value="$lxd" + ynh_app_setting_set --app="$app" --key="backend" --value="$backend" fi # Values now use underscore