Browse Source

Validate site.conf

Matthias Schiffer 10 years ago
parent
commit
ffd86668fe

+ 7 - 2
package/gluon-autoupdater/Makefile

@@ -1,12 +1,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=gluon-autoupdater
-PKG_VERSION:=2
+PKG_VERSION:=3
 PKG_RELEASE:=$(GLUON_BRANCH)
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
-include $(INCLUDE_DIR)/package.mk
+include $(GLUONDIR)/include/package.mk
 
 define Package/gluon-autoupdater
   SECTION:=gluon
@@ -34,4 +34,9 @@ define Package/gluon-autoupdater/install
 	fi
 endef
 
+define Package/gluon-autoupdater/postinst
+#!/bin/sh
+$(call GluonCheckSite,check_site.lua)
+endef
+
 $(eval $(call BuildPackage,gluon-autoupdater))

+ 13 - 0
package/gluon-autoupdater/check_site.lua

@@ -0,0 +1,13 @@
+need_string 'autoupdater.branch'
+
+local function check_branch(k, _)
+   local prefix = string.format('autoupdater.branches[%q].', k)
+
+   need_string(prefix .. 'name')
+   need_string_array(prefix .. 'mirrors')
+   need_number(prefix .. 'probability')
+   need_number(prefix .. 'good_signatures')
+   need_string_array(prefix .. 'pubkeys')
+end
+
+need_table('autoupdater.branches', check_branch)

+ 7 - 2
package/gluon-config-mode/Makefile

@@ -4,11 +4,11 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=gluon-config-mode
-PKG_VERSION:=2
+PKG_VERSION:=3
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
-include $(INCLUDE_DIR)/package.mk
+include $(GLUONDIR)/include/package.mk
 
 define Package/gluon-config-mode
   SECTION:=gluon
