3
0

zcip_handler 986 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/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. service=${PWD##*/}
  16. file_ipconf="$service.ipconf"
  17. dir_ipconf="/var/run/service/fw"
  18. exec >/dev/null
  19. #exec >>"$0.out" #debug
  20. exec 2>&1
  21. echo "`date`: Params: $*"
  22. if test x"$1" != x"config"; then
  23. # Reconfigure network with this interface disabled
  24. echo "Deconfiguring"
  25. rm "$file_ipconf"
  26. rm "$dir_ipconf/$file_ipconf"
  27. svc -u fw
  28. exit
  29. fi
  30. # "config": we've got the address
  31. # Record information for e.g. dhcp_$IF_pinger service
  32. env >"env.out"
  33. ./convert2ipconf "$file_ipconf"
  34. # Reconfigure routing and firewall if needed
  35. diff --brief "$file_ipconf" "$dir_ipconf/$file_ipconf" >/dev/null 2>&1
  36. if test $? != 0; then
  37. echo "Reconfiguring fw"
  38. mkdir -p "$dir_ipconf" 2>/dev/null
  39. cp "$file_ipconf" "$dir_ipconf/$file_ipconf"
  40. svc -u fw
  41. fi