forked from zaclys/searxng
LXC: minor fixes and renaming
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
ad32739860
commit
a1f5f2ced8
26
utils/lxc.sh
26
utils/lxc.sh
|
@ -55,14 +55,14 @@ usage() {
|
||||||
usage::
|
usage::
|
||||||
|
|
||||||
$(basename "$0") build [containers]
|
$(basename "$0") build [containers]
|
||||||
$(basename "$0") delete [containers|subordinate]
|
$(basename "$0") remove [containers|subordinate]
|
||||||
$(basename "$0") [start|stop] [containers]
|
$(basename "$0") [start|stop] [containers]
|
||||||
$(basename "$0") inspect [info|config]
|
$(basename "$0") inspect [info|config]
|
||||||
$(basename "$0") cmd ...
|
$(basename "$0") cmd ...
|
||||||
|
|
||||||
build / delete
|
build / remove
|
||||||
:containers: build and delete all LXC containers
|
:containers: build and remove all LXC containers
|
||||||
add / delete
|
add / remove
|
||||||
:subordinate: lxd permission to map ${HOST_USER}'s user/group id through
|
:subordinate: lxd permission to map ${HOST_USER}'s user/group id through
|
||||||
start/stop
|
start/stop
|
||||||
:containers: start/stop of all containers
|
:containers: start/stop of all containers
|
||||||
|
@ -86,7 +86,7 @@ lxd_info() {
|
||||||
LXD is needed, to install run::
|
LXD is needed, to install run::
|
||||||
|
|
||||||
snap install lxd
|
snap install lxd
|
||||||
lxc init --auto
|
lxd init --auto
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
@ -112,10 +112,10 @@ main() {
|
||||||
containers) build_instances ;;
|
containers) build_instances ;;
|
||||||
*) usage "$_usage"; exit 42;;
|
*) usage "$_usage"; exit 42;;
|
||||||
esac ;;
|
esac ;;
|
||||||
delete)
|
remove)
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
case $2 in
|
case $2 in
|
||||||
containers) delete_instances ;;
|
containers) remove_instances ;;
|
||||||
subordinate) echo; del_subordinate_ids ;;
|
subordinate) echo; del_subordinate_ids ;;
|
||||||
*) usage "$_usage"; exit 42;;
|
*) usage "$_usage"; exit 42;;
|
||||||
esac ;;
|
esac ;;
|
||||||
|
@ -173,8 +173,8 @@ build_instances() {
|
||||||
lxc list "$HOST_PREFIX"
|
lxc list "$HOST_PREFIX"
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_instances() {
|
remove_instances() {
|
||||||
rst_title "Delete LXC instances"
|
rst_title "Remove LXC instances"
|
||||||
echo -en "\\nLXC containers(s)::\\n\\n ${LOCAL_IMAGES[*]}\\n" | $FMT
|
echo -en "\\nLXC containers(s)::\\n\\n ${LOCAL_IMAGES[*]}\\n" | $FMT
|
||||||
if ask_yn "Do you really want to delete all images"; then
|
if ask_yn "Do you really want to delete all images"; then
|
||||||
lxc_delete_containers
|
lxc_delete_containers
|
||||||
|
@ -219,12 +219,14 @@ lxc_cmd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
lxc_init_containers() {
|
lxc_init_containers() {
|
||||||
for i in "${LOCAL_IMAGES[@]}"; do
|
local shortname
|
||||||
if lxc info "$i" &>/dev/null; then
|
for ((i=0; i<${#TEST_IMAGES[@]}; i+=2)); do
|
||||||
|
shortname="${TEST_IMAGES[i+1]}"
|
||||||
|
if lxc info "${HOST_PREFIX}-${shortname}" &>/dev/null; then
|
||||||
info_msg "conatiner '$i' already exists"
|
info_msg "conatiner '$i' already exists"
|
||||||
else
|
else
|
||||||
info_msg "create conatiner instance: $i"
|
info_msg "create conatiner instance: $i"
|
||||||
lxc init "local:$i" "$i"
|
lxc init "local:${shortname}" "${HOST_PREFIX}-${shortname}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue