4 # skeleton example file to build /etc/init.d/ scripts.
5 # This file should be used to construct scripts for /etc/init.d.
7 # Written by Miquel van Smoorenburg <miquels@cistron.nl>.
8 # Modified for Debian GNU/Linux
9 # by Ian Murdock <imurdock@gnu.ai.mit.edu>.
10 # Modified for the nbd-client package
11 # by Wouter Verhelst <wouter@debian.org>
14 # Provides: nbd-client
15 # Required-Start: $network $local_fs
16 # Required-Stop: $network
19 # X-Start-Before: mountnfs
20 # Short-Description: Network Block Device client
23 # Version: @(#)skeleton 1.8 03-Mar-1998 miquels@cistron.nl
25 PATH
=/sbin
:/bin
:/usr
/sbin
:/usr
/bin
26 DAEMON
="/sbin/nbd-client"
28 DESC
="NBD client process"
30 test -f /etc
/nbd-client
&& .
/etc
/nbd-client
32 test -x $DAEMON ||
exit 0
36 # I don't use start-stop-daemon: nbd-client only does some setup
37 # for the connection; the 'nbd-client' you see in your ps output
38 # later on is a kernel thread...
40 echo -n 'Connecting...'
41 for dev
in $
(awk '/^(( \t)*[^#])/{print $1}' /etc
/nbdtab
)
43 # cfq deadlocks NBD devices, so switch to something else if cfq is
45 # This doesn't take into account non-udev devnames, but since
46 # there's really no other option these days...
47 if grep '\[cfq\]' "/sys/block/${dev}/queue/scheduler" >/dev
/null
; then
48 echo deadline
> "/sys/block/${dev}/queue/scheduler"
50 if nbd-client
-c "${dev}" >/dev
/null
52 echo "${dev} already connected, skipping..."
59 echo -n "Starting $DESC: "
61 if [ ! -f /run
/sendsigs.omit.d
/nbd-client
]
63 for x
in $
(cat /proc
/cmdline
); do
66 nbdroot
="${x#nbdroot=}"
67 nbdbasedev
=$
(echo "$nbdroot" |
sed -e 's/^.*,//')
68 nbdrootdev
=/dev
/$nbdbasedev
71 nbdrootdev
="${x#root=}"
75 OMITKILL
="$OMITKILL ${nbdrootdev%p*}"
78 nbd-client
-c $x >> /run
/sendsigs.omit.d
/nbd-client
83 echo "Stopping $DESC: "
84 for dev
in $
(awk '/^(( \t)*[^#])/{print $1}' /etc
/nbdtab
)
86 nbd-client
-d /dev
/$dev
98 echo "Usage: $N {start|connect|stop|restart|force-reload}" >&2