mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
swmodd: uci-default scrip to migrate lxc-auto config
In release-6.5 lxc-auto used for autostart of lxc containers, this uci-default migration script shall migrate the autostart info to the configured path.
This commit is contained in:
parent
81bfe4cc1b
commit
6e3490b985
2 changed files with 51 additions and 3 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=swmodd
|
PKG_NAME:=swmodd
|
||||||
PKG_VERSION:=2.2.4
|
PKG_VERSION:=2.2.5
|
||||||
|
|
||||||
LOCAL_DEV:=0
|
LOCAL_DEV:=0
|
||||||
ifneq ($(LOCAL_DEV),1)
|
ifneq ($(LOCAL_DEV),1)
|
||||||
|
|
@ -76,23 +76,24 @@ define Package/swmodd/install
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/bbfdm
|
$(INSTALL_DIR) $(1)/usr/lib/bbfdm
|
||||||
$(INSTALL_DIR) $(1)/usr/sbin
|
$(INSTALL_DIR) $(1)/usr/sbin
|
||||||
$(INSTALL_DIR) $(1)/usr/share/swmodd/
|
$(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/init.d/swmodd $(1)/etc/init.d/swmodd
|
||||||
$(INSTALL_BIN) ./files/etc/config/swmodd $(1)/etc/config/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)/swmodd $(1)/usr/sbin/swmodd
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libswmodd.so $(1)/usr/lib/bbfdm/libswmodd.so
|
$(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) $(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)
|
ifeq ($(CONFIG_PACKAGE_liblxc),y)
|
||||||
$(INSTALL_DIR) $(1)/usr/share/lxc/templates/
|
$(INSTALL_DIR) $(1)/usr/share/lxc/templates/
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/templates/lxc-iopsys $(1)/usr/share/lxc/templates/lxc-iopsys
|
$(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
|
endif
|
||||||
ifeq ($(CONFIG_PACKAGE_crun),y)
|
ifeq ($(CONFIG_PACKAGE_crun),y)
|
||||||
$(INSTALL_DIR) $(1)/etc/swmodd
|
$(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/swmodd/run.sh $(1)/etc/swmodd/run.sh
|
||||||
$(INSTALL_BIN) ./files/etc/init.d/crun $(1)/etc/init.d/crun
|
$(INSTALL_BIN) ./files/etc/init.d/crun $(1)/etc/init.d/crun
|
||||||
$(INSTALL_BIN) ./files/etc/config/crun $(1)/etc/config/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) $(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
|
endif
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
|
||||||
47
swmodd/files/etc/uci-defaults/02-migrate-lxc
Normal file
47
swmodd/files/etc/uci-defaults/02-migrate-lxc
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Reference in a new issue