Skip to content

Commit 3f9cdaa

Browse files
committed
added extraction for node ipv6 ip for PirateBox config
1 parent 576be17 commit 3f9cdaa

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/sh
2+
#
3+
# AutoConfiguration via USB file
4+
#
5+
# Prints out the PirateBox Node IP and changes it
6+
# DOES NOT change IP in OPENWRT network config
7+
#
8+
# Available global variables
9+
# CONFIG_TMP_STORE
10+
# CONFIG_STORE
11+
12+
13+
#uncommend the following line for REAL modules
14+
MODULE_LIST="$MODULE_LIST piratebox_node_ip"
15+
16+
piratebox_node_ip_myself="piratebox_node_ip" #contains the name of the module
17+
piratebox_node_ip_config_file="piratebox_node_ip.txt"
18+
19+
node_config=/opt/piratebox/conf/node.conf
20+
21+
# Read configuration out of the system and save it to piratebox_node_ip_system_config depending on the
22+
# parameter
23+
func_read_system_config_piratebox_node_ip() {
24+
local path=$1 ; shift
25+
26+
echo "Extracting Node-IPv6 IP parameter from $node_config"
27+
config_line=$(grep NODE_IPV6_IP=\" $node_config )
28+
#extract value
29+
config_line=${config_line#NODE_IPV6_IP=\'}
30+
config_value=${config_line%\'}
31+
32+
echo $config_value > $path/$piratebox_node_ip_config_file
33+
}
34+
35+
# Parse the first parameter with the changed value
36+
# do the stuff you need to do for changing the configuratioj
37+
func_set_system_config_piratebox_node_ip(){
38+
local value=$1 ; shift
39+
local old_value=$1; shift
40+
41+
echo "Changing PirateBox node ipv6 ip ..."
42+
sed "s|NODE_IPV6_IP='$old_value'|NODE_IPV6_IP='$value'|" -i $node_config
43+
44+
}
45+
46+
47+
#This function is called to compare content and et differences
48+
# to initiate a restart in the end, set "changed=1"
49+
# the easiest comparison can be used with auto_default_compare
50+
# see below
51+
func_compare_and_set_piratebox_node_ip(){
52+
53+
auto_config_lookup_and_set "$piratebox_node_ip_myself" \
54+
"$cfg_auto_folder/$piratebox_node_ip_config_file" \
55+
"$cfg_tmp_folder/$piratebox_node_ip_config_file"
56+
57+
}

0 commit comments

Comments
 (0)