blob: 9606edba0c497bc6037ddb65b19ab0ec01c42e2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
<?xml version="1.0"?>
<!-- $Id$ -->
<encap_profile
profile_ver="1.0"
pkgspec="runit-1.7.2"
>
<prereq package="m4-1.4.4" />
<prereq package="patch-2.5.9" />
<environment
variable="CC"
value="gcc -static-libgcc"
type="set"
/>
<environment
variable="PATH"
PLATFORM_IF_MATCH(solaris)
value="/usr/local/lib/bcfg2/bin:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin:"
PLATFORM_ELSE
value="/usr/local/lib/bcfg2/bin:/usr/local/bin:"
PLATFORM_ENDIF
type="prepend"
/>
<environment
variable="CPPFLAGS"
value="-I/usr/local/lib"
type="set"
/>
PLATFORM_IF_MATCH(linux)
PLATFORM_ELSE
<environment
variable="MAKE"
value="gmake"
type="set"
/>
PLATFORM_ENDIF
<source
url="http://encapsrcdist/mirror/runit/runit-1.7.2.tar.gz
http://mirror.opensysadmin.com/runit/runit-1.7.2.tar.gz
http://smarden.org/runit/runit-1.7.2.tar.gz"
use_objdir="no"
subdir="admin/runit-1.7.2"
>
PLATFORM_IF_MATCH(aix)
<patch options="-p0" from_dir="compile"><![CDATA[
--- uw_tmp.h1 2007-06-25 01:17:00.000000000 -0400
+++ uw_tmp.h1 2007-06-25 01:17:23.000000000 -0400
@@ -3,7 +3,7 @@
/* sysdep: -utmpx */
-#define UW_TMP_UFILE _PATH_UTMP
-#define UW_TMP_WFILE _PATH_WTMP
+#define UW_TMP_UFILE UTMP_FILE
+#define UW_TMP_WFILE WTMP_FILE
typedef struct utmp uw_tmp;
]]></patch>
PLATFORM_ELSE
PLATFORM_ENDIF
<configure type="unset" />
<build>
./package/compile
./package/check
</build>
<install>
test -d ${ENCAP_SOURCE} || mkdir ${ENCAP_SOURCE}
test -d ${ENCAP_SOURCE}/${ENCAP_PKGNAME} || mkdir ${ENCAP_SOURCE}/${ENCAP_PKGNAME}
test -d ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/bin || mkdir ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/bin
test -d ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share || mkdir ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share
test -d ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/doc || mkdir ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/doc
test -d ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/doc/runit || mkdir ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/doc/runit
test -d ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/man || mkdir ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/man
test -d ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/man/man8 || mkdir ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/man/man8
cp command/* ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/bin
cp -r doc/* ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/doc/runit
cp -r etc ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/doc/runit
cp -r package ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/share/doc/runit
cp man/* ${ENCAP_SOURCE}/${ENCAP_PKGNAME}/man/man8
</install>
<clean type="unset" />
</source>
<prepackage>
# Make "this encap is installed" sentinal file available in /usr/local/var/encap
test -d var || mkdir var
test -d var/encap || mkdir var/encap
touch var/encap/${ENCAP_PKGNAME}
</prepackage>
<include_file name="bin/runsvdir-usrlocal-start" mode="0755"><![CDATA[
#!/bin/sh
PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin
exec env - PATH=$PATH \
runsvdir -P /usr/local/var/service 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'
]]></include_file>
<include_file name="inittab.boot" mode="0644"><![CDATA[
SV:123456:respawn:/usr/local/bin/runsvdir-usrlocal-start
]]></include_file>
<include_file name="upstart.boot" mode="0644"><![CDATA[
# /etc/event.d/SV 0644
#
# for runit - manage /usr/local/bin/runsvdir-usrlocal-start
#
start on runlevel-2
start on runlevel-3
start on runlevel-4
start on runlevel-5
stop on shutdown
respawn /usr/local/bin/runsvdir-usrlocal-start
]]></include_file>
<include_file name="inittab-install" mode="0755"><![CDATA[
#!/bin/sh -e
if grep SV: /etc/inittab >/dev/null
then
echo 'inittab contains an SV: line. I assume that runsvdir is already running.
'
else
echo 'Adding runsvdir to inittab...'
rm -f /etc/inittab'{new}'
cat /etc/inittab inittab.boot > /etc/inittab'{new}'
mv -f /etc/inittab'{new}' /etc/inittab
kill -HUP 1
echo 'init should start runsvdir now.
'
fi
]]></include_file>
<include_file name="inittab-remove" mode="0755"><![CDATA[
#!/bin/sh -e
if grep SV: /etc/inittab >/dev/null
then
echo 'Backing up inittab to .inittab.backup...'
rm -f /etc/.inittab.backup
cp -f /etc/inittab /etc/.inittab.backup
echo 'Removing svscan lines from inittab...'
rm -f /etc/inittab'{new}'
grep -v SV: /etc/inittab > /etc/inittab'{new}'
mv -f /etc/inittab'{new}' /etc/inittab
kill -HUP 1
echo 'init should stop runsvdir now.
'
else
echo 'inittab does not contain a runsvdir line.
'
fi
]]></include_file>
<include_file name="postinstall" mode="0755"><![CDATA[
#!/bin/sh
umask 002
BASEDIR="`echo ${0} | xargs -n1 dirname`"
LOG=${BASEDIR}/postinstall.log
exec > $LOG 2>&1
printf "Running runit postinstall script...\n"
date
case `uname` in
AIX|SunOS) PS="ps -ef" ;;
*) PS="ps auxw" ;;
esac
printf "1: Make sure required directories exist...\n"
test -d /usr/local/var || mkdir /usr/local/var
test -d /usr/local/var/svlogd || mkdir /usr/local/var/svlog
test -d /usr/local/var/service || mkdir /usr/local/var/service
test -d /usr/local/etc || mkdir /usr/local/etc
test -d /usr/local/etc/default || mkdir /usr/local/etc/default
test -d /usr/local/etc/sv || mkdir /usr/local/etc/sv
printf "\n2: Currently running runsv and svlogd processes:\n"
$PS | grep [r]unsv
$PS | grep [s]vlogd
printf "\n3: Killing any running runsv and svlogd processes...\n"
$PS | grep [r]unsv | awk '{print $2}' | xargs -n1 -i{} kill -15 -{} 2>/dev/null
$PS | grep [s]vlogd | awk '{print $2}' | xargs -n1 -i{} kill -15 -{} 2>/dev/null
sleep 2
$PS | grep [r]unsv | awk '{print $2}' | xargs -n1 -i{} kill -9 -{} 2>/dev/null
$PS | grep [s]vlogd | awk '{print $2}' | xargs -n1 -i{} kill -9 -{} 2>/dev/null
printf "\n4: Currently running runsv and svlogd processes:\n"
$PS | grep [r]unsv
$PS | grep [s]vlogd
printf "\n5: Removing any stale state information in /usr/local/etc/sv...\n"
for service in `ls /usr/local/etc/sv`; do
test -d /usr/local/etc/sv/$service/supervise && rm -rf /usr/local/etc/sv/$service/supervise
test -d /usr/local/etc/sv/$service/log/supervise && rm -rf /usr/local/etc/sv/$service/log/supervise
done
printf "\n6: Re-enabling services that were installed before package was removed...\n"
if [ -d /usr/local/var/service/.disabled ]; then
for service in `ls /usr/local/var/service/.disabled`; do
if [ -h /usr/local/var/service/$service ]; then
printf "A new version of $service exists, removing old version...\n"
rm /usr/local/var/service/.disabled/$service
else
printf "Re-enabling service $service...\n"
mv /usr/local/var/service/.disabled/$service /usr/local/var/service/
fi
done
fi
printf "\n7: Making runsvdir run all the time...\n"
if [ -f /etc/inittab ]; then
printf "Installing to /etc/inittab ...\n"
cd ${ENCAP_SOURCE}/${ENCAP_PKGNAME} && ./inittab-install
fi
if [ -d /etc/event.d ]; then
printf "Installing to /etc/event.d/SV (Upstart) ...\n"
initctl stop SV 2>/dev/null || true
cd ${ENCAP_SOURCE}/${ENCAP_PKGNAME} && cp upstart.boot /etc/event.d/SV
initctl start SV
fi
printf "\n8: Finished runit postinstall script.\n"
]]></include_file>
<include_file name="preremove" mode="0755"><![CDATA[
#!/bin/sh
printf "Running runit preremove script...\n"
umask 002
date
case `uname` in
AIX|SunOS) PS="ps -ef" ;;
*) PS="ps auxw" ;;
esac
printf "1: All sv processes runnning before any actions...\n"
$PS | grep [s]v
printf "\n2: Running sv force-shutdown on all /usr/local/var/service services.\n"
printf "We wait up to an hour for each service to die - if it takes more than a\n"
printf "minute, your daemon probably doesn't properly support signals, and you\n"
printf "will probably want to manually kill the service process in another window.\n"
for service in `ls /usr/local/var/service`; do
printf "Trying to force-shutdown /usr/local/var/service/$service ...\n"
sv -v -w 3600 force-shutdown /usr/local/var/service/$service
done
sleep 2
printf "All sv processes runnning now...\n"
$PS | grep [s]v
printf "\n3: Removing all services from /usr/local/var/service/ - runsvdir should now\n"
printf "shut down any runsv processes...\n"
test -d /usr/local/var/service/.disabled || mkdir /usr/local/var/service/.disabled
mv /usr/local/var/service/* /usr/local/var/service/.disabled/ 2>/dev/null || printf "No services to disable.\n"
printf "Waiting 10 seconds for runsv processes to die...\n"
sleep 10
printf "All sv processes runnning now...\n"
$PS | grep [s]v
printf "If there are any runsv or svlogd processes still running, you will need\n"
printf "to kill them manually.\n"
printf "\n4: Now shutting down the runsvdir processes...\n"
# Stop the "runsvdir" process {
if [ -f /etc/inittab ]; then
printf "Removing from /etc/inittab ...\n"
cd ${ENCAP_SOURCE}/${ENCAP_PKGNAME} && ./inittab-remove
fi
if [ -d /etc/event.d ]; then
if [ -f /etc/event.d/SV ]; then
printf "Removing /etc/event.d/SV (Upstart) ...\n"
initctl stop SV || printf "SV already stopped...\n"
rm /etc/event.d/SV
fi
fi
# } Stop the "runsvdir" process
sleep 2
printf "All sv processes runnning now...\n"
$PS | grep [s]v
printf "runsvdir should no longer be running.\n"
printf "\n5: Removing any old state from /usr/local/etc/sv directories...\n"
for service in `ls /usr/local/etc/sv`; do
test -d /usr/local/etc/sv/$service/supervise && rm -rf /usr/local/etc/sv/$service/supervise
test -d /usr/local/etc/sv/$service/log/supervise && rm -rf /usr/local/etc/sv/$service/log/supervise
done
printf "\n6: Finished runit preremove script.\n"
]]></include_file>
<encapinfo>
description runit - a UNIX init scheme with service supervision
</encapinfo>
</encap_profile>
|