From 73783100681b41a043454fbc29a18c922b127c31 Mon Sep 17 00:00:00 2001 From: cascading-pr Date: Sun, 5 Nov 2023 16:18:53 +0000 Subject: [PATCH] [FORGEJO] upgrade lxc-heplers to be k8s capable cascading-pr from https://code.forgejo.org/forgejo/lxc-helpers/pulls/4 Co-authored-by: cascading-pr Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/16 Co-authored-by: cascading-pr Co-committed-by: cascading-pr --- pkg/runner/lxc-helpers-lib.sh | 145 +++++++++++++++++++++++++++++----- pkg/runner/lxc-helpers.sh | 27 ++++++- 2 files changed, 150 insertions(+), 22 deletions(-) diff --git a/pkg/runner/lxc-helpers-lib.sh b/pkg/runner/lxc-helpers-lib.sh index faaae90..2cc8612 100755 --- a/pkg/runner/lxc-helpers-lib.sh +++ b/pkg/runner/lxc-helpers-lib.sh @@ -5,9 +5,12 @@ export DEBIAN_FRONTEND=noninteractive LXC_SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" LXC_BIN=/usr/local/bin +LXC_CONTAINER_CONFIG_ALL="unprivileged lxc libvirt docker k8s" +LXC_CONTAINER_CONFIG_DEFAULT="lxc libvirt docker" : ${LXC_SUDO:=} : ${LXC_CONTAINER_RELEASE:=bookworm} +: ${LXC_CONTAINER_CONFIG:=$LXC_CONTAINER_CONFIG_DEFAULT} : ${LXC_HOME:=/home} : ${LXC_VERBOSE:=false} @@ -94,7 +97,7 @@ EOF function lxc_maybe_sudo() { if test $(id -u) != 0 ; then - LXC_SUDO=sudo + LXC_SUDO=sudo fi } @@ -105,42 +108,138 @@ function lxc_prepare_environment() { fi } -function lxc_container_configure() { - local name="$1" - - $LXC_SUDO tee -a $(lxc_config $name) > /dev/null <<'EOF' -security.nesting = true -lxc.cap.drop = -lxc.apparmor.profile = unconfined +function lxc_container_config_nesting() { + echo 'security.nesting = true' +} + +function lxc_container_config_cap() { + echo 'lxc.cap.drop =' +} + +function lxc_container_config_net() { + cat <> /etc/default/lxc-net <