First commit of gluon-migrate-vpn
This is a meta package which enabled tunneldigger/fastd if the opposite was active before.
This commit is contained in:
parent
63c5772fc3
commit
8ebb23163d
38
package/gluon-migrate-vpn/Makefile
Normal file
38
package/gluon-migrate-vpn/Makefile
Normal file
@ -0,0 +1,38 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=gluon-migrate-vpn
|
||||
PKG_VERSION:=1
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(GLUONDIR)/include/package.mk
|
||||
|
||||
define Package/gluon-migrate-vpn
|
||||
SECTION:=gluon
|
||||
CATEGORY:=Gluon
|
||||
TITLE:=Enables either fastd or tunneldigger if the opposite was active before upgrading
|
||||
DEPENDS:=+gluon-core
|
||||
endef
|
||||
|
||||
define Package/gluon-migrate-vpn/description
|
||||
Gluon community wifi mesh firmware framework: VPN service migration script
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/gluon-migrate-vpn/install
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
define Package/gluon-migrate-vpn/postinst
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,gluon-migrate-vpn))
|
31
package/gluon-migrate-vpn/files/lib/gluon/upgrade/499-migrate-vpn
Executable file
31
package/gluon-migrate-vpn/files/lib/gluon/upgrade/499-migrate-vpn
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local site = require 'gluon.site_config'
|
||||
local users = require 'gluon.users'
|
||||
local util = require 'gluon.util'
|
||||
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
local lutil = require 'luci.util'
|
||||
|
||||
local tunneldigger_enabled = uci:get_first('tunneldigger', 'broker', 'enabled')
|
||||
local fastd_enabled = uci:get('fastd', 'mesh_vpn', 'enabled')
|
||||
|
||||
local tunneldigger_installed = util.exec('sh' , '-c', 'opkg list-installed | grep -e \'^tunneldigger\'')
|
||||
local fastd_installed = util.exec('sh' , '-c', 'opkg list-installed | grep -e \'^fastd\'')
|
||||
|
||||
local enabled = 0
|
||||
|
||||
if (tonumber(tunneldigger_enable) == 1 or tonumber(fastd_enabled) == 1) then
|
||||
enabled = 1
|
||||
end
|
||||
|
||||
if (enabled == 1 and tunneldigger_installed == 0 and fastd_installed == 256) then
|
||||
uci:set("tunneldigger", uci:get_first("tunneldigger", "broker"), "enabled", enabled)
|
||||
uci:save("tunneldigger")
|
||||
uci:commit("tunneldigger")
|
||||
elseif (enabled == 1 and tunneldigger_installed == 256 and fastd_installed == 0) then
|
||||
uci:set("fastd", "mesh_vpn", "enabled", enabled)
|
||||
uci:save("fastd")
|
||||
uci:commit("fastd")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user