diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-10-03 23:43:44 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-10-03 23:43:44 +0200 |
| commit | 095ddf7669a05b52839ccbfd2c324de718241747 (patch) | |
| tree | 61fe4384e08985b5a217f9d4456da3e51875f606 /examples | |
| parent | 7f0ebbc69ed14b2f35e8bc62b03612b94e270955 (diff) | |
| download | busybox-w32-095ddf7669a05b52839ccbfd2c324de718241747.tar.gz busybox-w32-095ddf7669a05b52839ccbfd2c324de718241747.tar.bz2 busybox-w32-095ddf7669a05b52839ccbfd2c324de718241747.zip | |
examples: add example of a DHCP server
As usual, by multiplying directories - "dhcpd_eth0", "dhcpd_wlan1"
you can run many servers on different interfaces.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/var_service/dhcpd_if/README | 5 | ||||
| -rwxr-xr-x | examples/var_service/dhcpd_if/log/run | 21 | ||||
| -rwxr-xr-x | examples/var_service/dhcpd_if/p_log | 4 | ||||
| -rwxr-xr-x | examples/var_service/dhcpd_if/run | 23 | ||||
| -rw-r--r-- | examples/var_service/dhcpd_if/udhcpc.conf | 28 | ||||
| -rwxr-xr-x | examples/var_service/dhcpd_if/w_dumpleases | 3 | ||||
| -rwxr-xr-x | examples/var_service/dhcpd_if/w_dumpleases_countdown | 3 | ||||
| -rwxr-xr-x | examples/var_service/dhcpd_if/w_log | 4 |
8 files changed, 91 insertions, 0 deletions
diff --git a/examples/var_service/dhcpd_if/README b/examples/var_service/dhcpd_if/README new file mode 100644 index 000000000..4ddccb22d --- /dev/null +++ b/examples/var_service/dhcpd_if/README | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | The real README file is one directory up. | ||
| 2 | |||
| 3 | This directory's run script can have useful comments. | ||
| 4 | If it doesn't but you feel it should, please send a patch | ||
| 5 | to busybox's mailing list. | ||
diff --git a/examples/var_service/dhcpd_if/log/run b/examples/var_service/dhcpd_if/log/run new file mode 100755 index 000000000..69d74b73f --- /dev/null +++ b/examples/var_service/dhcpd_if/log/run | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | user=logger | ||
| 4 | |||
| 5 | logdir="/var/log/service/`(cd ..;basename $PWD)`" | ||
| 6 | mkdir -p "$logdir" 2>/dev/null | ||
| 7 | chown -R "$user": "$logdir" | ||
| 8 | chmod -R go-rwxst,u+rwX "$logdir" | ||
| 9 | rm -rf logdir | ||
| 10 | ln -s "$logdir" logdir | ||
| 11 | |||
| 12 | # make this dir accessible to logger | ||
| 13 | chmod a+rX . | ||
| 14 | |||
| 15 | exec >/dev/null | ||
| 16 | exec 2>&1 | ||
| 17 | exec \ | ||
| 18 | env - PATH="$PATH" \ | ||
| 19 | softlimit \ | ||
| 20 | setuidgid "$user" \ | ||
| 21 | svlogd -tt "$logdir" | ||
diff --git a/examples/var_service/dhcpd_if/p_log b/examples/var_service/dhcpd_if/p_log new file mode 100755 index 000000000..a2521be05 --- /dev/null +++ b/examples/var_service/dhcpd_if/p_log | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | cd log/logdir || exit 1 | ||
| 4 | cat @* current | $PAGER | ||
diff --git a/examples/var_service/dhcpd_if/run b/examples/var_service/dhcpd_if/run new file mode 100755 index 000000000..de85dece0 --- /dev/null +++ b/examples/var_service/dhcpd_if/run | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | exec 2>&1 | ||
| 4 | exec </dev/null | ||
| 5 | |||
| 6 | pwd="$PWD" | ||
| 7 | |||
| 8 | if="${PWD##*/dhcpd_}" | ||
| 9 | |||
| 10 | echo "* Upping iface $if" | ||
| 11 | ip link set dev $if up | ||
| 12 | |||
| 13 | >>udhcpd.leases | ||
| 14 | sed 's/^interface.*$/interface '"$if/" -i udhcpc.conf | ||
| 15 | |||
| 16 | echo "* Starting udhcpd" | ||
| 17 | exec \ | ||
| 18 | env - PATH="$PATH" \ | ||
| 19 | softlimit \ | ||
| 20 | setuidgid root \ | ||
| 21 | udhcpd -f -vv udhcpc.conf | ||
| 22 | |||
| 23 | exit $? | ||
diff --git a/examples/var_service/dhcpd_if/udhcpc.conf b/examples/var_service/dhcpd_if/udhcpc.conf new file mode 100644 index 000000000..a81925970 --- /dev/null +++ b/examples/var_service/dhcpd_if/udhcpc.conf | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | # Directives with defaults: | ||
| 2 | # start 192.168.0.20 | ||
| 3 | # end 192.168.0.254 | ||
| 4 | # interface eth0 | ||
| 5 | # max_leases 235 | ||
| 6 | # auto_time 7200 | ||
| 7 | # decline_time 3600 | ||
| 8 | # conflict_time 3600 | ||
| 9 | # offer_time 60 | ||
| 10 | # min_lease 60 | ||
| 11 | # lease_file /var/lib/misc/udhcpd.leases | ||
| 12 | # pidfile /var/run/udhcpd.pid | ||
| 13 | # siaddr 0.0.0.0 | ||
| 14 | # | ||
| 15 | # Directives with no defaults (or with empty defaults): | ||
| 16 | # option/opt NAME VALUE | ||
| 17 | # notify_file /path/to/script_to_run_after_leasefile_is_written | ||
| 18 | # (it is run with $1 = lease_file_name) | ||
| 19 | # sname dhcp_packet_sname_field_contents | ||
| 20 | # boot_file dhcp_packet_bootfile_field_contents | ||
| 21 | # static_lease XX:XX:XX:XX:XX:XX IP.ADD.RE.SS | ||
| 22 | |||
| 23 | interface if | ||
| 24 | pidfile /dev/null | ||
| 25 | lease_file udhcpd.leases | ||
| 26 | option subnet 255.255.255.0 | ||
| 27 | option lease 3600 | ||
| 28 | #option router 192.168.0.1 | ||
diff --git a/examples/var_service/dhcpd_if/w_dumpleases b/examples/var_service/dhcpd_if/w_dumpleases new file mode 100755 index 000000000..ff772055a --- /dev/null +++ b/examples/var_service/dhcpd_if/w_dumpleases | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | watch -n1 'dumpleases -af udhcpd.leases' | ||
diff --git a/examples/var_service/dhcpd_if/w_dumpleases_countdown b/examples/var_service/dhcpd_if/w_dumpleases_countdown new file mode 100755 index 000000000..7fcd9602a --- /dev/null +++ b/examples/var_service/dhcpd_if/w_dumpleases_countdown | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | watch -n1 'dumpleases -f udhcpd.leases' | ||
diff --git a/examples/var_service/dhcpd_if/w_log b/examples/var_service/dhcpd_if/w_log new file mode 100755 index 000000000..dba76c69b --- /dev/null +++ b/examples/var_service/dhcpd_if/w_log | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | cd log/logdir | ||
| 4 | watch -n1 'w=`ttysize w`; h=`ttysize h`; tail -$((h-3)) current 2>&1 | cut -b0-$((w-2))' | ||
