swmodd: Select lxc utils based on config option

This commit is contained in:
Vivek Kumar Dutta 2023-07-26 15:34:13 +05:30
parent dc4c8bafc2
commit 91d345c7fb
No known key found for this signature in database
GPG key ID: 65C818099F37097D
4 changed files with 95 additions and 59 deletions

View file

@ -1,26 +1,56 @@
menu "Configuration" config SWMODD_REGISTRY_PULL_SUPPORT
depends on PACKAGE_swmodd
config SWMODD_LXC_SUPPORT
bool "Handles LXC based containers"
default y
config SWMODD_OCI_SUPPORT
bool "Handles OCI containers"
default y
depends on PACKAGE_swmodd
select PACKAGE_crun
config SWMODD_REGISTRY_PULL_SUPPORT
bool "Add support to pull images from container image registries (i.e: docker.io, quay.io)" bool "Add support to pull images from container image registries (i.e: docker.io, quay.io)"
default n
depends on PACKAGE_swmodd depends on PACKAGE_swmodd
default n
select PACKAGE_skopeo select PACKAGE_skopeo
select PACKAGE_umoci select PACKAGE_umoci
config SWMODD_KERNEL_OPTIONS config SWMODD_LXC_SUPPORT
bool "Enable kernel support for LXC and OCI containers" bool "Handles LXC based containers"
depends on PACKAGE_swmodd
default y default y
select PACKAGE_lxc
select PACKAGE_lxc-attach
select PACKAGE_lxc-auto
select PACKAGE_lxc-cgroup
select PACKAGE_lxc-checkconfig
select PACKAGE_lxc-common
select PACKAGE_lxc-config
select PACKAGE_lxc-configs
select PACKAGE_lxc-console
select PACKAGE_lxc-create
select PACKAGE_lxc-destroy
select PACKAGE_lxc-execute
select PACKAGE_lxc-freeze
select PACKAGE_lxc-hooks
select PACKAGE_lxc-info
select PACKAGE_lxc-init
select PACKAGE_lxc-ls
select PACKAGE_lxc-start
select PACKAGE_lxc-stop
select PACKAGE_lxc-templates
select PACKAGE_lxc-top
select PACKAGE_lxc-unfreeze
select PACKAGE_lxc-unprivileged
select PACKAGE_lxc-unshare
select PACKAGE_lxc-user-nic
select PACKAGE_lxc-usernsexec
select PACKAGE_lxc-wait
config SWMODD_OCI_SUPPORT
bool "Handles OCI containers"
depends on PACKAGE_swmodd
default y
select PACKAGE_crun
config SWMODD_KERNEL_OPTIONS
bool "Enable kernel support for LXC and OCI containers"
depends on PACKAGE_swmodd
default y
select LXC_KERNEL_OPTIONS
select LXC_BUSYBOX_OPTIONS
select LXC_SECCOMP
select LXC_NETWORKING
select KERNEL_CGROUPS select KERNEL_CGROUPS
select KERNEL_CGROUP_SCHED select KERNEL_CGROUP_SCHED
select KERNEL_CGROUP_DEVICE select KERNEL_CGROUP_DEVICE
@ -42,12 +72,11 @@ menu "Configuration"
include cgroups, namespaces and other miscellaneous options. These include cgroups, namespaces and other miscellaneous options. These
options unfortunately can not be installed as a module. options unfortunately can not be installed as a module.
config SWMODD_NETWORKING config SWMODD_NETWORKING
bool "Enable networking support for LXC/OCI containers" bool "Enable networking support for LXC/OCI containers"
depends on PACKAGE_swmodd
default y default y
select PACKAGE_kmod-veth select PACKAGE_kmod-veth
select PACKAGE_kmod-macvlan select PACKAGE_kmod-macvlan
help help
Enable "veth pair device" and "macvlan" Enable "veth pair device" and "macvlan"
endmenu

View file

