From bf7a2c974eea980a7671d221ba1383f3cd29aede Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 14 May 2014 16:53:48 +0200 Subject: [PATCH] gluon-legacy: don't use generated scripts anymore --- package/gluon-legacy/Makefile | 3 +- .../files/lib/gluon/legacy/legacy-upgrade | 13 +++++++ .../lib/gluon/legacy/legacy-upgrade-late | 8 +++++ .../config-mode/legacy/010-migrate-configured | 20 +++++++++++ .../gluon/upgrade/core/legacy/001-sysconfig | 4 ++- .../upgrade/core/legacy/011-gluon-network | 0 .../gluon/upgrade/core/legacy/020-wireless | 24 +++++++++++++ .../lock-password/legacy/010-lock-password | 0 .../upgrade/mesh-batman-adv/legacy/010-mesh | 22 ++++++++++++ .../legacy/010-reset-fastd-config | 35 +++++++++++++++++++ .../upgrade/simple-tc/legacy/010-migrate-tc | 27 ++++++++++++++ .../generate/lib/gluon/legacy/legacy-upgrade | 12 ------- .../lib/gluon/legacy/legacy-upgrade-late | 3 -- .../config-mode/legacy/010-migrate-configured | 14 -------- .../gluon/upgrade/core/legacy/020-wireless | 19 ---------- .../upgrade/mesh-batman-adv/legacy/010-mesh | 17 --------- .../legacy/010-reset-fastd-config | 28 --------------- .../upgrade/simple-tc/legacy/010-migrate-tc | 19 ---------- 18 files changed, 153 insertions(+), 115 deletions(-) create mode 100755 package/gluon-legacy/files/lib/gluon/legacy/legacy-upgrade create mode 100755 package/gluon-legacy/files/lib/gluon/legacy/legacy-upgrade-late create mode 100755 package/gluon-legacy/files/lib/gluon/upgrade/config-mode/legacy/010-migrate-configured rename package/gluon-legacy/{generate => files}/lib/gluon/upgrade/core/legacy/001-sysconfig (82%) rename package/gluon-legacy/{generate => files}/lib/gluon/upgrade/core/legacy/011-gluon-network (100%) create mode 100755 package/gluon-legacy/files/lib/gluon/upgrade/core/legacy/020-wireless rename package/gluon-legacy/{generate => files}/lib/gluon/upgrade/lock-password/legacy/010-lock-password (100%) create mode 100755 package/gluon-legacy/files/lib/gluon/upgrade/mesh-batman-adv/legacy/010-mesh create mode 100755 package/gluon-legacy/files/lib/gluon/upgrade/mesh-vpn-fastd/legacy/010-reset-fastd-config create mode 100755 package/gluon-legacy/files/lib/gluon/upgrade/simple-tc/legacy/010-migrate-tc delete mode 100755 package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade delete mode 100755 package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade-late delete mode 100755 package/gluon-legacy/generate/lib/gluon/upgrade/config-mode/legacy/010-migrate-configured delete mode 100755 package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/020-wireless delete mode 100755 package/gluon-legacy/generate/lib/gluon/upgrade/mesh-batman-adv/legacy/010-mesh delete mode 100755 package/gluon-legacy/generate/lib/gluon/upgrade/mesh-vpn-fastd/legacy/010-reset-fastd-config delete mode 100755 package/gluon-legacy/generate/lib/gluon/upgrade/simple-tc/legacy/010-migrate-tc diff --git a/package/gluon-legacy/Makefile b/package/gluon-legacy/Makefile index e0377bdb..d074f699 100644 --- a/package/gluon-legacy/Makefile +++ b/package/gluon-legacy/Makefile @@ -2,7 +2,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gluon-legacy PKG_VERSION:=1 -PKG_RELEASE:=1.$(GLUON_CONFIG_VERSION) PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) @@ -30,7 +29,7 @@ define Build/Compile endef define Package/gluon-legacy/install - $(GLUON_GENERATE) ./generate/* $(1)/ + $(CP) ./files/* $(1)/ endef $(eval $(call BuildPackage,gluon-legacy)) diff --git a/package/gluon-legacy/files/lib/gluon/legacy/legacy-upgrade b/package/gluon-legacy/files/lib/gluon/legacy/legacy-upgrade new file mode 100755 index 00000000..8ff8c495 --- /dev/null +++ b/package/gluon-legacy/files/lib/gluon/legacy/legacy-upgrade @@ -0,0 +1,13 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' + +local ret = 1 + +for _, file in pairs(site.legacy.version_files) do + if os.remove(file) then + ret = 0 + end +end + +os.exit(ret) diff --git a/package/gluon-legacy/files/lib/gluon/legacy/legacy-upgrade-late b/package/gluon-legacy/files/lib/gluon/legacy/legacy-upgrade-late new file mode 100755 index 00000000..08763a09 --- /dev/null +++ b/package/gluon-legacy/files/lib/gluon/legacy/legacy-upgrade-late @@ -0,0 +1,8 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' + + +for _, file in pairs(site.legacy.old_files) do + os.remove(file) +end diff --git a/package/gluon-legacy/files/lib/gluon/upgrade/config-mode/legacy/010-migrate-configured b/package/gluon-legacy/files/lib/gluon/upgrade/config-mode/legacy/010-migrate-configured new file mode 100755 index 00000000..18bdaf19 --- /dev/null +++ b/package/gluon-legacy/files/lib/gluon/upgrade/config-mode/legacy/010-migrate-configured @@ -0,0 +1,20 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' +local uci = require 'luci.model.uci' + +local c = uci.cursor() + + +for _, config in ipairs(site.legacy.config_mode_configs) do + local old = c:get_first(config, 'wizard', 'configured') + if old == '1' then + local wizard = c:get_first('gluon-config-mode', 'wizard') + c:set('gluon-config-mode', wizard, 'configured', '1') + + c:save('gluon-config-mode') + c:commit('gluon-config-mode') + + break + end +end diff --git a/package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/001-sysconfig b/package/gluon-legacy/files/lib/gluon/upgrade/core/legacy/001-sysconfig similarity index 82% rename from package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/001-sysconfig rename to package/gluon-legacy/files/lib/gluon/upgrade/core/legacy/001-sysconfig index c1bba31b..4fb4a39a 100755 --- a/package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/001-sysconfig +++ b/package/gluon-legacy/files/lib/gluon/upgrade/core/legacy/001-sysconfig @@ -24,7 +24,9 @@ remove_bat0() { sed -r -e 's/(^| )bat0( |$)/ /g' -e 's/^ | $//g' } -mesh_ifname="$(uci get 'network.@legacy.mesh_ifname@.ifname' | remove_bat0)" + +mesh_section="$(lua -e 'print(require("gluon.site_config").legacy.mesh_ifname)')" +mesh_ifname="$(uci get "network.${mesh_section}.ifname" | remove_bat0)" wan_ifname="$(uci get network.wan.ifname)" if [ -n "$wan_ifname" ] && iface_exists "$wan_ifname"; then diff --git a/package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/011-gluon-network b/package/gluon-legacy/files/lib/gluon/upgrade/core/legacy/011-gluon-network similarity index 100% rename from package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/011-gluon-network rename to package/gluon-legacy/files/lib/gluon/upgrade/core/legacy/011-gluon-network diff --git a/package/gluon-legacy/files/lib/gluon/upgrade/core/legacy/020-wireless b/package/gluon-legacy/files/lib/gluon/upgrade/core/legacy/020-wireless new file mode 100755 index 00000000..f6f9335f --- /dev/null +++ b/package/gluon-legacy/files/lib/gluon/upgrade/core/legacy/020-wireless @@ -0,0 +1,24 @@ +#!/usr/bin/lua + + +local site = require 'gluon.site_config' +local uci = require 'luci.model.uci' + + +local c = uci.cursor() + + +function delete_legacy_iface(iface) + for _, wifi in pairs(site.legacy.wifi_names) do + if wifi == iface['.name'] then + return true + end + end + + return false +end + +c:delete_all('wireless', 'wifi-iface', delete_legacy_iface) + +c:save('wireless') +c:commit('wireless') diff --git a/package/gluon-legacy/generate/lib/gluon/upgrade/lock-password/legacy/010-lock-password b/package/gluon-legacy/files/lib/gluon/upgrade/lock-password/legacy/010-lock-password similarity index 100% rename from package/gluon-legacy/generate/lib/gluon/upgrade/lock-password/legacy/010-lock-password rename to package/gluon-legacy/files/lib/gluon/upgrade/lock-password/legacy/010-lock-password diff --git a/package/gluon-legacy/files/lib/gluon/upgrade/mesh-batman-adv/legacy/010-mesh b/package/gluon-legacy/files/lib/gluon/upgrade/mesh-batman-adv/legacy/010-mesh new file mode 100755 index 00000000..45f27d94 --- /dev/null +++ b/package/gluon-legacy/files/lib/gluon/upgrade/mesh-batman-adv/legacy/010-mesh @@ -0,0 +1,22 @@ +#!/usr/bin/lua + + +local site = require 'gluon.site_config' +local uci = require 'luci.model.uci' + +local c = uci.cursor() + + +local s = c:get_all('network', site.legacy.mesh_ifname) +c:delete('network', site.legacy.mesh_ifname) + +s.auto = nil +s.accept_ra = nil +s.defaultroute = nil +s.proto = 'dhcpv6' +s.reqprefix = 'no' + +c:section('network', 'interface', 'client', s) + +c:save('network') +c:commit('network') diff --git a/package/gluon-legacy/files/lib/gluon/upgrade/mesh-vpn-fastd/legacy/010-reset-fastd-config b/package/gluon-legacy/files/lib/gluon/upgrade/mesh-vpn-fastd/legacy/010-reset-fastd-config new file mode 100755 index 00000000..730feea0 --- /dev/null +++ b/package/gluon-legacy/files/lib/gluon/upgrade/mesh-vpn-fastd/legacy/010-reset-fastd-config @@ -0,0 +1,35 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' +local uci = require 'luci.model.uci' + +local c = uci.cursor() + + +local secret +local enabled + + +for _, config in ipairs(site.legacy.fastd_configs) do + if not secret then + local s = c:get_all('fastd', config) + if s then + secret = s.secret + enabled = s.enabled + end + end + + c:delete('fastd', config) +end + +if secret then + c:section('fastd', 'fastd', 'mesh_vpn', + { + secret = secret, + enabled = enabled, + } + ) +end + +c:save('fastd') +c:commit('fastd') diff --git a/package/gluon-legacy/files/lib/gluon/upgrade/simple-tc/legacy/010-migrate-tc b/package/gluon-legacy/files/lib/gluon/upgrade/simple-tc/legacy/010-migrate-tc new file mode 100755 index 00000000..39dd5f5d --- /dev/null +++ b/package/gluon-legacy/files/lib/gluon/upgrade/simple-tc/legacy/010-migrate-tc @@ -0,0 +1,27 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' +local uci = require 'luci.model.uci' + +local c = uci.cursor() + + +for _, config in ipairs(site.legacy.tc_configs) do + local s = c:get_first(config, 'bandwidth') + if s then + old = c:get_all(config, s) + c:section('gluon-simple-tc', 'interface', 'mesh_vpn', + { + ifname = 'mesh-vpn', + enabled = old.enabled, + limit_ingress = old.downstream, + limit_egress = old.upstream, + } + ) + + c:save('gluon-simple-tc') + c:commit('gluon-simple-tc') + + break + end +end diff --git a/package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade b/package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade deleted file mode 100755 index 9f8ec1fb..00000000 --- a/package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -RET=1 - -for file in @legacy.version_files@; do - if [ -e "$file" ]; then - rm "$file" - RET=0 - fi -done - -exit $RET diff --git a/package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade-late b/package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade-late deleted file mode 100755 index 54419cb4..00000000 --- a/package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade-late +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -rm -f @legacy.old_files@ diff --git a/package/gluon-legacy/generate/lib/gluon/upgrade/config-mode/legacy/010-migrate-configured b/package/gluon-legacy/generate/lib/gluon/upgrade/config-mode/legacy/010-migrate-configured deleted file mode 100755 index 23c81fe0..00000000 --- a/package/gluon-legacy/generate/lib/gluon/upgrade/config-mode/legacy/010-migrate-configured +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - - -. /lib/functions.sh - - -for config in @legacy.config_mode_configs@; do - if [ "$(uci -q get "$config".configured)" = '1' ]; then - uci_set gluon-config-mode '@wizard[0]' 'configured' '1' - uci_commit gluon-config-mode - - break - fi -done diff --git a/package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/020-wireless b/package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/020-wireless deleted file mode 100755 index 8fe97308..00000000 --- a/package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/020-wireless +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -. /lib/functions.sh - -config_load wireless - -delete_legacy_iface() { - local iface="$1" - - for wifi in @legacy.wifi_names@; do - if [ "$wifi" = "$iface" ]; then - uci_remove wireless "$iface" - break - fi - done -} - -config_foreach delete_legacy_iface 'wifi-iface' -uci_commit wireless diff --git a/package/gluon-legacy/generate/lib/gluon/upgrade/mesh-batman-adv/legacy/010-mesh b/package/gluon-legacy/generate/lib/gluon/upgrade/mesh-batman-adv/legacy/010-mesh deleted file mode 100755 index 7a6995d5..00000000 --- a/package/gluon-legacy/generate/lib/gluon/upgrade/mesh-batman-adv/legacy/010-mesh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - - -. /lib/functions.sh -. /lib/gluon/functions/sysconfig.sh - - -uci_rename network '@legacy.mesh_ifname@' 'client' - -uci_remove network client auto -uci_remove network client accept_ra -uci_remove network client defaultroute - -uci_set network client proto 'dhcpv6' -uci_set network client reqprefix 'no' - -uci_commit network diff --git a/package/gluon-legacy/generate/lib/gluon/upgrade/mesh-vpn-fastd/legacy/010-reset-fastd-config b/package/gluon-legacy/generate/lib/gluon/upgrade/mesh-vpn-fastd/legacy/010-reset-fastd-config deleted file mode 100755 index 01818ec7..00000000 --- a/package/gluon-legacy/generate/lib/gluon/upgrade/mesh-vpn-fastd/legacy/010-reset-fastd-config +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -. /lib/functions.sh - - -SECRET= -ENABLED= - - -for config in @legacy.fastd_configs@; do - if [ -z "$SECRET" ]; then - SECRET="$(uci_get fastd "$config" secret)" - ENABLED="$(uci_get fastd "$config" enabled)" - fi - - uci_remove fastd "$config" -done - -if [ -n "$SECRET" ]; then - uci_add fastd fastd 'mesh_vpn' - uci_set fastd 'mesh_vpn' 'secret' "$SECRET" - - if [ "$ENABLED" = 1 ]; then - uci_set fastd 'mesh_vpn' 'enabled' '1' - fi -fi - -uci_commit fastd diff --git a/package/gluon-legacy/generate/lib/gluon/upgrade/simple-tc/legacy/010-migrate-tc b/package/gluon-legacy/generate/lib/gluon/upgrade/simple-tc/legacy/010-migrate-tc deleted file mode 100755 index d75060e7..00000000 --- a/package/gluon-legacy/generate/lib/gluon/upgrade/simple-tc/legacy/010-migrate-tc +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -. /lib/functions.sh - - -for config in @legacy.tc_configs@; do - if uci -q get "$config" >/dev/null; then - uci_add gluon-simple-tc interface 'mesh_vpn' - uci_set gluon-simple-tc 'mesh_vpn' ifname 'mesh-vpn' - - uci_set gluon-simple-tc 'mesh_vpn' enabled "$(uci get "$config".enabled)" - uci_set gluon-simple-tc 'mesh_vpn' limit_ingress "$(uci get "$config".downstream)" - uci_set gluon-simple-tc 'mesh_vpn' limit_egress "$(uci get "$config".upstream)" - - uci_commit gluon-simple-tc - - break - fi -done