Add gluon-legacy package with legacy upgrade scripts
This commit is contained in:
parent
65c7db78fd
commit
2454c8abb7
@ -1,3 +1,3 @@
|
||||
config wizard
|
||||
option enabled '1'
|
||||
option enabled '0'
|
||||
option configured '0'
|
||||
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
OLD_CFG=/etc/config/config_mode
|
||||
NEW_CFG=/etc/config/gluon-config-mode
|
||||
|
||||
[ -f $OLD_CFG ] && mv $OLD_CFG $NEW_CFG
|
@ -5,6 +5,13 @@ UPGRADE_DIR=/lib/gluon/upgrade
|
||||
VERSION_DIR=/lib/gluon/version
|
||||
|
||||
|
||||
if [ -x /lib/gluon/legacy/legacy-upgrade ] && /lib/gluon/legacy/legacy-upgrade; then
|
||||
HAS_LEGACY=1
|
||||
else
|
||||
HAS_LEGACY=
|
||||
fi
|
||||
|
||||
|
||||
mkdir -p "$VERSION_DIR"
|
||||
|
||||
|
||||
@ -33,7 +40,11 @@ do_component() {
|
||||
|
||||
local oldversion="$(oldversion_of "$component")"
|
||||
if [ -z "$oldversion" ]; then
|
||||
if [ "$HAS_LEGACY" ]; then
|
||||
do_dir legacy
|
||||
else
|
||||
do_dir initial
|
||||
fi
|
||||
else
|
||||
local v
|
||||
|
||||
@ -62,3 +73,7 @@ for component in *; do
|
||||
[ "$component" != 'core' ] || continue
|
||||
do_component "$component"
|
||||
done
|
||||
|
||||
if [ "$HAS_LEGACY" ]; then
|
||||
/lib/gluon/legacy/legacy-upgrade-late
|
||||
fi
|
||||
|
36
package/gluon-legacy/Makefile
Normal file
36
package/gluon-legacy/Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=gluon-legacy
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1.$(GLUON_CONFIG_VERSION)
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/gluon-legacy
|
||||
SECTION:=gluon
|
||||
CATEGORY:=Gluon
|
||||
TITLE:=Legacy update scripts
|
||||
DEPENDS:=+gluon-legacy
|
||||
endef
|
||||
|
||||
define Package/gluon-legacy/description
|
||||
Gluon community wifi mesh firmware framework: legacy update scripts
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/gluon-legacy/install
|
||||
$(GLUON_GENERATE) ./generate/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,gluon-legacy))
|
12
package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade
Executable file
12
package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
RET=1
|
||||
|
||||
for file in @legacy.version_files@; do
|
||||
if [ -e "$file" ]; then
|
||||
rm "$file"
|
||||
RET=0
|
||||
fi
|
||||
done
|
||||
|
||||
exit $RET
|
3
package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade-late
Executable file
3
package/gluon-legacy/generate/lib/gluon/legacy/legacy-upgrade-late
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm -f @legacy.old_files@
|
@ -0,0 +1,14 @@
|
||||
#!/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
|
37
package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/001-sysconfig
Executable file
37
package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/001-sysconfig
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/gluon/functions/sysconfig.sh
|
||||
. /lib/ar71xx.sh
|
||||
|
||||
|
||||
get_primary_mac() {
|
||||
case "$(ar71xx_board_name)" in
|
||||
tl-wdr3600|tl-wdr4300)
|
||||
cat /sys/class/ieee80211/phy1/macaddress
|
||||
;;
|
||||
*)
|
||||
cat /sys/class/ieee80211/phy0/macaddress
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
iface_exists() {
|
||||
local name="$1"
|
||||
ip link show dev "${name//.*/}" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
remove_bat0() {
|
||||
sed -r -e 's/(^| )bat0( |$)/ /g' -e 's/^ | $//g'
|
||||
}
|
||||
|
||||
mesh_ifname="$(uci get 'network.@legacy.mesh_ifname@.ifname' | remove_bat0)"
|
||||
wan_ifname="$(uci get network.wan.ifname | remove_bat0)"
|
||||
|
||||
if [ -n "$wan_ifname" ] && iface_exists "$wan_ifname"; then
|
||||
[ -z "$mesh_ifname" ] || sysconfig_set lan_ifname "$mesh_ifname"
|
||||
sysconfig_set wan_ifname "$wan_ifname"
|
||||
else
|
||||
sysconfig_set wan_ifname "$mesh_ifname"
|
||||
fi
|
||||
|
||||
sysconfig_set primary_mac "$(get_primary_mac)"
|
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/gluon/functions/sysconfig.sh
|
||||
|
||||
|
||||
case "$(ar71xx_board_name)" in
|
||||
tl-wr1043nd|\
|
||||
tl-wdr3600|\
|
||||
tl-wdr4300) # fix up duplicate mac addresses
|
||||
local mainaddr=$(sysconfig primary_mac)
|
||||
local oIFS="$IFS"; IFS=":"; set -- $mainaddr; IFS="$oIFS"
|
||||
local b2mask=0x02
|
||||
|
||||
local wanaddr=$(printf "%02x:%s:%s:%02x:%s:%02x" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $(( (0x$6 + 1) % 0x100 )) )
|
||||
|
||||
uci_set network wan macaddr "$wanaddr"
|
||||
;;
|
||||
esac
|
||||
|
||||
uci_commit network
|
19
package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/020-wireless
Executable file
19
package/gluon-legacy/generate/lib/gluon/upgrade/core/legacy/020-wireless
Executable file
@ -0,0 +1,19 @@
|
||||
#!/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
|
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
has_root_pwd() {
|
||||
local pwd=$([ -f "$1" ] && cat "$1")
|
||||
pwd="${pwd#*root:}"
|
||||
pwd="${pwd%%:*}"
|
||||
|
||||
test -n "${pwd#[\!x]}"
|
||||
}
|
||||
|
||||
|
||||
has_root_pwd /etc/passwd || has_root_pwd /etc/shadow || passwd -l root
|
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/gluon/functions/sysconfig.sh
|
||||
|
||||
|
||||
uci_rename network '@legacy.mesh_ifname@' 'client'
|
||||
|
||||
if [ "$(uci_get network client proto)" = 'none' ]; then
|
||||
uci_remove network client auto
|
||||
uci_remove network client accept_ra
|
||||
|
||||
uci_set network client proto 'dhcpv6'
|
||||
uci_set network client reqprefix 'no'
|
||||
fi
|
||||
|
||||
uci_commit network
|
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
|
||||
SECRET=
|
||||
|
||||
|
||||
for config in @legacy.fastd_configs@; do
|
||||
if [ -z "$SECRET" ]; then
|
||||
SECRET="$(uci_get fastd "$config" secret)"
|
||||
fi
|
||||
|
||||
uci_remove fastd "$config"
|
||||
done
|
||||
|
||||
if [ -n "$SECRET" ]; then
|
||||
uci_add fastd fastd 'mesh_vpn'
|
||||
uci_set fastd 'mesh_vpn' 'secret' "$SECRET"
|
||||
fi
|
||||
|
||||
uci_commit fastd
|
@ -0,0 +1,19 @@
|
||||
#!/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
|
@ -25,9 +25,6 @@ add_user gluon-fastd 800
|
||||
|
||||
uci_add fastd fastd mesh_vpn
|
||||
|
||||
uci_remove fastd mesh_vpn config
|
||||
uci_remove fastd mesh_vpn config_peer_dir
|
||||
|
||||
uci_set fastd mesh_vpn user 'gluon-fastd'
|
||||
uci_set fastd mesh_vpn syslog_level 'verbose'
|
||||
uci_set fastd mesh_vpn interface 'mesh-vpn'
|
||||
|
Loading…
Reference in New Issue
Block a user