Re: init.d-script in 2.4.33pre?

Bas van Schaik <[email protected]> Sun, 19 Mar 2006 13:15:26 +0100
Newsgroups gmane.linux.enbd.general
Message-ID <[email protected]>
Peter T. Breuer wrote:

>"Also sprach Peter T. Breuer:"
>  
>
>>You are right .. and the hyphens should be underlines! Corrected!
>>    
>>
>
>Nah .. let's use hyphens everywhere. Then one has enbd-server and
>enbd-server.conf.
>  
>
I concur. However, yesterday I posted a small patch on the enbd-init
file, but I think the mailing list doesn't support attachments or
something... Since it's not a very good idea to include a whole file in
the body of an e-mail, I'll try to put the diff of the small changes I
made. I hope this is readable, though:

8,10c8,10
< OLD_CONFIG="/etc/enbd.conf"
< SERVER_CONFIG="/etc/enbd-server.conf"
< CLIENT_CONFIG="/etc/enbd-client.conf"
---
> OLD_CONFIG="${ENBD_CONFIG-/etc/enbd.conf}"
> SERVER_CONFIG="${ENBD_SERVER_CONFIG-/etc/enbd-server.conf}"
> CLIENT_CONFIG="${ENBD_CLIENT_CONFIG-/etc/enbd-client.conf}"
13c13
<     SERVER_CONFIG=$OLD_CONFIG
---
>     SERVER_CONFIG=${NBD_CONFIG}
16c16
<     CLIENT_CONFIG=$OLD_CONFIG
---
>     CLIENT_CONFIG=${ENBD_CONFIG}
21a22
>
405,406c406,407
<       [ -r "$SERVER_CONFIG" ] && cat "$SERVER_CONFIG";
<       [ -r "$CLIENT_CONFIG" ] && cat "$CLIENT_CONFIG";
---
>       [ -r "$SERVER_CONFIG" ] && [ -x "$THESERVER" ] && cat
"$SERVER_CONFIG";
>       [ -r "$CLIENT_CONFIG" ] && [ -x "$THECLIENT" ] && cat
"$CLIENT_CONFIG";
433,440c434,435
<            # client configuration found! Check if client binary is
<            # available, issue a warning when missing.
<            if [ ! -x "$THECLIENT" ]; then
<              echo "Warning: enbd-client is not available, client
config ignored"
<          continue
<            fi
<
<            echo "$rest" | while read device server port options; do
---
>                [ -x "$THECLIENT" ] || continue
>                echo "$rest" | while read device server port options; do
445,451c440
<            # server configuration found! Check if server binary is
<            # available, issue a warning when missing.
<            if [ ! -x "$THESERVER" ]; then
<              echo "Warning: but enbd-server is not available, server
config ignored"
<          continue
<            fi
<           
---
>                [ -x "$THESERVER" ] || continue
480,481c469,472
< # exit if both server and client binaries are unavailable
< [ -x "$THECLIENT" ] && [ -x "$THESERVER" ] && exit 1
---
>
> # exit if server is here and there is no server config, etc.
> [ ! -r "$CLIENT_CONFIG" ] && [ -x "$THECLIENT" ] && exit 1
> [ ! -r "$SERVER_CONFIG" ] && [ -x "$THESERVER" ] && exit 1


Summary of the changes I made:
1) I don't think it's correct to exit if there's a server binary
installed without a configuration file. It should be the other way
around: exit (or warn) when a server config exists, but there's no
server binary.
2) Exit if both client and server binaries are unavailable
3) Issue a warning when server configuration found, but no server binary
(see above)
4) Changed the variables (but you already fixed that)

As I tried to post yesterday: feel free to use the "patch" above, but
feel free also to trash it in /dev/null.

--Bas