diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2020-04-03 17:08:42 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2020-04-03 17:08:42 +0200 |
commit | af988dbf71ce4b14d2056676d7d9691335266d83 (patch) | |
tree | 9fbdde5a663be7cd66bda113fde70339e1fab9f6 /utils/lib.sh | |
parent | f32b4fceddf698f6a33c42a866ca21c6cc202841 (diff) | |
download | searxng-af988dbf71ce4b14d2056676d7d9691335266d83.tar.gz searxng-af988dbf71ce4b14d2056676d7d9691335266d83.zip |
utils/lxc.sh: support build of selected containers
$ sudo -H ./utils/lxc.sh build <name>
$ sudo -H ./utils/lxc.sh show [images|suite|info|config [<name>]]
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'utils/lib.sh')
-rwxr-xr-x | utils/lib.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/utils/lib.sh b/utils/lib.sh index 60476610a..e466100c1 100755 --- a/utils/lib.sh +++ b/utils/lib.sh @@ -1118,6 +1118,37 @@ lxc_install_base_packages() { pkg_install "${LXC_BASE_PACKAGES}" } + +lxc_image_copy() { + + # usage: lxc_copy_image <remote image> <local image> + # + # lxc_copy_image "images:ubuntu/19.10" "ubu1910" + + 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" |