mirror of https://github.com/searxng/searxng.git
utils/lxc.sh install: support installation on selected containers
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
84daf9999c
commit
3c19f2f1ce
|
@ -10,10 +10,12 @@
|
||||||
# config
|
# config
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
LXC_SUITE_NAME="searx"
|
||||||
lxc_set_suite_env() {
|
lxc_set_suite_env() {
|
||||||
# name of https://images.linuxcontainers.org
|
# name of https://images.linuxcontainers.org
|
||||||
export LINUXCONTAINERS_ORG_NAME="${LINUXCONTAINERS_ORG_NAME:-images}"
|
export LINUXCONTAINERS_ORG_NAME="${LINUXCONTAINERS_ORG_NAME:-images}"
|
||||||
export LXC_HOST_PREFIX="${LXC_HOST_PREFIX:-searx}"
|
export LXC_HOST_PREFIX="${LXC_SUITE_NAME:-searx}"
|
||||||
export LXC_SUITE=(
|
export LXC_SUITE=(
|
||||||
|
|
||||||
# to disable containers, comment out lines ..
|
# to disable containers, comment out lines ..
|
||||||
|
|
35
utils/lxc.sh
35
utils/lxc.sh
|
@ -82,7 +82,7 @@ usage::
|
||||||
$_cmd [start|stop] [containers|<name>]
|
$_cmd [start|stop] [containers|<name>]
|
||||||
$_cmd show [images|suite|info|config [<name>]]
|
$_cmd show [images|suite|info|config [<name>]]
|
||||||
$_cmd cmd [--|<name>] '...'
|
$_cmd cmd [--|<name>] '...'
|
||||||
$_cmd install [suite|base]
|
$_cmd install [suite|base [<name>]]
|
||||||
|
|
||||||
build
|
build
|
||||||
:containers: build, launch all containers and 'install base' packages
|
:containers: build, launch all containers and 'install base' packages
|
||||||
|
@ -105,32 +105,26 @@ cmd
|
||||||
-- run command '...' in all containers of the LXC suite
|
-- run command '...' in all containers of the LXC suite
|
||||||
:<name>: run command '...' in container <name>
|
:<name>: run command '...' in container <name>
|
||||||
install
|
install
|
||||||
:suite: install LXC suite; ${LXC_SUITE_INSTALL_INFO}
|
|
||||||
:base: prepare LXC; install basic packages
|
:base: prepare LXC; install basic packages
|
||||||
|
:suite: install LXC ${LXC_SUITE_NAME} suite into all (or <name>) containers
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
usage_images
|
|
||||||
echo
|
|
||||||
usage_containers
|
usage_containers
|
||||||
echo
|
|
||||||
[ -n "${1+x}" ] && err_msg "$1"
|
[ -n "${1+x}" ] && err_msg "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
usage_containers() {
|
usage_containers() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
LXC suite containers:
|
LXC suite: ${LXC_SUITE_NAME}
|
||||||
|
$(echo " ${LXC_SUITE_INSTALL_INFO}" | $FMT)
|
||||||
|
suite images:
|
||||||
|
$(echo " ${LOCAL_IMAGES[*]}" | $FMT)
|
||||||
|
suite containers:
|
||||||
$(echo " ${CONTAINERS[*]}" | $FMT)
|
$(echo " ${CONTAINERS[*]}" | $FMT)
|
||||||
EOF
|
EOF
|
||||||
[ -n "${1+x}" ] && err_msg "$1"
|
[ -n "${1+x}" ] && err_msg "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
usage_images() {
|
|
||||||
cat <<EOF
|
|
||||||
LXC suite images:
|
|
||||||
$(echo " ${LOCAL_IMAGES[*]}" | $FMT)
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
lxd_info() {
|
lxd_info() {
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
@ -216,6 +210,7 @@ main() {
|
||||||
config)
|
config)
|
||||||
case $3 in
|
case $3 in
|
||||||
${LXC_HOST_PREFIX}-*)
|
${LXC_HOST_PREFIX}-*)
|
||||||
|
! lxc_exists "$3" && usage_containers "unknown container: $3" && exit 42
|
||||||
lxc config show "$3" | prefix_stdout "[${_BBlue}${3}${_creset}] "
|
lxc config show "$3" | prefix_stdout "[${_BBlue}${3}${_creset}] "
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -230,6 +225,7 @@ main() {
|
||||||
info)
|
info)
|
||||||
case $3 in
|
case $3 in
|
||||||
${LXC_HOST_PREFIX}-*)
|
${LXC_HOST_PREFIX}-*)
|
||||||
|
! lxc_exists "$3" && usage_containers "unknown container: $3" && exit 42
|
||||||
lxc info "$3" | prefix_stdout "[${_BBlue}${3}${_creset}] "
|
lxc info "$3" | prefix_stdout "[${_BBlue}${3}${_creset}] "
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -259,14 +255,21 @@ main() {
|
||||||
shift
|
shift
|
||||||
lxc_exec_cmd "${name}" "$@"
|
lxc_exec_cmd "${name}" "$@"
|
||||||
;;
|
;;
|
||||||
*) usage "uknown or missing container <name> $1"; exit 42;;
|
*) usage_containers "unknown container: $1" && exit 42
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
install)
|
install)
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
case $2 in
|
case $2 in
|
||||||
suite|base)
|
suite|base)
|
||||||
lxc_exec "${LXC_REPO_ROOT}/utils/lxc.sh" __install "$2"
|
case $3 in
|
||||||
|
${LXC_HOST_PREFIX}-*)
|
||||||
|
! lxc_exists "$3" && usage_containers "unknown container: $3" && exit 42
|
||||||
|
lxc_exec_cmd "$3" "${LXC_REPO_ROOT}/utils/lxc.sh" __install "$2"
|
||||||
|
;;
|
||||||
|
'') lxc_exec "${LXC_REPO_ROOT}/utils/lxc.sh" __install "$2" ;;
|
||||||
|
*) usage_containers "unknown container: $3" && exit 42
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
*) usage "$_usage"; exit 42 ;;
|
*) usage "$_usage"; exit 42 ;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue