Commit Graph

57 Commits

Author SHA1 Message Date
Denys Vlasenko
1e9a4f56f5 examples/var_service: use "exec sleep 5" instead of "{ sleep 5; exit; }"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-21 14:30:19 +02:00
Denys Vlasenko
1e474d3d93 service examples: if iface do not exist, retry upping it
I've had a case of a machine where eth0 was appearing a bit later
after the boot, and appearing _downed_. ifplugd then fails to detect
"link up". Thus, depending on how service startup
("ip link set dev eth0 up") races with driver initialization,
ethernet randomly fails to initialize on boot.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-05 18:41:48 +02:00
Denys Vlasenko
5a387e26c2 dhcp service example: rewrite "private network to mask" as case statement
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-02-08 10:37:05 +01:00
Denys Vlasenko
2feaba1d8d dhcp service example: cater for servers hot giving subnet and/or router
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-02-05 17:48:24 +01:00
Denys Vlasenko
e17e8d4b7d service examples: do not respawn supplicant too often
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-02-02 19:06:19 +01:00
Denys Vlasenko
f7235cc89f service examples: ifplugd -M to prevents frequent respawning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-18 14:17:02 +01:00
Denys Vlasenko
871bd2abac examples/var_service: add /var/run flag file to ntp.script
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-26 13:45:33 +02:00
Denys Vlasenko
14339191af examples/var_service/: use standard logger script, viewer and pager scripts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-03 23:23:09 +02:00
Denys Vlasenko
aa75a7da7f examples/var_service/: use "svc" for service commands, other tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-03 17:02:50 +02:00
Denys Vlasenko
e56e091d65 examples: update /var/service/getty for Unicode ttys
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-23 13:55:13 +02:00
Denys Vlasenko
a40a661d97 tweak /var/service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-20 22:43:42 +02:00
Denys Vlasenko
816d8d7a66 setlogcons: open /dev/ttyN for "setlogcons N", not /dev/tty1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-16 21:48:32 +02:00
Denys Vlasenko
df65dc89b4 examples/var_service: new example: dnsmasq service
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30 20:49:16 +02:00
Denys Vlasenko
0d79d7709d svok: new applet (daemontools compat)
function                                             old     new   delta
svok_main                                              -     127    +127
packed_usage                                       32705   32757     +52
applet_names                                        2756    2761      +5
applet_main                                         1588    1592      +4
bb_banner                                             46      47      +1
sv                                                  1286    1284      -2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/1 up/down: 189/-2)            Total: 187 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30 20:02:33 +02:00
Denys Vlasenko
d892f7137f ifplugd service example: always run up/down script on startup
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30 11:14:46 +02:00
Denys Vlasenko
3293bc1469 udhcpd: fix "not dying on SIGTERM"
Fixes:
	commit 52a515d187
	"udhcp: use poll() instead of select()"
	Feb 16 2017

udhcp_sp_read() is meant to check whether signal pipe indeed has some data to read.
In the above commit, it was changed as follows:

-	if (!FD_ISSET(signal_pipe.rd, rfds))
+	if (!pfds[0].revents)
		return 0;

The problem is, the check was working for select() purely by accident.
Caught signal interrupts select()/poll() syscalls, they return with EINTR
(regardless of SA_RESTART flag in sigaction). _Then_ signal handler is invoked.
IOW: they can't see any changes to fd state caused by signal haldler
(in our case, signal handler makes signal pipe ready to be read).

For select(), it means that rfds[] bit array is unmodified, bit of signal
pipe's read fd is still set, and the above check "works": it thinks select()
says there is data to read.

This accident does not work for poll(): .revents stays clear, and we do not
try reading signal pipe as we should. In udhcpd, we fall through and block
in socket read. Further SIGTERM signals simply cause socket read to be
interrupted and then restarted (since SIGTERM handler has SA_RESTART=1).

Fixing this as follows: remove the check altogether. Set signal pipe read fd
to nonblocking mode. Always read it in udhcp_sp_read().
If read fails, assume it's EAGAIN and return 0 ("no signal seen").

udhcpd avoids reading signal pipe on every recvd packet by looping if EINTR
(using safe_poll()) - thus ensuring we have correct .revents for all fds -
and calling udhcp_sp_read() only if pfds[0].revents!=0.

udhcpc performs much fewer reads (typically it sleeps >99.999% of the time),
there is no need to optimize it: can call udhcp_sp_read() after each poll
unconditionally.

To robustify socket reads, unconditionally set pfds[1].revents=0
in udhcp_sp_fd_set() (which is before poll), and check it before reading
network socket in udhcpd.

