mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
swmodd: limited support to install lxc service container
This commit is contained in:
parent
33b331d724
commit
1d62545b4d
2 changed files with 27 additions and 4 deletions
|
|
@ -5,7 +5,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=swmodd
|
||||
PKG_VERSION:=2.3.2
|
||||
PKG_VERSION:=2.3.3
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
|
|
|
|||
|
|
@ -23,15 +23,23 @@ validate_globals_section()
|
|||
}
|
||||
|
||||
start_lxc_container() {
|
||||
local root
|
||||
|
||||
config_get name "${1}" name ""
|
||||
config_get type "${1}" type ""
|
||||
config_get autostart "${1}" autostart "0"
|
||||
config_get timeout "${1}" timeout "300"
|
||||
root="${2}"
|
||||
|
||||
if [ -z "${name}" ] || [ -z "${type}" ]; then
|
||||
return 0;
|
||||
fi
|
||||
|
||||
# workaround to install lxc container with installdu and autostart them
|
||||
if [ -f "${root}/$name/config" ]; then
|
||||
type=lxc
|
||||
fi
|
||||
|
||||
if [ "${type}" != "lxc" ]; then
|
||||
return 0;
|
||||
fi
|
||||
|
|
@ -44,12 +52,12 @@ start_lxc_container() {
|
|||
if [ "${autostart}" == "0" ]; then
|
||||
if [ "${state}" == "RUNNING" ]; then
|
||||
# stop the container if running
|
||||
lxc-stop -n "${name}" -t "${timeout}" &
|
||||
lxc-stop -k -n "${name}" &
|
||||
return 0;
|
||||
elif [ "${state}" == "FROZEN" ]; then
|
||||
# first unfreeze then stop
|
||||
lxc-unfreeze -n "${name}"
|
||||
lxc-stop -n "${name}" -t "${timeout}" &
|
||||
lxc-stop -k -n "${name}" &
|
||||
return 0;
|
||||
fi
|
||||
else
|
||||
|
|
@ -64,6 +72,12 @@ start_lxc_container() {
|
|||
fi
|
||||
}
|
||||
|
||||
stop_lxc_containers() {
|
||||
for f in `lxc-ls`; do
|
||||
lxc-stop -k -n $f >/dev/null 2>&1;
|
||||
done
|
||||
}
|
||||
|
||||
start_service() {
|
||||
local enabled debug log_level sock lxc_bundle_root oci_bundle_root
|
||||
|
||||
|
|
@ -105,8 +119,17 @@ start_service() {
|
|||
if [ -f "${lxc_bundle_root}/lxccontainer" ]; then
|
||||
UCI_CONFIG_DIR="${lxc_bundle_root}"
|
||||
config_load lxccontainer
|
||||
config_foreach start_lxc_container container
|
||||
config_foreach start_lxc_container container ${lxc_bundle_root}
|
||||
fi
|
||||
if [ -f "${oci_bundle_root}/ocicontainer" ]; then
|
||||
UCI_CONFIG_DIR="${oci_bundle_root}"
|
||||
config_load ocicontainer
|
||||
config_foreach start_lxc_container du_eu_assoc ${oci_bundle_root}
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
stop_lxc_containers
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue