From c851f73ed0d24584588ee732ed1ebccd4866fad9 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 17 Jan 2023 15:56:39 +0100 Subject: [PATCH] Fixes from the battlefield --- .gitignore | 3 +++ analyze_yunohost_app.sh | 6 +++--- maintenance/finish_install.sh | 31 +++++++++++++++++-------------- run.py | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index fd08516..c23dc49 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ __pycache__ results/* .admin_token package_check +config.py +venv/ +.lxd/ diff --git a/analyze_yunohost_app.sh b/analyze_yunohost_app.sh index 685310c..28d0f63 100755 --- a/analyze_yunohost_app.sh +++ b/analyze_yunohost_app.sh @@ -19,10 +19,10 @@ lock_package_check="./package_check/pcheck-${worker_id}.lock" # 10800 sec / 60 = 180 min = 3 hours TIMEOUT="10800" -BASE_URL="$(cat "./config.py" | tr -d ' ' | grep "^BASE_URL=" | cut --delimiter="=" --fields=2)" -ynh_branch="$(cat "./config.py" | tr -d ' ' | grep "^YNH_BRANCH=" | cut --delimiter="=" --fields=2)" +BASE_URL="$(cat "./config.py" | tr -d ' "' | grep "^BASE_URL=" | cut --delimiter="=" --fields=2)" +ynh_branch="$(cat "./config.py" | tr -d ' "' | grep "^YNH_BRANCH=" | cut --delimiter="=" --fields=2)" arch="$(dpkg --print-architecture)" -dist="$(cat "./config.py" | tr -d ' ' | grep "^DIST=" | cut --delimiter="=" --fields=2)" +dist="$(cat "./config.py" | tr -d ' "' | grep "^DIST=" | cut --delimiter="=" --fields=2)" # Enable chat notifications only on main CI if [[ "$ynh_branch" == "stable" ]] && [[ "$arch" == "amd64" ]] && [[ -e "./maintenance/chat_notify.sh" ]] diff --git a/maintenance/finish_install.sh b/maintenance/finish_install.sh index e3457ca..c521a4c 100755 --- a/maintenance/finish_install.sh +++ b/maintenance/finish_install.sh @@ -1,7 +1,5 @@ #!/bin/bash -cd "$(dirname $(realpath $0))" - if (( $# < 1 )) then cat << EOF @@ -26,8 +24,8 @@ then exit 1 fi -ci_type=$3 -lxd_cluster=$4 +ci_type=$1 +lxd_cluster=$2 # User which execute the CI software. ci_user=yunorunner @@ -88,7 +86,7 @@ function tweak_yunorunner() { # For automatic / "main" CI we want to auto schedule jobs using the app list if [ $ci_type == "auto" ] then - cat >/var/www/yunorunner/config.py <$YUNORUNNER_HOME/config.py </var/www/yunorunner/config.py <$YUNORUNNER_HOME/config.py < Configuring lxd..." if [ "$lxd_cluster" == "cluster" ] @@ -192,6 +190,8 @@ EOF lxd init --auto --storage-backend=dir fi + popd + # ci_user will be the one launching job, gives it permission to run lxd commands usermod -a -G lxd $ci_user @@ -222,7 +222,6 @@ EOF # Main stuff # ========================= -#git clone https://github.com/YunoHost/package_check "./package_check" #install_dependencies [ -e /usr/bin/yunohost ] || { echo "YunoHost is not installed"; exit; } @@ -230,9 +229,13 @@ EOF tweak_yunohost tweak_yunorunner +git clone https://github.com/YunoHost/package_check "./package_check" setup_lxd add_cron_jobs +# Add permission to the user for the entire yunorunner home because it'll be the one running the tests (as a non-root user) +chown -R $ci_user $YUNORUNNER_HOME + echo "Done!" echo " " echo "N.B. : If you want to enable Matrix notification, you should look at " diff --git a/run.py b/run.py index 67cfae8..e224ad4 100644 --- a/run.py +++ b/run.py @@ -784,7 +784,7 @@ def require_token(): token = request.headers["X-Token"].strip() - if not await hmac.compare_digest(token, admin_token): + if not hmac.compare_digest(token, admin_token): api_logger.warning("someone tried to access the API using an invalid admin token") return response.json({'status': 'invalid token'}, 403)