From bf85573c4e88fc8e7f23a32c17a4f7b6118819fd Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 18 Aug 2018 17:16:13 +0200 Subject: Fix wrong wanip6ll generation and add fence instead of genereating a broken config file --- build-openwrt-dev.sh | 6 +++++- build-openwrt.sh | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build-openwrt-dev.sh b/build-openwrt-dev.sh index 9f2021c..4338bfa 100755 --- a/build-openwrt-dev.sh +++ b/build-openwrt-dev.sh @@ -52,7 +52,11 @@ lanip4addr=$3 ip6prefix=$4 wanip6addr=${ip6prefix}1/56 lanip6addr=${ip6prefix%%0::}1::1/64 -wanip6ll=$(echo $ip6prefix | sed -e 's#.*:\(....:....\)::$#fe80::\1/64#') +wanip6ll=$(echo $ip6prefix | sed -ne 's#.*:\([0-9a-f]\{1,4\}:[0-9a-f]\{1,4\}\)::$#fe80::\1/64#pi') +if [ -z "$wanip6ll" ] +then echo "Error while generating link-local WAN IPv6 address" + exit 2 +fi if [ '$1$' = "${5:0:3}" ] then root_password=$5 diff --git a/build-openwrt.sh b/build-openwrt.sh index e5c1019..939d21d 100755 --- a/build-openwrt.sh +++ b/build-openwrt.sh @@ -52,7 +52,11 @@ lanip4addr=$3 ip6prefix=$4 wanip6addr=${ip6prefix}1/56 lanip6addr=${ip6prefix%%0::}1::1/64 -wanip6ll=$(echo $ip6prefix | sed -e 's#.*:\(....:....\)::$#fe80::\1/64#') +wanip6ll=$(echo $ip6prefix | sed -ne 's#.*:\([0-9a-f]\{1,4\}:[0-9a-f]\{1,4\}\)::$#fe80::\1/64#pi') +if [ -z "$wanip6ll" ] +then echo "Error while generating link-local WAN IPv6 address" + exit 2 +fi if [ '$1$' = "${5:0:3}" ] then root_password=$5 -- cgit v1.1