@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=swmodd PKG_NAME:=swmodd
PKG_VERSION:=2.2.8 PKG_VERSION:=2.2.9
LOCAL_DEV:=0 LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
@ -28,6 +28,7 @@ define Package/swmodd
CATEGORY:=Utilities CATEGORY:=Utilities
SUBMENU:=TRx69 SUBMENU:=TRx69
TITLE:= Software Modules Daemon TITLE:= Software Modules Daemon
MENU:=1
DEPENDS:=+libuci +libubox +ubus +libuuid +opkg +libcurl \ DEPENDS:=+libuci +libubox +ubus +libuuid +opkg +libcurl \
+PACKAGE_lxc:lxc +PACKAGE_liblxc:liblxc +@BUSYBOX_CONFIG_BUSYBOX \ +PACKAGE_lxc:lxc +PACKAGE_liblxc:liblxc +@BUSYBOX_CONFIG_BUSYBOX \
+@BUSYBOX_CONFIG_FEATURE_SHOW_SCRIPT +@BUSYBOX_CONFIG_SCRIPT \ +@BUSYBOX_CONFIG_FEATURE_SHOW_SCRIPT +@BUSYBOX_CONFIG_SCRIPT \
@ -54,12 +55,12 @@ TARGET_CFLAGS += \
-D_GNU_SOURCE \ -D_GNU_SOURCE \
-Wall -Werror -Wall -Werror
ifeq ($(CONFIG_PACKAGE_crun),y) ifeq ($(CONFIG_SWMODD_OCI_SUPPORT),y)
MAKE_FLAGS += \ MAKE_FLAGS += \
SWMOD_CRUN="yes" SWMOD_CRUN="yes"
endif endif
ifeq ($(CONFIG_PACKAGE_lxc),y) ifeq ($(CONFIG_SWMODD_LXC_SUPPORT),y)
MAKE_FLAGS += \ MAKE_FLAGS += \
SWMOD_LXC="yes" SWMOD_LXC="yes"
endif endif

View file

@ -6,6 +6,11 @@ STOP=01
USE_PROCD=1 USE_PROCD=1
PROG=/usr/sbin/swmodd PROG=/usr/sbin/swmodd
log()
{
logger -t swmodd.init "$*"
}
validate_globals_section() validate_globals_section()
{ {
uci_validate_section swmodd swmodd "globals" \ uci_validate_section swmodd swmodd "globals" \
@ -70,9 +75,15 @@ start_service() {
[ "${enabled}" -eq 0 ] && return 0 [ "${enabled}" -eq 0 ] && return 0
# Create the bundle paths if not present if [ ! -d "${lxc_bundle_root}" ]; then
[ -n "${lxc_bundle_root}" ] && mkdir -p "${lxc_bundle_root}" log "# Not staring lxc [${lxc_bundle_root}] not present/defined"
[ -n "${oci_bundle_root}" ] && mkdir -p "${oci_bundle_root}" return 1
fi
if [ ! -d "${oci_bundle_root}" ]; then
log "# Not staring oci [${oci_bundle_root}] not present/defined"
return 1
fi
procd_open_instance swmodd procd_open_instance swmodd
procd_set_param command ${PROG} procd_set_param command ${PROG}

View file

@ -21,23 +21,18 @@ if [ -n "${lxc_bundle}" ]; then
elif [ -n "${lxc}" ]; then elif [ -n "${lxc}" ]; then
# if lxc_bundle_root not define in swmodd, update it with lxc path # if lxc_bundle_root not define in swmodd, update it with lxc path
uci_set swmodd globals lxc_bundle_root ${lxc} uci_set swmodd globals lxc_bundle_root ${lxc}
uci_commit
else else
mkdir -p /etc/lxc mkdir -p /etc/lxc
echo "lxc.lxcpath = /srv/" > /etc/lxc/lxc.conf echo "lxc.lxcpath = /srv/" > /etc/lxc/lxc.conf
uci_set swmodd globals lxc_bundle_root "/srv/" uci_set swmodd globals lxc_bundle_root "/srv/"
uci_commit
fi fi
if [ -z "${oci_bundle}" ] && [ -n "${lxc_bundle}" ]; then if [ -z "${oci_bundle}" ] && [ -n "${lxc_bundle}" ]; then
# if oci_bundle_root not defined in swmodd, update it with lxc_bundle_root if defined # if oci_bundle_root not defined in swmodd, update it with lxc_bundle_root if defined
uci_set swmodd globals oci_bundle_root ${lxc_bundle} uci_set swmodd globals oci_bundle_root ${lxc_bundle}
uci_commit
elif [ -z "${oci_bundle}" ] && [ -n "${lxc}" ]; then elif [ -z "${oci_bundle}" ] && [ -n "${lxc}" ]; then
# if oci_bundle_root not defined in swmodd, update it with lxc path # if oci_bundle_root not defined in swmodd, update it with lxc path
uci_set swmodd globals oci_bundle_root ${lxc} uci_set swmodd globals oci_bundle_root ${lxc}
uci_commit
elif [ -z "${oci_bundle}" ]; then elif [ -z "${oci_bundle}" ]; then
uci_set swmodd globals oci_bundle_root "/srv/" uci_set swmodd globals oci_bundle_root "/srv/"
uci_commit
fi fi