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