diff --git a/swmodd/Makefile b/swmodd/Makefile index 781672ebb..204f1ecba 100755 --- a/swmodd/Makefile +++ b/swmodd/Makefile @@ -5,13 +5,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=swmodd -PKG_VERSION:=2.5.17 +PKG_VERSION:=2.5.18 LOCAL_DEV:=0 ifneq ($(LOCAL_DEV),1) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://dev.iopsys.eu/lcm/swmodd.git -PKG_SOURCE_VERSION:=f14859ab9a5e829ebbe9b3736c2677ee7e7c36cf +PKG_SOURCE_VERSION:=c50b1deb62bc931f350b799a65a5ac3aa88352dd PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_MIRROR_HASH:=skip endif diff --git a/swmodd/files/etc/init.d/crun b/swmodd/files/etc/init.d/crun index eb2167e2a..ef943f127 100755 --- a/swmodd/files/etc/init.d/crun +++ b/swmodd/files/etc/init.d/crun @@ -56,7 +56,7 @@ configure_lxc_container() { } configure_crun_container() { - local name type autostart du_status requested_state url username password capability + local name type autostart du_status requested_state url username password capability envlist local BRIDGE BUNDLE BOOT PERM local RUNNER="/etc/swmodd/run.sh" @@ -74,6 +74,12 @@ configure_crun_container() { config_get username "${1}" username "" config_get password "${1}" password "" config_get capability "${1}" capability "" + config_get envlist "${1}" env_var "" + + if [ -n "${envlist}" ]; then + envlist="${envlist// /;}" + fi + if [ -n "${capability}" ]; then PERM="-p ${capability// /,}" fi @@ -152,7 +158,7 @@ configure_crun_container() { if [ "${BOOT}" -eq "1" ]; then if [ "${autostart}" -eq 1 ]; then - ${RUNNER} -U -b "${BUNDLE}" -n "${name}" ${PERM} + ${RUNNER} -U -b "${BUNDLE}" -n "${name}" -e "${envlist}" ${PERM} result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_description") if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" description "${result}" @@ -185,7 +191,7 @@ configure_crun_container() { ${RUNNER} -u -n "${name}" -i "${BRIDGE}" ${PERM} crun resume "${name}" else - ${RUNNER} -U -b "${BUNDLE}" -n "${name}" ${PERM} + ${RUNNER} -U -b "${BUNDLE}" -n "${name}" -e "${envlist}" ${PERM} result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_description") if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" description "${result}" diff --git a/swmodd/files/etc/swmodd/run.sh b/swmodd/files/etc/swmodd/run.sh index a07ed6476..4ab10e7a0 100755 --- a/swmodd/files/etc/swmodd/run.sh +++ b/swmodd/files/etc/swmodd/run.sh @@ -144,6 +144,20 @@ update_config_json() { json_add_string hostname "${NAME}" fi + if [ -n "${ENVLIST}" ]; then + json_select process + json_get_values preenv env + json_select env + for i in ${ENVLIST//;/ }; do + key="$(echo $i|cut -d= -f1)" + if [[ "${preenv}" != *"${key}="* ]]; then + json_add_string "" "${i}" + fi + done + json_select .. + json_select .. + fi + # Update cabalities if [ -n "${PERM}" ]; then log "Updating Permission in the json ..." @@ -264,10 +278,11 @@ clean=0 net_update=0 update_json=0 PERM="" +ENVLIST="" log "## Runner [$@] ##" -while getopts b:n:i:r:l:t:p:cuU options +while getopts b:n:i:r:l:t:p:e:cuU options do case "${options}" in b) BUNDLE=${OPTARG};; @@ -278,6 +293,7 @@ do r) REGURL=${OPTARG};; l) LOGIN=${OPTARG};; t) TIMEOUT=${OPTARG};; + e) ENVLIST=${OPTARG};; u) net_update=1;; U) update_json=1;; *) log "Invalid options";;