TODO:
This might still fail: if pfds[1].revents=POLLIN, socket read may still block.
There are rare cases when select/poll indicates that data can be read,
but then actual read still blocks (one such case is UDP packets with
wrong checksum). General advise is, if you use a poll/select loop,
keep all your fds nonblocking.
Maybe we should also do that to our network sockets?

function                                             old     new   delta
udhcp_sp_setup                                        55      65     +10
udhcp_sp_fd_set                                       54      60      +6
udhcp_sp_read                                         46      36     -10
udhcpd_main                                         1451    1437     -14
udhcpc_main                                         2723    2708     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/3 up/down: 16/-39)            Total: -23 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-10 19:34:39 +01:00
Denys Vlasenko
2e01eec4d3 tweak examples/var_service/*
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-27 12:53:20 +02:00
Denys Vlasenko
08dfafc437 fix more instances of ": $((a++))" in shell scripts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-15 19:20:45 +02:00
Denys Vlasenko
10ad622dc2 Spelling fixes in comments, documentation, tests and examples
By klemens <ka7@github.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-17 16:13:32 +02:00
Tito Ragusa
d3720828ea README_distro_proposal.txt: typo fixes
Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-03 12:25:18 +01:00
Denys Vlasenko
96f1d6b70c Update to examples/var_service/README_distro_proposal.txt
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-25 20:41:00 +01:00
Denys Vlasenko
fdb4421e00 README_distro_proposal.txt: writeup about runit adoption
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-03 14:06:55 +01:00
Denys Vlasenko
6bbb48fadf examples: update var_service/README again
Added "ps -AH e" example

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 19:02:11 +02:00
Denys Vlasenko
e43000f2d4 typo fixes in doc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:48:05 +02:00
Denys Vlasenko
93ff2b4b5f examples: update var_service/README again
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:38:08 +02:00
Denys Vlasenko
ee2d19445b examples: update var_service/README
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:22:50 +02:00
Denys Vlasenko
095ddf7669 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>
2016-10-03 23:43:44 +02:00
Denys Vlasenko
dea3bdbefe examples: wpa_supplicant.conf has a wrong field deleted in examples
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-26 20:47:17 +02:00
Denys Vlasenko
d8330ca4a4 examples/var_service/supplicant_if: new service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-20 18:09:00 +02:00
Denys Vlasenko
6b5abc9596 service/fw example: do not ruin $if[], use different name
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-30 22:29:10 +02:00
Denys Vlasenko
3191ec7cce var_service/fw: optionally flush all netdevs; optionally prefer one 0/0 routing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-25 16:28:57 +02:00
Denys Vlasenko
f6348e50ef examples: add a useful "see abridged log" script for ntpd service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-10 20:15:28 +02:00
Denys Vlasenko
bf1866c183 tweak zcip service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 18:57:32 +02:00
Denys Vlasenko
1a1cfedbef Tweak README
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 14:58:58 +02:00
Denys Vlasenko
4f8ecf273c update network service examples
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 14:55:33 +02:00
Denys Vlasenko
d32a1a4054 New example of a service: examples/var_service/zcip_if
Zeroconf for IPv4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 05:30:58 +02:00
Denys Vlasenko
5251135bc1 better pinger service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-15 02:10:11 +02:00
Denys Vlasenko
1186894f77 update example ntp.script
Handle an interesting corner case when NTP server is reachable...
but on a different IP now.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-31 22:00:55 +02:00
Denys Vlasenko
192c14bd87 Improve examples/var_service READMEs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-21 12:55:43 +01:00
Denys Vlasenko
1f3709ec74 fix typo in README
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-12-08 06:08:47 +01:00
Denys Vlasenko
309974412a typo fix
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-12-06 15:44:13 +01:00
Denys Vlasenko
bc3cdf8ed1 update examples/var_service/README
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-12-06 15:42:44 +01:00
Denys Vlasenko
75bb332dbd add examples/var_service/README
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-12-06 15:13:58 +01:00
Denys Vlasenko
1aaf1cb096 whitespace fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-26 08:04:18 +01:00
Denys Vlasenko
24928ffd8d ntpd: explain why scripts can be run in quick succession
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-25 19:30:16 +01:00
Denys Vlasenko
3581c62515 whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-25 13:39:24 +01:00
Denys Vlasenko
573ba4e92e fix examples which used non-standard cut -b0-NNN
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-18 12:25:09 +01:00
Denys Vlasenko
4fc82e0067 examples: add example ntpd service
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-13 22:07:34 +01:00
Denys Vlasenko
fae9f499b2 ntpd: make it work w/o -g too :(
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-12-01 02:32:01 +01:00
Denys Vlasenko
b6d221ac9c fix 'not not' in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-09 11:12:45 +01:00