diff --git a/swmodd/Makefile b/swmodd/Makefile index 58a6993dc..16020fa08 100755 --- a/swmodd/Makefile +++ b/swmodd/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=swmodd -PKG_VERSION:=2.2.4 +PKG_VERSION:=2.2.5 LOCAL_DEV:=0 ifneq ($(LOCAL_DEV),1) @@ -76,23 +76,24 @@ define Package/swmodd/install $(INSTALL_DIR) $(1)/usr/lib/bbfdm $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_DIR) $(1)/usr/share/swmodd/ + $(INSTALL_DIR) $(1)/etc/uci-defaults $(INSTALL_BIN) ./files/etc/init.d/swmodd $(1)/etc/init.d/swmodd $(INSTALL_BIN) ./files/etc/config/swmodd $(1)/etc/config/swmodd $(INSTALL_BIN) $(PKG_BUILD_DIR)/swmodd $(1)/usr/sbin/swmodd $(INSTALL_BIN) $(PKG_BUILD_DIR)/libswmodd.so $(1)/usr/lib/bbfdm/libswmodd.so $(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/opkg_offline.sh $(1)/usr/share/swmodd/opkg_offline + $(INSTALL_BIN) ./files/etc/uci-defaults/01-fix-bundle-path $(1)/etc/uci-defaults/01-fix-bundle-path ifeq ($(CONFIG_PACKAGE_liblxc),y) $(INSTALL_DIR) $(1)/usr/share/lxc/templates/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/templates/lxc-iopsys $(1)/usr/share/lxc/templates/lxc-iopsys + $(INSTALL_BIN) ./files/etc/uci-defaults/02-migrate-lxc $(1)/etc/uci-defaults/02-migrate-lxc endif ifeq ($(CONFIG_PACKAGE_crun),y) $(INSTALL_DIR) $(1)/etc/swmodd - $(INSTALL_DIR) $(1)/etc/uci-defaults $(INSTALL_BIN) ./files/etc/swmodd/run.sh $(1)/etc/swmodd/run.sh $(INSTALL_BIN) ./files/etc/init.d/crun $(1)/etc/init.d/crun $(INSTALL_BIN) ./files/etc/config/crun $(1)/etc/config/crun $(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/crun_create $(1)/usr/sbin/crun_create - $(INSTALL_BIN) ./files/etc/uci-defaults/01-fix-bundle-path $(1)/etc/uci-defaults/01-fix-bundle-path endif endef diff --git a/swmodd/files/etc/uci-defaults/02-migrate-lxc b/swmodd/files/etc/uci-defaults/02-migrate-lxc new file mode 100644 index 000000000..96b7903d4 --- /dev/null +++ b/swmodd/files/etc/uci-defaults/02-migrate-lxc @@ -0,0 +1,47 @@ +#!/bin/sh + +. /lib/functions.sh + +config_change=0 + +migrate_lxc() { + config_get name "${1}" name "" + + if [ -z "${name}" ]; then + return 0; + fi + + # Now lets check if already present in lxccontainer + exist=$(uci -q -c "${2}" show lxccontainer | grep ".name='$name'") + if [ -z "${exist}" ]; then + # Not present, need to migrate + sec=$(uci -q -c "${2}" add lxccontainer container) + if [ -n "${sec}" ]; then + uci -q -c "${2}" set lxccontainer."${sec}".name="${name}" + uci -q -c "${2}" set lxccontainer."${sec}".type='lxc' + uci -q -c "${2}" set lxccontainer."${sec}".autostart='1' + uci -q -c "${2}" set lxccontainer."${sec}".timeout='300' + config_change=1 + fi + fi +} + +config_load swmodd +config_get lxc_bundle globals lxc_bundle_root "" + +if [ -z "${lxc_bundle}" ]; then + return 0 +fi + +if [ ! -d "${lxc_bundle}" ]; then + return 0 +fi + +touch "${lxc_bundle}"/lxccontainer + +config_load lxc-auto +config_foreach migrate_lxc container "${lxc_bundle}" + +if [ $config_change -eq 1 ]; then + uci -q -c "${lxc_bundle}" commit lxccontainer +fi