2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by scripts/Create-CopyPatch.
5 # T2 SDE: package/.../rocknet/rocknet.sh
6 # Copyright (C) 2004 - 2020 The T2 SDE Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
17 rocknet_base
="/lib/network"
18 rocknet_config
="/etc/conf"
19 rocknet_tmp_base
="/var/run/rocknet"
21 [ -d $rocknet_tmp_base ] || mkdir
-p $rocknet_tmp_base
23 unset code_snipplets_idx code_snipplets_dat code_snipplets_counter
24 declare -a code_snipplets_idx
='()'
25 declare -a code_snipplets_dat
='()'
26 code_snipplets_counter
=0
32 if [ "$3" != "up" -a "$3" != "down" ]; then
33 echo "Usage: $0 { profile | default } { interface | auto } { up | down }"
37 if [ ! -f $rocknet_config/network
]; then
38 echo "Configuration file \"$rocknet_config/network\" missing."
46 pmatched
=0 # some profile matched ?
47 imatched
=0 # some interface matched ?
50 # addcode mode major-priority minor-priority code1
53 [ "$mode" != "$1" ] && return
54 [ "$ignore" -gt 0 ] && return
55 if [ "$1" = "up" ]; then udo
="+"; else udo
="-"; fi
56 code_snipplets_idx
[code_snipplets_counter
]="`
57 printf '%04d.%04d.%04d' $((5000$udo$2)) $((5000$udo$lineno)) \
58 $((5000$udo$3))` $code_snipplets_counter"
59 code_snipplets_dat
[code_snipplets_counter
]="$4"
60 (( code_snipplets_counter
++ ))
67 [ "$ignore" -gt 0 ] && return 0
69 eval "isfirst_$1='return 1'"
85 # register / unregister active interfaces for user input validation
89 echo -n "${1}," >> $rocknet_tmp_base/active-interfaces
93 active_interfaces
="`cat $rocknet_tmp_base/active-interfaces 2>/dev/null`"
94 active_interfaces
="${active_interfaces//${1},/}"
95 echo -n "$active_interfaces" > $rocknet_tmp_base/active-interfaces
98 for x
in $rocknet_base/*.sh
; do .
"$x"; done
104 if [ -n "$cmd" ]; then
106 para
="$( echo "$para" | sed 's,[\*\?],\\&,g' )"
107 if declare -f public_
$cmd > /dev
/null
109 # optimization: Only execute commands when they are
110 # inside an unignored interface section ...
111 if [ $cmd = "interface" ] ; then
114 elif [ $ignore -eq 0 -o $global -gt 0 ] ; then
118 error
"Unknown statement in config file: $cmd"
121 done < <( sed 's,\(^\|[ \t]\)#.*$,,' < $rocknet_config/network
)
123 while read id1 id2
; do
124 if [ "$rocknet_debug" = 1 ]; then
125 echo ">> $id1 -> $id2: ${code_snipplets_dat[id2]}"
127 eval "${code_snipplets_dat[id2]}"
129 for x
in "${code_snipplets_idx[@]}"; do echo "$x"
133 if [ "$pmatched" = 0 -a "$profile" != "default" ]; then
134 error
"Unknown profile: '$profile'"
137 if [ "$imatched" = 0 ]; then
138 error
"Unknown interface for profile: '$interface'"