1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yunorunner_ynh.git synced 2024-09-03 20:36:13 +02:00

Manifest v2

This commit is contained in:
Salamandar 2024-03-15 11:59:13 +01:00
parent 93ca4425c5
commit 61fabf77a7
17 changed files with 282 additions and 886 deletions

View file

@ -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

View file

@ -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 <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
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

View file

@ -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

2
conf/cron Normal file
View file

@ -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

View file

@ -11,13 +11,13 @@ location __PATH__/ {
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
location __PATH__/logs { location __PATH__/logs {
alias __FINALPATH__/results/logs/; alias __INSTALL_DIR__/results/logs/;
autoindex on; autoindex on;
default_type "text/plain"; default_type "text/plain";
} }
location __PATH__/summary/ { location __PATH__/summary/ {
alias __FINALPATH__/results/summary/; alias __INSTALL_DIR__/results/summary/;
autoindex on; autoindex on;
etag off; etag off;
more_set_headers "Cache-control: max-age=300, s-maxage=300"; more_set_headers "Cache-control: max-age=300, s-maxage=300";

View file

@ -7,8 +7,9 @@ Type=simple
Restart=always Restart=always
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/venv/bin/python ./run.py ExecStart=__INSTALL_DIR__/venv/bin/python ./run.py
Environment=YNHDEV_BACKEND=__BACKEND__
# Sandboxing options to harden security # Sandboxing options to harden security
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html

View file

@ -1,6 +1,8 @@
#!/usr/bin/env python3
BASE_URL = "https://__DOMAIN____PATH__" BASE_URL = "https://__DOMAIN____PATH__"
PORT = __PORT__ PORT = __PORT__
PACKAGE_CHECK_DIR = "__FINALPATH__/package_check/" PACKAGE_CHECK_DIR = "__INSTALL_DIR__/package_check/"
MONITOR_APPS_LIST = __AUTO__ MONITOR_APPS_LIST = __AUTO__
MONITOR_GIT = __AUTO__ MONITOR_GIT = __AUTO__
MONITOR_ONLY_GOOD_QUALITY_APPS = False MONITOR_ONLY_GOOD_QUALITY_APPS = False

View file

@ -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)"
}
}
]
}
}

85
manifest.toml Normal file
View file

@ -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",
]

View file

