Merge pull request 'fix: LXC leftovers from the runner may belong to root' (#297) from earl-warren/setup-forgejo:wip-cleanup into main

Reviewed-on: https://code.forgejo.org/actions/setup-forgejo/pulls/297
This commit is contained in:
earl-warren 2025-01-28 20:57:14 +00:00
commit f1a77d50d5
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: F128CBE6AB3A7201
2 changed files with 8 additions and 1 deletions

View file

@ -5,6 +5,12 @@ set -e
export DEBIAN_FRONTEND=noninteractive
function maybe_sudo() {
if test $(id -u) != 0; then
SUDO=sudo
fi
}
: ${RETRY_DELAYS:=1 1 5 5 15 30}
function retry() {

View file

@ -76,7 +76,8 @@ function setup() {
function teardown() {
stop_daemon forgejo-runner $DIR
if test -f $DIR/forgejo-runner-home; then
rm -fr $(cat $DIR/forgejo-runner-home)
maybe_sudo
$SUDO rm -fr $(cat $DIR/forgejo-runner-home)
fi
}