diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2020-03-08 02:41:45 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2020-03-08 02:41:45 +0100 |
commit | e7f69b63f1169a60f6f15b827dfe4f5748a41d2c (patch) | |
tree | a828cfb439112707b810193b4b85cf845091e01d /utils/lxc.sh | |
parent | b1e90cff23eae2181d2b430e77471f488947d1a9 (diff) | |
download | searxng-e7f69b63f1169a60f6f15b827dfe4f5748a41d2c.tar.gz searxng-e7f69b63f1169a60f6f15b827dfe4f5748a41d2c.zip |
LXC: from searx.sh, morty.sh and filtron.sh tests
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'utils/lxc.sh')
-rwxr-xr-x | utils/lxc.sh | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/utils/lxc.sh b/utils/lxc.sh index b5ae59a7b..bcee16743 100755 --- a/utils/lxc.sh +++ b/utils/lxc.sh @@ -108,15 +108,29 @@ cmd install :suite: install LXC suite, includes morty & filtron -Images of the LXC suite: -$(echo " ${LOCAL_IMAGES[*]}" | $FMT) +EOF + usage_images + echo + usage_containers + echo + [ -n "${1+x}" ] && err_msg "$1" +} -Containers of the LXC suite: +usage_containers() { + cat <<EOF +LXC suite containers: $(echo " ${CONTAINERS[*]}" | $FMT) EOF [ -n "${1+x}" ] && err_msg "$1" } +usage_images() { + cat <<EOF +LXC suite images: +$(echo " ${LOCAL_IMAGES[*]}" | $FMT) +EOF +} + lxd_info() { cat <<EOF @@ -164,11 +178,12 @@ main() { images) lxc_delete_images_localy ;; subordinate) echo; del_subordinate_ids ;; ${LXC_HOST_PREFIX}-*) + ! lxc_exists "$2" && usage_containers "unknown container: $2" && exit 42 if ask_yn "Do you really want to delete conatiner $2"; then lxc_delete_container "$2" fi ;; - *) usage "unknown (or mising) container <name> $2"; exit 42;; + *) usage "uknown or missing container <name> $2"; exit 42;; esac ;; add) @@ -183,10 +198,11 @@ main() { case $2 in ''|containers) lxc_cmd "$1" ;; ${LXC_HOST_PREFIX}-*) + ! lxc_exists "$2" && usage_containers "unknown container: $2" && exit 42 info_msg "lxc $1 $2" lxc "$1" "$2" | prefix_stdout "[${_BBlue}${i}${_creset}] " ;; - *) usage "ukknown or missing container <name> $2"; exit 42;; + *) usage "uknown or missing container <name> $2"; exit 42;; esac ;; show) @@ -225,13 +241,12 @@ main() { done ;; ${LXC_HOST_PREFIX}-*) + ! lxc_exists "$1" && usage_containers "unknown container: $1" && exit 42 local name=$1 shift lxc_exec_cmd "${name}" "$@" ;; - - *) usage "unknown <name>: $1"; exit 42 - ;; + *) usage "uknown or missing container <name> $2"; exit 42;; esac ;; install) @@ -351,6 +366,7 @@ show_suite(){ else lxc exec -t "${i}" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __show suite \ | prefix_stdout "[${_BBlue}${i}${_creset}] " + echo fi done } @@ -384,12 +400,12 @@ lxc_exec_cmd() { shift exit_val= info_msg "[${_BBlue}${name}${_creset}] ${_BGreen}${*}${_creset}" - lxc exec "${name}" -- "$@" + lxc exec --cwd "${LXC_REPO_ROOT}" "${name}" -- "$@" exit_val=$? if [[ $exit_val -ne 0 ]]; then - warn_msg "[${_BBlue}${i}${_creset}] exit code (${_BRed}${exit_val}${_creset}) from ${_BGreen}${*}${_creset}" + warn_msg "[${_BBlue}${name}${_creset}] exit code (${_BRed}${exit_val}${_creset}) from ${_BGreen}${*}${_creset}" else - info_msg "[${_BBlue}${i}${_creset}] exit code (${exit_val}) from ${_BGreen}${*}${_creset}" + info_msg "[${_BBlue}${name}${_creset}] exit code (${exit_val}) from ${_BGreen}${*}${_creset}" fi echo } |