@@ -35,4 +35,9 @@ define Package/gluon-config-mode/install
 	$(CP) ./files/* $(1)/
 endef
 
+define Package/gluon-config-mode/postinst
+#!/bin/sh
+$(call GluonCheckSite,check_site.lua)
+endef
+
 $(eval $(call BuildPackage,gluon-config-mode))

+ 3 - 0
package/gluon-config-mode/check_site.lua

@@ -0,0 +1,3 @@
+need_string 'config_mode.msg_welcome'
+need_string 'config_mode.msg_pubkey'
+need_string 'config_mode.msg_reboot'

+ 7 - 2
package/gluon-core/Makefile

@@ -1,12 +1,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=gluon-core
-PKG_VERSION:=2
+PKG_VERSION:=3
 PKG_RELEASE:=$(GLUON_VERSION)
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
-include $(INCLUDE_DIR)/package.mk
+include $(GLUONDIR)/include/package.mk
 
 define Package/gluon-core
   SECTION:=gluon
@@ -36,4 +36,9 @@ define Package/gluon-core/install
 	echo "$(GLUON_VERSION)" > $(1)/lib/gluon/gluon-version
 endef
 
+define Package/gluon-core/postinst
+#!/bin/sh
+$(call GluonCheckSite,check_site.lua)
+endef
+
 $(eval $(call BuildPackage,gluon-core))

+ 10 - 0
package/gluon-core/check_site.lua

@@ -0,0 +1,10 @@
+need_string 'site_code'
+need_string 'site_name'
+
+need_string 'hostname_prefix'
+need_string 'timezone'
+
+need_string_array('ntp_servers', false)
+
+need_string_match('prefix4', '^%d+.%d+.%d+.%d+/%d+$')
+need_string_match('prefix6', '^[%x:]+/%d+$')

+ 7 - 2
package/gluon-legacy/Makefile

@@ -1,11 +1,11 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=gluon-legacy
-PKG_VERSION:=1
+PKG_VERSION:=2
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
-include $(INCLUDE_DIR)/package.mk
+include $(GLUONDIR)/include/package.mk
 
 define Package/gluon-legacy
   SECTION:=gluon
@@ -32,4 +32,9 @@ define Package/gluon-legacy/install
 	$(CP) ./files/* $(1)/
 endef
 
+define Package/gluon-legacy/postinst
+#!/bin/sh
+$(call GluonCheckSite,check_site.lua)
+endef
+
 $(eval $(call BuildPackage,gluon-legacy))

+ 8 - 0
package/gluon-legacy/check_site.lua

@@ -0,0 +1,8 @@
+need_string_array 'legacy.version_files'
+need_string_array 'legacy.old_files'
+
+need_string_array 'legacy.config_mode_configs'
+need_string_array 'legacy.fastd_configs'
+need_string 'legacy.mesh_ifname'
+need_string_array 'legacy.tc_configs'
+need_string_array 'legacy.wifi_names'

+ 8 - 2
package/gluon-mesh-batman-adv/Makefile

@@ -1,11 +1,11 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=gluon-mesh-batman-adv
-PKG_VERSION:=2
+PKG_VERSION:=3
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
-include $(INCLUDE_DIR)/package.mk
+include $(GLUONDIR)/include/package.mk
 
 define Package/gluon-mesh-batman-adv
   SECTION:=gluon
@@ -32,4 +32,10 @@ define Package/gluon-mesh-batman-adv/install
 	$(CP) ./files/* $(1)/
 endef
 
+define Package/gluon-mesh-batman-adv/postinst
+#!/bin/sh
+$(call GluonCheckSite,check_site.lua)
+endef
+
+
 $(eval $(call BuildPackage,gluon-mesh-batman-adv))

+ 10 - 0
package/gluon-mesh-batman-adv/check_site.lua

@@ -0,0 +1,10 @@
+need_string('regdom')
+
+for _, config in ipairs({'wifi24', 'wifi5'}) do
+   need_string(config .. '.ssid')
+   need_number(config .. '.channel')
+   need_string(config .. '.htmode')
+   need_string(config .. '.mesh_ssid')
+   need_string_match(config .. '.mesh_bssid', '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$')
+   need_number(config .. '.mesh_mcast_rate')
+end

+ 7 - 2
package/gluon-mesh-vpn-fastd/Makefile

@@ -1,11 +1,11 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=gluon-mesh-vpn-fastd
-PKG_VERSION:=2
+PKG_VERSION:=3
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
-include $(INCLUDE_DIR)/package.mk
+include $(GLUONDIR)/include/package.mk
 
 define Package/gluon-mesh-vpn-fastd
   SECTION:=gluon
@@ -32,4 +32,9 @@ define Package/gluon-mesh-vpn-fastd/install
 	$(CP) ./files/* $(1)/
 endef
 
+define Package/gluon-mesh-vpn-fastd/postinst
+#!/bin/sh
+$(call GluonCheckSite,check_site.lua)
+endef
+
 $(eval $(call BuildPackage,gluon-mesh-vpn-fastd))

+ 13 - 0
package/gluon-mesh-vpn-fastd/check_site.lua

@@ -0,0 +1,13 @@
+need_string_array 'fastd_mesh_vpn.methods'
+need_number 'fastd_mesh_vpn.mtu'
+need_number 'fastd_mesh_vpn.backbone.limit'
+
+
+local function check_peer(k, _)
+   local prefix = string.format('fastd_mesh_vpn.backbone.peers[%q].', k)
+
+   need_string(prefix .. 'key')
+   need_string_array(prefix .. 'remotes')
+end
+
+need_table('fastd_mesh_vpn.backbone.peers', check_peer)

+ 7 - 2
package/gluon-next-node/Makefile

@@ -1,11 +1,11 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=gluon-next-node
-PKG_VERSION:=2
+PKG_VERSION:=3
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
-include $(INCLUDE_DIR)/package.mk
+include $(GLUONDIR)/include/package.mk
 
 define Package/gluon-next-node
   SECTION:=gluon
@@ -32,4 +32,9 @@ define Package/gluon-next-node/install
 	$(CP) ./files/* $(1)/
 endef
 
+define Package/gluon-next-node/postinst
+#!/bin/sh
+$(call GluonCheckSite,check_site.lua)
+endef
+
 $(eval $(call BuildPackage,gluon-next-node))

+ 4 - 0
package/gluon-next-node/check_site.lua

@@ -0,0 +1,4 @@
+need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$')
+need_string_match('next_node.ip6', '^[%x:]+$')
+
+need_string_match('next_node.mac', '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$')