source: MondoRescue/branches/3.3/mindi-busybox/examples/var_service/README@ 3621

Last change on this file since 3621 was 3621, checked in by Bruno Cornec, 7 years ago

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

File size: 3.3 KB
Line 
1In many cases, network configuration makes it necessary to run several daemons:
2dhcp, zeroconf, ppp, openvpn and such. They need to be controlled,
3and in many cases you also want to babysit them. runsvdir is a good tool for this.
4examples/var_service directory provides a few examples. It is meant to be used
5this way: copy it somewhere (say, /var/service) and run something like
6
7env - PATH=... <other vars=...> runsvdir /var/service &
8
9from one of system startup scripts. (Google "man runsvdir" and "man runsv"
10for more info about these tools).
11
12You can try or debug an individual service by running its SERVICE_DIR/run script.
13In this case, its stdout and stderr go to your terminal.
14
15You can also run "runsv SERVICE_DIR", which runs both the service
16and its logger service (SERVICE_DIR/log/run) if logger service exists.
17If logger service exists, the output will go to it instead of the terminal.
18
19"runsvdir DIR" merely runs "runsv SERVICE_DIR" for every subdirectory in DIR.
20
21Some existing examples:
22
23var_service/dhcp_if -
24controls a udhcpc instance which provides dhpc-assigned IP
25address on interface named "if". Copy/rename this directory as needed to run
26udhcpc on other interfaces (var_service/dhcp_if/run script uses _foo suffix
27of the parent directory as interface name). When IP address is obtained or lost,
28var_service/dhcp_if/dhcp_handler is run. It saves new config data to
29/var/run/service/fw/dhcp_if.ipconf and (re)starts /var/service/fw service.
30This example can be used as a template for other dynamic network link services
31(ppp/vpn/zcip).
32
33var_service/ifplugd_if -
34watches link status of interface if. Downs and ups /var/service/dhcp_if
35service accordingly. In effect, it allows you to unplug/plug-to-different-network
36and have your IP properly re-negotiated at once.
37
38var_service/dhcp_if_pinger -
39Uses var_service/dhcp_if's data to determine router IP. Pings it.
40If ping fails, restarts /var/service/dhcp_if service.
41Basically, an example of watchdog service for networks which are not reliable
42and need babysitting.
43
44var_service/fw -
45A *one-shot* service which reconfigures network based on current known state
46of ALL interfaces. Uses conf/*.ipconf (static config) and /var/run/service/fw/*.ipconf
47(dynamic config from dhcp/ppp/vpn/etc) to determine what to do.
48One-shot-ness of this service means that it shuts itself off after single run.
49IOW: it is not a constantly running daemon sort of thing.
50It starts, it configures the network, it shuts down, all done
51(unlike infamous NetworkManagers which sit in RAM forever, doing hell knows what).
52
53However, any dhcp/ppp/vpn or similar service can restart it anytime
54when it senses the change in network configuration.
55This even works while fw service runs: if dhcp signals fw to (re)start
56while fw runs, fw will not stop after its execution, but will re-execute once,
57picking up dhcp's new configuration.
58This is achieved very simply by having
59 # Make ourself one-shot
60 sv o .
61at the very beginning of fw/run script, not at the end.
62Therefore, any "sv u /var/run/service/fw" command by any other
63script "undoes" o(ne-shot) command if fw still runs, thus
64runsv will rerun it; or start it in a normal way if fw is not running.
65
66System administrators are expected to edit fw/run script, since
67network configuration needs are likely to be very complex and different
68for non-trivial installations.
Note: See TracBrowser for help on using the repository browser.