From ae0fcf3a4208401f5dc0296c29227a55f63163da Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 16 Jul 2025 15:47:36 +0200 Subject: [chore] overdue maintenance of shell scripts Removes obsolete scripts and fix various leftovers. Signed-off-by: Markus Heiser --- utils/lib.sh | 140 ----------------------------------------------------------- 1 file changed, 140 deletions(-) (limited to 'utils/lib.sh') diff --git a/utils/lib.sh b/utils/lib.sh index 7886520c6..ff67c6f67 100755 --- a/utils/lib.sh +++ b/utils/lib.sh @@ -1626,146 +1626,6 @@ EOF fi } -# containers -# ---------- - -in_container() { - # Test if shell runs in a container. - # - # usage: in_container && echo "process running inside a LXC container" - # in_container || echo "process is not running inside a LXC container" - # - # sudo_or_exit - # hint: Reads init process environment, therefore root access is required! - # to be safe, take a look at the environment of process 1 (/sbin/init) - # grep -qa 'container=lxc' /proc/1/environ - - # see lxc_init_container_env - [[ -f /.lxcenv ]] -} - -LXC_ENV_FOLDER= -if in_container; then - # shellcheck disable=SC2034 - LXC_ENV_FOLDER="lxc-env/$(hostname)/" - PY_ENV="${LXC_ENV_FOLDER}${PY_ENV}" - PY_ENV_BIN="${LXC_ENV_FOLDER}${PY_ENV_BIN}" - PYDIST="${LXC_ENV_FOLDER}${PYDIST}" - PYBUILD="${LXC_ENV_FOLDER}${PYBUILD}" - DOCS_DIST="${LXC_ENV_FOLDER}${DOCS_DIST}" - DOCS_BUILD="${LXC_ENV_FOLDER}${DOCS_BUILD}" -fi - -lxc_init_container_env() { - - # usage: lxc_init_container_env - - # Create a /.lxcenv file in the root folder. Call this once after the - # container is initial started and before installing any boilerplate stuff. - - info_msg "create /.lxcenv in container $1" - cat < - # - # lxc_image_copy "images:ubuntu/20.04" "ubu2004" - - if lxc_image_exists "local:${LXC_SUITE[i+1]}"; then - info_msg "image ${LXC_SUITE[i]} already copied --> ${LXC_SUITE[i+1]}" - else - info_msg "copy image locally ${LXC_SUITE[i]} --> ${LXC_SUITE[i+1]}" - lxc image copy "${LXC_SUITE[i]}" local: \ - --alias "${LXC_SUITE[i+1]}" | prefix_stdout - fi -} - -lxc_init_container() { - - # usage: lxc_init_container - - local image_name="$1" - local container_name="$2" - - if lxc info "${container_name}" &>/dev/null; then - info_msg "container '${container_name}' already exists" - else - info_msg "create container instance: ${container_name}" - lxc init "local:${image_name}" "${container_name}" - fi -} - -lxc_exists(){ - - # usage: lxc_exists || echo "container does not exists" - - lxc info "$1" &>/dev/null -} - -lxc_image_exists(){ - # usage: lxc_image_exists || echo "image does locally not exists" - - lxc image info "local:$1" &>/dev/null - -} - -lxc_delete_container() { - - # usage: lxc_delete_container - - if lxc info "$1" &>/dev/null; then - info_msg "stop & delete instance ${_BBlue}${1}${_creset}" - lxc stop "$1" &>/dev/null - lxc delete "$1" | prefix_stdout - else - warn_msg "instance '$1' does not exist / can't delete :o" - fi -} - -lxc_delete_local_image() { - - # usage: lxc_delete_local_image - - info_msg "delete image 'local:$i'" - lxc image delete "local:$i" -} - # IP # -- -- cgit v1.2.3