diff options
| author | Markus Heiser <markus.heiser@darmarit.de> | 2025-07-16 15:47:36 +0200 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarIT.de> | 2025-07-28 12:53:26 +0200 |
| commit | ae0fcf3a4208401f5dc0296c29227a55f63163da (patch) | |
| tree | 3f3612b982c1180064e944e1a83060f0161af57e /utils/lib.sh | |
| parent | 54a2b553f46df6dc98a4b8410788e35165e0fa3e (diff) | |
[chore] overdue maintenance of shell scripts
Removes obsolete scripts and fix various leftovers.
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'utils/lib.sh')
| -rwxr-xr-x | utils/lib.sh | 140 |
1 files changed, 0 insertions, 140 deletions
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 <name> - - # 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 <<EOF | lxc exec "${1}" -- bash | prefix_stdout "[${_BBlue}${1}${_creset}] " -touch "/.lxcenv" -ls -l "/.lxcenv" -EOF -} - -# apt packages -LXC_BASE_PACKAGES_debian="bash git build-essential python3 python3-venv python-is-python3" - -# pacman packages -LXC_BASE_PACKAGES_arch="bash git base-devel python" - -# dnf packages -LXC_BASE_PACKAGES_fedora="bash git @development-tools python" - -# yum packages -LXC_BASE_PACKAGES_centos="bash git python3" - -lxc_distro_setup() { - case $DIST_ID in - ubuntu|debian) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_debian}" ;; - arch) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_arch}" ;; - fedora) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_fedora}" ;; - centos) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_centos}" ;; - *) err_msg "$DIST_ID-$DIST_VERS: pkg_install LXC_BASE_PACKAGES not yet implemented" ;; - esac -} - -lxc_install_base_packages() { - info_msg "install LXC_BASE_PACKAGES in container $1" - case $DIST_ID in - centos) yum groupinstall "Development Tools" -y ;; - esac - pkg_install "${LXC_BASE_PACKAGES}" -} - - -lxc_image_copy() { - - # usage: lxc_image_copy <remote image> <local image> - # - # 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 <image name> <container name> - - 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 <name> || echo "container <name> does not exists" - - lxc info "$1" &>/dev/null -} - -lxc_image_exists(){ - # usage: lxc_image_exists <alias> || echo "image <alias> does locally not exists" - - lxc image info "local:$1" &>/dev/null - -} - -lxc_delete_container() { - - # usage: lxc_delete_container <container-name> - - 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 <container-name> - - info_msg "delete image 'local:$i'" - lxc image delete "local:$i" -} - # IP # -- |