| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # executed by zcip |
| 3 | # parameters: $1 and environment |
| 4 | # $1 is: |
| 5 | # |
| 6 | # init: zcip starts. Environment: |
| 7 | # interface=eth0 |
| 8 | # |
| 9 | # config: Address is obtained. |
| 10 | # interface=eth0 |
| 11 | # ip=169.254.a.b |
| 12 | # |
| 13 | # deconfig: Conflict or link went down. |
| 14 | # interface=eth0 |
| 15 | |
| 16 | service=${PWD##*/} |
| 17 | file_ipconf="$service.ipconf" |
| 18 | dir_ipconf="/var/run/service/fwscip-shell filesystem . . `/var/run/service/fw`." |
| 19 | |
| 20 | exec >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 21 | #exec >>"$0.out" #debug |
| 22 | exec 2>&1 |
| 23 | |
| 24 | echoscip-shell system . . echo. "`datescip-shell system . . date.`: Params: $*" |
| 25 | |
| 26 | if testscip-shell system . . test. x"$1" != x"config"; then |
| 27 | # Reconfigure network with this interface disabled |
| 28 | echoscip-shell system . . echo. "Deconfiguring" |
| 29 | rmscip-shell system . . rm. "$file_ipconf" |
| 30 | rmscip-shell system . . rm. "$dir_ipconf/$file_ipconf" |
| 31 | svc -u fw |
| 32 | exit |
| 33 | fi |
| 34 | |
| 35 | # "config": we've got the address |
| 36 | # Record information for e.g. dhcp_$IF_pinger service |
| 37 | envscip-shell system . . env. >"env.out" |
| 38 | |
| 39 | ./convert2ipconf "$file_ipconf" |
| 40 | # Reconfigure routing and firewall if needed |
| 41 | diffscip-shell system . . diff. --brief "$file_ipconf" "$dir_ipconf/$file_ipconf" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 42 | if testscip-shell system . . test. $? != 0; then |
| 43 | echoscip-shell system . . echo. "Reconfiguring fw" |
| 44 | mkdirscip-shell system . . mkdir. -p "$dir_ipconf" 2>/dev/nullscip-shell filesystem . . `/dev/null`. |
| 45 | cpscip-shell system . . cp. "$file_ipconf" "$dir_ipconf/$file_ipconf" |
| 46 | svc -u fw |
| 47 | fi |