blob: b33ee2918b1efff1d3c745a3627bca7f483feb4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/bin/sh
OPENVPN_PKG="/etc/config/openvpn"
NETWORK_PKG="/etc/config/network"
[ -f "$OPENVPN_PKG" ] || exit 0
awk '
function section_exists(name) {
cmd = "uci -q get network." name " >/dev/null 2>&1"
return (system(cmd) == 0)
}
BEGIN {
in_section=0
secname = ""
}
/^config[ \t]+openvpn[ \t]+/ {
# get section name
secname = $3
gsub(/'\''/, "", secname)
if (section_exists(secname)) {
in_section=0
next
}
in_section=1
sub(/^config[ \t]+openvpn/, "config interface")
print
print "\toption proto '\''openvpn'\''"
next
}
# Start of another section
/^config[ \t]+/ {
in_section=0
}
# Inside openvpn section, rename proto
in_section && /^[ \t]*option[ \t]+proto[ \t]/ {
sub(/option[ \t]+proto/, "option ovpnproto")
print
next
}
# Inside openvpn section; copy as-is
in_section {
print
}
' "$OPENVPN_PKG" >> "$NETWORK_PKG"
exit 0
|