@ -4,9 +4,6 @@
# COMMON VARIABLES # 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_repository="https://github.com/YunoHost/yunorunner"
yunorunner_release="52ef23a2cb37cb4fe13debca58eb589bb2f4d927" yunorunner_release="52ef23a2cb37cb4fe13debca58eb589bb2f4d927"
@ -15,42 +12,48 @@ yunorunner_release="52ef23a2cb37cb4fe13debca58eb589bb2f4d927"
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
function tweak_yunohost() { tweak_yunohost() {
# Idk why this is needed but wokay I guess >_> # Idk why this is needed but wokay I guess >_>
echo -e "\n127.0.0.1 $domain #CI_APP" >> /etc/hosts echo -e "\n127.0.0.1 $domain #CI_APP" >> /etc/hosts
ynh_print_info "Disabling unecessary services to save up RAM..." 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 for SERVICE in mysql php7.4-fpm metronome rspamd dovecot postfix redis-server postsrsd yunohost-api avahi-daemon; do
do
systemctl stop $SERVICE systemctl stop $SERVICE
systemctl disable $SERVICE --quiet systemctl disable $SERVICE --quiet
done done
yunohost app makedefault -d "$domain" $app yunohost app makedefault -d "$domain" $app
} }
function setup_lxd() { setup_lxd() {
if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "lxd")' >/dev/null if ! yunohost app list --output-as json --quiet | jq -e '.apps[] | select(.id == "lxd")' >/dev/null; then
then
ynh_script_progression --message="Installing LXD... (this make take a long time!" ynh_script_progression --message="Installing LXD... (this make take a long time!"
yunohost app install --force https://github.com/YunoHost-Apps/lxd_ynh yunohost app install --force https://github.com/YunoHost-Apps/lxd_ynh
fi fi
mkdir .lxd
pushd .lxd
ynh_print_info "Configuring lxd..." ynh_print_info "Configuring lxd..."
if [ "$cluster" == "cluster" ] if [ "$cluster" == "cluster" ]; then
then setup_lxd
local free_space=$(df --output=avail / | sed 1d) else
local btrfs_size=$(( $free_space * 90 / 100 / 1024 / 1024 )) lxd init --auto # --storage-backend=dir
local lxc_network=$((1 + $RANDOM % 254)) fi
yunohost firewall allow TCP 8443 # ci_user will be the one launching job, gives it permission to run lxd commands
cat >./preseed.conf <<EOF usermod -a -G lxd "$app"
ynh_exec_as "$app" lxc remote add yunohost https://devbaseimgs.yunohost.org --public --accept-certificate
}
setup_lxd_cluster() {
local free_space=$(df --output=avail / | sed 1d)
local btrfs_size=$(( free_space * 90 / 100 / 1024 / 1024 ))
local lxc_network=$((1 + RANDOM % 254))
yunohost firewall allow TCP 8443
tmpfile=$(mktemp --suffix=.preseed.yml)
cat >"$tmpfile" <<EOF
config: config:
cluster.https_address: $domain:8443 cluster.https_address: $domain:8443
core.https_address: ${domain}:8443 core.https_address: ${domain}:8443
@ -96,29 +99,10 @@ cluster:
server_name: ${domain} server_name: ${domain}
enabled: true enabled: true
EOF EOF
cat ./preseed.conf | lxd init --preseed lxd init --preseed < "$tmpfile"
rm ./preseed.conf rm "$tmpfile"
lxc config set core.https_address [::]
else
lxd init --auto #--storage-backend=dir
fi
popd lxc config set core.https_address "[::]"
# ci_user will be the one launching job, gives it permission to run lxd commands
usermod -a -G lxd $app
ynh_exec_as $app lxc remote add yunohost https://devbaseimgs.yunohost.org --public --accept-certificate
}
function add_cron_jobs() {
ynh_script_progression --message="Configuring the cron jobs.."
# Cron tasks
cat >> "/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
} }
#================================================= #=================================================
@ -130,78 +114,63 @@ EOF
#================================================= #=================================================
ynh_maintenance_mode_ON () { ynh_maintenance_mode_ON () {
# Load value of $path_url and $domain from the config if their not set # Create an html to serve as maintenance notice
if [ -z $path_url ]; then cat > "/var/www/html/maintenance.$app.html" <<EOF
path_url=$(ynh_app_setting_get $app path) <!DOCTYPE html>
fi
if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain)
fi
# Create an html to serve as maintenance notice
echo "<!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="refresh" content="3"> <meta http-equiv="refresh" content="3">
<title>Your app $app is currently under maintenance!</title> <title>Your app $app is currently under maintenance!</title>
<style> <style>
body { body {
width: 70em; width: 70em;
margin: 0 auto; margin: 0 auto;
} }
</style> </style>
</head> </head>
<body> <body>
<h1>Your app $app is currently under maintenance!</h1> <h1>Your app $app is currently under maintenance!</h1>
<p>This app has been put under maintenance by your administrator at $(date)</p> <p>This app has been put under maintenance by your administrator at $(date)</p>
<p>Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.</p> <p>Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.</p>
</body>
</html>
EOF
</body> # Create a new nginx config file to redirect all access to the app to the maintenance notice instead.
</html>" > "/var/www/html/maintenance.$app.html" cat > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" <<EOF
# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice
# Create a new nginx config file to redirect all access to the app to the maintenance notice instead. rewrite ^${path}/(.*)$ ${path}_maintenance/? redirect;
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;
# Use another location, to not be in conflict with the original config file # Use another location, to not be in conflict with the original config file
location ${path_url}_maintenance/ { location ${path}_maintenance/ {
alias /var/www/html/ ; alias /var/www/html/ ;
try_files maintenance.$app.html =503;
try_files maintenance.$app.html =503; # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
EOF
# Include SSOWAT user panel. # The current config file will redirect all requests to the root of the app.
include conf.d/yunohost_panel.conf.inc; # To keep the full path, we can use the following rewrite rule:
}" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" # rewrite ^${path}/(.*)$ ${path}_maintenance/\$1? redirect;
# The difference will be in the $1 at the end, which keep the following queries.
# The current config file will redirect all requests to the root of the app. # But, if it works perfectly for a html request, there's an issue with any php files.
# To keep the full path, we can use the following rewrite rule: # This files are treated as simple files, and will be downloaded by the browser.
# rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect; # 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.
# The difference will be in the $1 at the end, which keep the following queries. systemctl reload nginx
# 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 () { ynh_maintenance_mode_OFF () {
# Load value of $path_url and $domain from the config if their not set # Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app.
if [ -z $path_url ]; then echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
path_url=$(ynh_app_setting_get $app path) systemctl reload nginx
fi
if [ -z $domain ]; then
domain=$(ynh_app_setting_get $app domain)
fi
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app. # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app.
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" sleep 4
systemctl reload nginx
# Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. # Then remove the temporary files used for the maintenance.
sleep 4 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. systemctl reload nginx
rm "/var/www/html/maintenance.$app.html"
rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
systemctl reload nginx
} }

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -10,26 +8,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers 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 # 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 # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # 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/systemd/system/$app.service"
ynh_backup --src_path="/etc/cron.d/$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC STARTING
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -9,135 +7,27 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers 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 # 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 # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." 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 # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting $app's systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" 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
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -9,116 +7,36 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers 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 # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." 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 # Download, check integrity, uncompress and patch the source from app.src
mkdir "$final_path" ynh_exec_as "$app" git -C "$install_dir" init
chown $app:$app "$final_path" ynh_exec_as "$app" git -C "$install_dir" remote add origin "$yunorunner_repository"
pushd "$final_path" ynh_exec_as "$app" git -C "$install_dir" fetch --quiet --depth=1 origin "$yunorunner_release"
ynh_exec_as $app git init ynh_exec_as "$app" git -C "$install_dir" reset --quiet --hard FETCH_HEAD
ynh_exec_as $app git remote add origin "$yunorunner_repository" ynh_exec_as "$app" git clone https://github.com/YunoHost/package_check "$install_dir/package_check"
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
chmod 750 "$final_path" chown "$app:$app" "$install_dir"
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"
#================================================= setup_lxd
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config chmod -R o-rwx "$install_dir"
ynh_add_nginx_config 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 # INSTALL PYTHON DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing Python dependencies..." ynh_script_progression --message="Installing Python dependencies..."
pushd $final_path pushd "$install_dir"
python3 -m venv venv python3 -m venv venv
venv/bin/pip install --upgrade pip venv/bin/pip install --upgrade pip
venv/bin/pip install -r requirements-frozen.txt venv/bin/pip install -r requirements-frozen.txt
popd popd
#================================================= #=================================================
@ -127,66 +45,46 @@ popd
ynh_script_progression --message="Adding a config file..." ynh_script_progression --message="Adding a config file..."
if [ $mode = "auto" ]; then if [ $mode = "auto" ]; then
auto="True" auto="True"
else else
auto="False" auto="False"
fi 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" chmod 400 "$install_dir/config.py"
chown $app:$app "$final_path/config.py" chown "$app:$app" "$install_dir/config.py"
#================================================= #=================================================
# FINISH INSTALL # FINISH INSTALL
#================================================= #=================================================
ynh_script_progression --message="Run Yunorunner's finish_install script..." ynh_script_progression --message="Run Yunorunner's finish_install script..."
if [ $context != "personal-ci" ] && [ ${PACKAGE_CHECK_EXEC:-0} -ne 0 ]; then if [ $context != "personal-ci" ] && [ "${PACKAGE_CHECK_EXEC:-0}" -ne 0 ]; then
tweak_yunohost tweak_yunohost
fi fi
add_cron_jobs #=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
#================================================= # Create a dedicated NGINX config
# SETUP SYSTEMD ynh_add_nginx_config
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
yunohost service add "$app" --description="$app daemon for YunoRunner"
#================================================= ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app daemon for YunoRunner"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting $app's systemd service..."
# Start a systemd service # Start a 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
#=================================================
# 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
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -10,81 +8,21 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # REMOVE SYSTEM CONFIGURATIONS
#=================================================
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
#================================================= #=================================================
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`) # 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
then yunohost service remove "$app"
ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app
fi fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_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 # Remove the dedicated NGINX config
ynh_remove_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 # END OF SCRIPT
#================================================= #=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -10,123 +8,53 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers 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 # ACTIVATE MAINTENANCE MODE
#================================================= #=================================================
ynh_maintenance_mode_ON 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 # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." 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 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:$app "$final_path" chown -R "$app:$app" "$install_dir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# INSTALL PYTHON DEPENDENCIES # INSTALL PYTHON DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing Python dependencies..." ynh_script_progression --message="Installing Python dependencies..."
pushd $final_path pushd "$install_dir"
python3 -m venv venv python3 -m venv venv
venv/bin/pip install --upgrade pip venv/bin/pip install --upgrade pip
venv/bin/pip install -r requirements-frozen.txt venv/bin/pip install -r requirements-frozen.txt
popd 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" 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" ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Started YunoRunner CI" --timeout=30
#=================================================
# 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=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -9,146 +7,60 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers 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 # ACTIVATE MAINTENANCE MODE
#================================================= #=================================================
ynh_maintenance_mode_ON ynh_maintenance_mode_ON
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# STOP SYSTEMD SERVICE # 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 # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..."
# If port doesn't exist, create it if [ ! -d "$install_dir/.git/" ]; then
if [ -z "$port" ]; then ynh_exec_as "$app" git -C "$install_dir" init
port=4242 git -C "$install_dir" remote add origin "$yunorunner_repository"
ynh_app_setting_set --app=$app --key=port --value=$port
fi fi
if [[ ! -d "$final_path/.git/" ]] # Close a legacy port
then if yunohost firewall list | grep -q "\- $port$"; then
git init "$final_path" ynh_exec_warn_less yunohost firewall disallow TCP "$port"
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
fi fi
# Remove Pythonz # Remove Pythonz
ynh_secure_remove --file="$final_path/.pythonz" ynh_secure_remove --file="$install_dir/.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
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Upgrading source files..."
if [ "$upgrade_type" == "UPGRADE_APP" ] # Download, check integrity, uncompress and patch the source from app.src
then pushd "$install_dir"
ynh_script_progression --message="Upgrading source files..." 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 chmod -R o-rwx "$install_dir"
pushd "$final_path" chown -R "$app:$app" "$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
fi
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 # INSTALL PYTHON DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing Python dependencies..." ynh_script_progression --message="Installing Python dependencies..."
pushd $final_path pushd "$install_dir"
python3 -m venv venv python3 -m venv venv
venv/bin/pip install --upgrade pip venv/bin/pip install --upgrade pip
venv/bin/pip install -r requirements-frozen.txt venv/bin/pip install -r requirements-frozen.txt
popd popd
#================================================= #=================================================
@ -156,34 +68,31 @@ popd
#================================================= #=================================================
ynh_script_progression --message="Updating a config file..." 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" chmod 400 "$install_dir/config.py"
chown $app:$app "$final_path/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 # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
yunohost service add "$app" --description="$app daemon for YunoRunner"
#================================================= ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app daemon for YunoRunner"
#================================================= #=================================================
# START SYSTEMD SERVICE # 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 # DEACTIVE MAINTENANCE MODE
@ -191,13 +100,6 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l
ynh_maintenance_mode_OFF 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 # END OF SCRIPT
#================================================= #=================================================

16
tests.toml Normal file
View file

@ -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"