lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # usage: see function usage() |
| 4 | |
| 5 | path_sh=`nv get path_sh` |
| 6 | . $path_sh/global.sh |
| 7 | |
| 8 | |
| 9 | usage () { |
| 10 | echo "usage: config-udhcpd.sh [option]..." |
| 11 | echo "options:" |
| 12 | echo " -h : print this help" |
| 13 | echo " -c : clean the conf file" |
| 14 | echo " -u interface : set upstream interface for server" |
| 15 | echo " -d interface1 [interface2].. : set downstream interface for client" |
| 16 | echo " -s addr : set gateway of upstream interface" |
| 17 | echo " -r : run igmpproxy" |
| 18 | exit |
| 19 | } |
| 20 | |
| 21 | config () { |
| 22 | case "$1" in |
| 23 | "-c") |
| 24 | sed -i '36,$d' $fname;; |
| 25 | "-u") |
| 26 | sed -i "30c phyint $2 upstream ratelimit 0 threshold 1" $fname;; |
| 27 | "-d") |
| 28 | sed -i '$a phyint '"$2"' downstream ratelimit 0 threshold 1' $fname |
| 29 | sed -i '$a' $fname;; |
| 30 | "-s") |
| 31 | sed -i "31c altnet $2/24" $fname;; |
| 32 | |
| 33 | esac |
| 34 | |
| 35 | } |
| 36 | |
| 37 | |
| 38 | fname=$path_conf"/igmpproxy.conf" |
| 39 | |
| 40 | case "$1" in |
| 41 | |
| 42 | |
| 43 | "-h") usage;; |
| 44 | "-c") config "$1";; |
| 45 | "-u") config "$1" "$2";; |
| 46 | "-s") config "$1" "$2";; |
| 47 | "-d") config "$1" "$2" "$3" "$4";; |
| 48 | "-r") igmpproxy& ;; |
| 49 | *) usage;; |
| 50 | esac |
| 51 | |
| 52 | |