Gentoo Archives: gentoo-dev

From: Martin Schlemmer <azarah@g.o>
To: James Yonan <jim@×××××.net>
Cc: Gentoo-Dev <gentoo-dev@g.o>
Subject: Re: [gentoo-dev] Init Scripts
Date: Sat, 28 Jun 2003 16:45:09
Message-Id: 1056818774.14725.17.camel@nosferatu.lan
In Reply to: [gentoo-dev] Init Scripts by James Yonan
1 On Sat, 2003-06-28 at 18:11, James Yonan wrote:
2 > Hi,
3 >
4 > I'm new to Gentoo and I'm trying to convert the RedHat init script for OpenVPN
5 > over to Gentoo's format. Though I'm still learning the Gentoo way of writing
6 > init scripts, I would like to suggest the following additions to runscript.sh:
7 >
8 > (1) There should be an easy-to-call support function so an init script can
9 > tell whether or not it has been started such as:
10 >
11 > started() {
12 > if [ -L "${svcdir}/started/${myservice}" ]; then
13 > return 1
14 > else
15 > return 0
16 > fi
17 > }
18 >
19
20 Already done in 1.8.6.*:
21
22 ------------------------
23 # bool service_started(service)
24 #
25 # Returns true if 'service' is started
26 #
27 service_started() {
28 ------------------------
29
30
31 > (2) Condrestart is a useful init script method, often seen in RH init scripts.
32 > It basically says "restart only if service is already running". It is
33 > commonly used to restart a daemon after a software update. OpenVPN needs it
34 > so that the VPN daemon can be restarted if a network adaptor gets a new IP
35 > address from a DHCP server. In cases like these, you obviously don't want to
36 > restart the daemon unless it is already running. Condrestart becomes
37 > breathtakingly simple if started() above is defined:
38 >
39 > condrestart() {
40 > started || restart
41 > }
42 >
43
44 Well, you could do:
45
46 [ -n "$(${myservice} status | grep 'started')" ] && \
47 ${myservice} restart
48
49
50 Regards,
51
52 --
53
54 Martin Schlemmer
55 Gentoo Linux Developer, Desktop/System Team Developer
56 Cape Town, South Africa

Attachments

File name MIME type
signature.asc application/pgp-signature