diff --git a/swmodd/Makefile b/swmodd/Makefile index 509efd917..b205119c1 100755 --- a/swmodd/Makefile +++ b/swmodd/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=swmodd -PKG_VERSION:=2.1.22 +PKG_VERSION:=2.1.23 LOCAL_DEV:=0 ifneq ($(LOCAL_DEV),1) diff --git a/swmodd/files/etc/init.d/crun b/swmodd/files/etc/init.d/crun index e96291b0f..976c58745 100644 --- a/swmodd/files/etc/init.d/crun +++ b/swmodd/files/etc/init.d/crun @@ -48,17 +48,17 @@ configure_crun_container() { uci_set ocicontainer "${1}" password "" result=$(${RUNNER} -b "${BUNDLE}" -n "${name}" -r "${url}" -l "${username}:${password}") if [ "$?" -eq 0 ]; then - result=$(cat "${BUNDLE}"/"${name}"/config.json |jq ".annotations.org_opencontainers_image_description") + result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_description") if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" description "${result}" fi - result=$(cat "${BUNDLE}"/"${name}"/config.json |jq ".annotations.org_opencontainers_image_vendor") + result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_vendor") if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" vendor "${result}" fi - result=$(cat "${BUNDLE}"/"${name}"/config.json |jq ".annotations.org_opencontainers_image_version") + result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_version") if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" version "${result}" fi @@ -106,17 +106,17 @@ configure_crun_container() { if [ "${BOOT}" -eq "1" ]; then if [ "${autostart}" -eq 1 ]; then ${RUNNER} -U -b "${BUNDLE}" -n "${name}" - result=$(cat "${BUNDLE}"/"${name}"/config.json |jq ".annotations.org_opencontainers_image_description") + result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_description") if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" description "${result}" fi - result=$(cat "${BUNDLE}"/"${name}"/config.json |jq ".annotations.org_opencontainers_image_vendor") + result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_vendor") if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" vendor "${result}" fi - result=$(cat "${BUNDLE}"/"${name}"/config.json |jq ".annotations.org_opencontainers_image_version") + result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_version") if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" version "${result}" fi @@ -139,17 +139,17 @@ configure_crun_container() { crun resume "${name}" else ${RUNNER} -U -b "${BUNDLE}" -n "${name}" - result=$(cat "${BUNDLE}"/"${name}"/config.json |jq ".annotations.org_opencontainers_image_description") + result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_description") if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" description "${result}" fi - result=$(cat "${BUNDLE}"/"${name}"/config.json |jq ".annotations.org_opencontainers_image_vendor") + result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_vendor") if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" vendor "${result}" fi - result=$(cat "${BUNDLE}"/"${name}"/config.json |jq ".annotations.org_opencontainers_image_version") + result=$(cat ${BUNDLE}/${name}/config.json |jq ".annotations.org_opencontainers_image_version") if [ "${result}" != "null" ]; then uci_set ocicontainer "${1}" version "${result}" fi diff --git a/swmodd/files/etc/init.d/swmodd_cgroup b/swmodd/files/etc/init.d/swmodd_cgroup index 6dc207e2e..b7c772d49 100644 --- a/swmodd/files/etc/init.d/swmodd_cgroup +++ b/swmodd/files/etc/init.d/swmodd_cgroup @@ -35,12 +35,12 @@ mount_cgroup() fi mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup - cd /sys/fs/cgroup || return 1 + cd /sys/fs/cgroup for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do - mkdir -p "${sys}" - if ! mountpoint -q "${sys}"; then - if ! mount -n -t cgroup -o "${sys}" cgroup "${sys}"; then - rm -f "${sys}" || true + mkdir -p $sys + if ! mountpoint -q $sys; then + if ! mount -n -t cgroup -o $sys cgroup $sys; then + rm -f $sys || true fi fi done diff --git a/swmodd/files/etc/swmodd/run.sh b/swmodd/files/etc/swmodd/run.sh index f5b3df9b6..879e30999 100644 --- a/swmodd/files/etc/swmodd/run.sh +++ b/swmodd/files/etc/swmodd/run.sh @@ -92,11 +92,11 @@ run_container() { update_network_ns() { local type - json_select "${2}" + json_select $2 json_get_var type type if [ "${type}" = "network" ]; then json_add_string path "/var/run/netns/${NAME}" - return; + break; fi json_select .. } @@ -121,7 +121,7 @@ update_config_json() { log "jshn.sh missing in the system" exit 1; fi - cd "${BUNDLE}/${NAME}" || exit 1; + cd "${BUNDLE}/${NAME}" if cat config.json |jq '.linux.namespaces[] |select (.type == "network") |.path' |grep -q ${NAME}; then exit 0; fi @@ -157,20 +157,20 @@ pull_image_from_registry() { exit 1 fi - cd "${temp}" || exit 1; + cd "${temp}" OPTS="" INSPECT_OPT="" if [ "${#LOGIN}" -gt 3 ]; then OPTS="--src-creds ${LOGIN}" INSPECT_OPT="--creds ${LOGIN}" fi - if ! skopeo --command-timeout 4m copy "${OPTS}" "${REGURL}" oci:"${NAME}"_tmp:latest >/dev/null 2>&1; then + if ! skopeo --command-timeout 4m copy ${OPTS} ${REGURL} oci:${NAME}_tmp:latest >/dev/null 2>&1; then log "Failed to download image" cd - rm -rf "${temp}" exit 1 fi - if ! umoci unpack --image "${NAME}"_tmp:latest "${NAME}" >/dev/null 2>&1; then + if ! umoci unpack --image ${NAME}_tmp:latest ${NAME} >/dev/null 2>&1; then log "Failed to unpack image" cd - rm -rf "${temp}" @@ -185,8 +185,8 @@ pull_image_from_registry() { fi # Check disk available space before copy - disksize=$(df -P -k "${BUNDLE}" |tail -n +2 |awk '{print $4}') - exsize=$(du -s "${temp}" |awk '{print $1}') + disksize=$(df -P -k ${BUNDLE} |tail -n +2 |awk '{print $4}') + exsize=$(du -s ${temp} |awk '{print $1}') if [ "${disksize}" -lt "${exsize}" ]; then log "Disk space ${disksize} less than required ${exsize}" cd - @@ -194,12 +194,12 @@ pull_image_from_registry() { exit 1 fi - mv "${NAME}" "${BUNDLE}"/ + mv ${NAME} ${BUNDLE}/ if [ "$?" -ne 0 ]; then log "Failed ${name} move in ${BUNDLE}" cd - rm -rf "${temp}" - rm -rf "${BUNDLE}"/"${NAME}" + rm -rf ${BUNDLE}/${NAME} exit 1 fi diff --git a/swmodd/files/etc/uci-defaults/01-fix-bundle-path b/swmodd/files/etc/uci-defaults/01-fix-bundle-path index d78c821e7..d479e4733 100644 --- a/swmodd/files/etc/uci-defaults/01-fix-bundle-path +++ b/swmodd/files/etc/uci-defaults/01-fix-bundle-path @@ -20,7 +20,7 @@ if [ -n "${lxc_bundle}" ]; then echo "lxc.lxcpath = ${lxc_bundle}" > /etc/lxc/lxc.conf elif [ -n "${lxc}" ]; then # 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 mkdir -p /etc/lxc @@ -35,7 +35,7 @@ if [ -z "${oci_bundle}" ] && [ -n "${lxc_bundle}" ]; then uci_commit elif [ -z "${oci_bundle}" ] && [ -n "${lxc}" ]; then # 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 uci_set swmodd globals oci_bundle_root "/srv/"