commit 221e83bd7b27ad0b139a9f1dfb762b9c5d52dcce
parent 4b40368790996e889dfa0bf176bff56203621e07
Author: Gerrit Pape <pape@smarden.org>
Date: Sun, 22 Jun 2003 18:25:31 +0000
* doc/index.html, doc/install.html, doc/replaceinit.html, doc/useinit.html:
how to install and configure runit on MacOSX.
* svlogd.c: fix incorrect handling of processor's state file; minor code
cleanup.
* runit-init.c: exit 0 on wrong usage.
0.10.0
Diffstat:
12 files changed, 131 insertions(+), 61 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,6 +1,6 @@
DESTDIR=
-PACKAGE=runit-0.9.5
+PACKAGE=runit-0.10.0
DIRS=doc man etc package src
MANPAGES=runit.8 runit-init.8 runsvdir.8 runsv.8 svwaitdown.8 svwaitup.8 \
utmpset.8 runsvchdir.8 runsvstat.8 runsvctrl.8 svlogd.8
diff --git a/debian/rules b/debian/rules
@@ -41,13 +41,13 @@ build-arch: configure-stamp build-arch-stamp
build-arch-stamp:
dh_testdir
- tar xfzvp runit-0.9.5.tar.gz
+ tar xfzvp runit-0.10.0.tar.gz
-gcc -v
( \
set -e; \
- cd admin/runit-0.9.5/src; \
- ln -s runit-0.9.5 runit; mv runit ../..; \
+ cd admin/runit-0.10.0/src; \
+ ln -s runit-0.10.0 runit; mv runit ../..; \
echo "$(CC) $(CFLAGS)" >conf-cc; \
echo "$(CC) $(LDFLAGS)" >conf-ld; \
$(MAKE); \
@@ -79,35 +79,35 @@ install: build
dh_installdirs
# runit
- install -m0500 admin/runit-0.9.5/src/runit \
+ install -m0500 admin/runit-0.10.0/src/runit \
$(CURDIR)/debian/runit/sbin/runit
- install -m0500 admin/runit-0.9.5/src/runit-init \
+ install -m0500 admin/runit-0.10.0/src/runit-init \
$(CURDIR)/debian/runit/sbin/runit-init
- install -m0755 admin/runit-0.9.5/src/runsvdir \
+ install -m0755 admin/runit-0.10.0/src/runsvdir \
$(CURDIR)/debian/runit/usr/bin/runsvdir
- install -m0755 admin/runit-0.9.5/src/runsv \
+ install -m0755 admin/runit-0.10.0/src/runsv \
$(CURDIR)/debian/runit/usr/bin/runsv
- install -m0755 admin/runit-0.9.5/src/runsvchdir \
+ install -m0755 admin/runit-0.10.0/src/runsvchdir \
$(CURDIR)/debian/runit/usr/sbin/runsvchdir
- install -m0755 admin/runit-0.9.5/src/svlogd \
+ install -m0755 admin/runit-0.10.0/src/svlogd \
$(CURDIR)/debian/runit/usr/bin/svlogd
- install -m0755 admin/runit-0.9.5/src/svwaitdown \
+ install -m0755 admin/runit-0.10.0/src/svwaitdown \
$(CURDIR)/debian/runit/usr/bin/svwaitdown
- install -m0755 admin/runit-0.9.5/src/svwaitup \
+ install -m0755 admin/runit-0.10.0/src/svwaitup \
$(CURDIR)/debian/runit/usr/bin/svwaitup
- install -m0755 admin/runit-0.9.5/src/utmpset \
+ install -m0755 admin/runit-0.10.0/src/utmpset \
$(CURDIR)/debian/runit/usr/sbin/utmpset
- install -m0755 admin/runit-0.9.5/src/runsvstat \
+ install -m0755 admin/runit-0.10.0/src/runsvstat \
$(CURDIR)/debian/runit/usr/bin/runsvstat
- install -m0755 admin/runit-0.9.5/src/runsvctrl \
+ install -m0755 admin/runit-0.10.0/src/runsvctrl \
$(CURDIR)/debian/runit/usr/bin/runsvctrl
- install -m0755 admin/runit-0.9.5/src/setuidgid \
+ install -m0755 admin/runit-0.10.0/src/setuidgid \
$(CURDIR)/debian/runit/usr/sbin/setuidgid
- install -m0755 admin/runit-0.9.5/etc/debian/getty-tty5/run \
+ install -m0755 admin/runit-0.10.0/etc/debian/getty-tty5/run \
$(CURDIR)/debian/runit/etc/runit/getty-5/run
- install -m0755 admin/runit-0.9.5/etc/debian/getty-tty5/finish \
+ install -m0755 admin/runit-0.10.0/etc/debian/getty-tty5/finish \
$(CURDIR)/debian/runit/etc/runit/getty-5/finish
# lintian overrides
@@ -146,7 +146,7 @@ binary-arch: build install
# dh_installdocs -an
# dh_installexamples -a
dh_installman -a admin/runit/man/*.8
- dh_installchangelogs -a admin/runit-0.9.5/package/CHANGES
+ dh_installchangelogs -a admin/runit-0.10.0/package/CHANGES
dh_strip -a
# dh_link -a
dh_compress -a
diff --git a/doc/index.html b/doc/index.html
@@ -41,8 +41,8 @@
replacement for
<a href="ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/">sysvinit</a>
and other init schemes. <i>runit</i> runs on <b>GNU/Linux</b>,
-<b>OpenBSD</b>, <b>FreeBSD</b>, and can easily be adapted to other unix
-operating systems.
+<b>OpenBSD</b>, <b>FreeBSD</b>, <b>MacOSX</b>, and can easily be adapted to
+other unix operating systems.
If <i>runit</i> runs for you on any other operating system or Linux
distribution, please let me know.
<p>
diff --git a/doc/install.html b/doc/install.html
@@ -17,16 +17,22 @@ If you don't have a <tt>/package</tt> directory, create it now:
# chmod 1755 /package
</pre>
Download
-<a href="runit-0.9.5.tar.gz">runit-0.9.5.tar.gz</a> into <tt>/package</tt>
+<a href="runit-0.10.0.tar.gz">runit-0.10.0.tar.gz</a> into <tt>/package</tt>
and unpack the archive
<pre>
# cd /package
- # gunzip runit-0.9.5.tar
- # tar -xpf runit-0.9.5.tar
- # rm runit-0.9.5.tar
- # cd admin/runit-0.9.5
+ # gunzip runit-0.10.0.tar
+ # tar -xpf runit-0.10.0.tar
+ # rm runit-0.10.0.tar
+ # cd admin/runit-0.10.0
</pre>
-Compile and install the <i>runit</i> programs
+On MacOSX, do
+<pre>
+ # echo 'cc -Xlinker -x' >src/conf-ld
+ # cp src/Makefile src/Makefile.old
+ # sed -e 's/ -static//' <src/Makefile.old >src/Makefile
+</pre>
+Now compile and install the <i>runit</i> programs
<pre>
# package/install
</pre>
@@ -37,7 +43,7 @@ hierarchy, do:
</pre>
To report success:
<pre>
- # mail pape-runit-0.9.5@smarden.org <compile/sysdeps
+ # mail pape-runit-0.10.0@smarden.org <compile/sysdeps
</pre>
Refer to <a href="replaceinit.html">replacing init</a> for
replacing <i>init</i> with <i>runit</i>, or to
diff --git a/doc/replaceinit.html b/doc/replaceinit.html
@@ -9,10 +9,11 @@
<hr>
<h1>runit - replacing init</h1>
<hr>
-<a href="#sysvinit">How to replace sysvinit on GNU/Linux</a><br>
-<a href="#bsdinit">How to replace init on *BSD</a>
+<a href="#sysv">How to replace sysvinit on GNU/Linux</a><br>
+<a href="#bsd">How to replace init on *BSD</a><br>
+<a href="#macosx">How to replace init on MacOSX</a>
<hr>
-<a name="sysvinit"><h2>Replacing sysvinit (GNU/Linux)</h2></a>
+<a name="sysv"><h2>Replacing sysvinit (GNU/Linux)</h2></a>
Follow these steps to migrate from <i>sysvinit</i> to <i>runit</i> on
<a href="http://www.debian.org/releases/woody/">Debian GNU/Linux (woody)</a>.
The <tt>/sbin/init</tt> binary is not replaced until step 6, <i>runit</i> is
@@ -107,11 +108,11 @@ default Unix process no 1 <i>runit</i>.
</pre>
To report success:
<pre>
- # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.9.5@smarden.org
+ # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.10.0@smarden.org
</pre>
<hr>
-<a name="bsdinit"><h2>Replacing init (*BSD)</h2></a>
+<a name="bsd"><h2>Replacing init (*BSD)</h2></a>
Follow these steps to migrate from <i>init</i> to <i>runit</i> on
<a href="http://www.openbsd.org/">OpenBSD 2.9</a> or
<a href="http://www.freebsd.org/">FreeBSD 4.4</a>. The
@@ -188,7 +189,7 @@ Use <b>init 6</b> to reboot and <b>init 0</b> to halt a system that runs
<p>
To report success:
<pre>
- # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.9.5@smarden.org
+ # ( uname -a ; cat /etc/runit/[123] ) | mail pape-runit-0.10.0@smarden.org
</pre>
<h3>Step 5: Service migration</h3>
The goal is to migrate all services from <i>/etc/rc.*</i> scheme to the
@@ -211,6 +212,12 @@ it is running, disable the service in <tt>/etc/rc.conf</tt> or remove the
service startup from the <tt>/etc/rc.*</tt> scripts and tell
<a href="runsvdir.8.html">runsvdir</a> about the new service.
<hr>
+
+<a name="macosx"><h2>Replacing init on MacOSX</h2></a>
+Replacing init on MacOSX is not yet supported.
+Please refer to the <a href="useinit.html">instructions</a> on how to use
+<i>runit</i> service supervision with the MacOSX init scheme.
+<hr>
<address><a href="mailto:pape@smarden.org">
Gerrit Pape <pape@smarden.org>
</a></address>
diff --git a/doc/useinit.html b/doc/useinit.html
@@ -14,17 +14,23 @@ the <i>init</i> scheme of the system.
Simply run the <i>stage 2</i> of <i>runit</i> as a service with your
current <i>init</i>.
<p>
-Normally this is done by either adding <tt>/etc/runit/2</tt> as command to
-</tt>/etc/rc.local</tt>, or by adding an entry for <tt>/etc/runit/2</tt> to
-<tt>/etc/inittab</tt>.
+Normally this is done by either adding an entry for <tt>/etc/runit/2</tt>
+to <tt>/etc/inittab</tt>, or by adding <tt>/etc/runit/2</tt> as command to
+</tt>/etc/rc.local</tt>, or by adding <tt>/etc/runit/2</tt> to the system's
+<tt>StartupItems</tt>.
<p>
-In either case, you first need to copy the <i>stage 2</i> script to
+In any case, you first need to copy the <i>stage 2</i> script to
<tt>/etc/runit/2</tt>:
<pre>
# mkdir -p /etc/runit
# cp -p /package/admin/runit/etc/2 /etc/runit/
</pre>
<hr>
+<a href="#sysv">How to use with sysvinit</a><br>
+<a href="#bsd">How to use with *BSD init</a><br>
+<a href="#macosx">How to use with MacOSX init</a>
+<hr>
+<a name="sysv"><h2>Using with sysvinit</h2></a>
If your system uses a sysvinit alike init scheme with a <tt>/etc/inittab</tt>
file, do:
<pre>
@@ -37,15 +43,26 @@ and tell <i>init</i> to reread its configuration, e.g.:
# init q
</pre>
<hr>
+<a name="bsd"><h2>Using with *BSD init</h2></a>
If your system uses a BSD alike init scheme with a <tt>/etc/rc.local</tt>
script, do:
<pre>
# cat >>/etc/rc.local <<EOT
- /etc/runit/2 &
+ csh -cf '/etc/runit/2 &'
EOT
</pre>
and reboot your system.
<hr>
+<a name="macosx"><h2>Using with MacOSX init</h2></a>
+On MacOSX 10.2 create an entry for <i>runit</i> in
+<tt>/System/Library/StartupItems/</tt>:
+<pre>
+ # cd /System/Library/StartupItems
+ # mkdir -p runit
+ # cp -p /package/admin/runit/etc/macosx/StartupItems/* runit/
+</pre>
+and reboot your system.
+<hr>
<address><a href="mailto:pape@smarden.org">
Gerrit Pape <pape@smarden.org>
</a></address>
diff --git a/etc/macosx/StartupItems/StartupParameters.plist b/etc/macosx/StartupItems/StartupParameters.plist
@@ -0,0 +1,11 @@
+{
+ Description = "runit service supervision";
+ Provides = ("runit");
+ Requires = ("Disks");
+ OrderPreference = "None";
+ Messages =
+ {
+ start = "Starting runit service supervision";
+ stop = "Stopping runit service supervision";
+ };
+}
diff --git a/etc/macosx/StartupItems/runit b/etc/macosx/StartupItems/runit
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+##
+# runit
+##
+
+. /etc/rc.common
+
+StartService() {
+ ConsoleMessage "Starting runit service supervision"
+ /bin/csh -cf '/etc/runit/2 &'
+}
+StopService() {
+ ConsoleMessage "Stopping runit service supervision"
+ svwaitdown -xk -t34 /service/*
+}
+RestartService() {
+ return 0
+}
+
+RunService "$1"
diff --git a/package/CHANGES b/package/CHANGES
@@ -1,3 +1,11 @@
+runit 0.10.0
+Sun, 22 Jun 2003 20:14:29 +0200
+ * doc/index.html, doc/install.html, doc/replaceinit.html, doc/useinit.html:
+ how to install and configure runit on MacOSX.
+ * svlogd.c: fix incorrect handling of processor's state file; minor code
+ cleanup.
+ * runit-init.c: exit 0 on wrong usage.
+
runit 0.9.5
Tue, 17 Jun 2003 10:48:10 +0200
* runit.c: use select() on systems that don't provide poll().
diff --git a/package/upgrade b/package/upgrade
@@ -7,9 +7,9 @@ test -d src || ( echo 'Wrong working directory.'; exit 1 )
here=`env - PATH=$PATH pwd`
parent=`dirname $here`
-echo 'Creating symlink runit -> runit-0.9.5...'
+echo 'Creating symlink runit -> runit-0.10.0...'
rm -f runit
-ln -s runit-0.9.5 runit
+ln -s runit-0.10.0 runit
mv -f runit ..
echo 'Making command links in /command...'
diff --git a/src/runit-init.c b/src/runit-init.c
@@ -14,7 +14,7 @@
const char *progname;
-void usage(void) { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); }
+void usage(void) { strerr_die4x(0, "usage: ", progname, USAGE, "\n"); }
void runit_halt () {
if (open_trunc(STOPIT) == -1)
diff --git a/src/svlogd.c b/src/svlogd.c
@@ -180,10 +180,12 @@ unsigned int processorstop(struct logdir *ld) {
ld->fnsave[26] ='t';
byte_copy(f, 26, ld->fnsave);
f[26] ='s'; f[27] =0;
- while (rename(ld->fnsave, f) == .1)
+ while (rename(ld->fnsave, f) == -1)
pause2("unable to rename processed", ld->name);
while (chmod(f, 0744) == -1)
pause2("unable to set mode of processed", ld->name);
+ while (rename("newstate", "state") == -1)
+ pause2("unable to rename state", ld->name);
while (fchdir(fdwdir) == -1)
pause1("unable to change to initial working directory");
return(1);
@@ -242,15 +244,13 @@ unsigned int rotate(struct logdir *ld) {
while ((f =readdir(d)))
if ((f->d_name[0] == '@') && (str_len(f->d_name) == 27)) {
++n;
- if (str_diff(f->d_name, oldest) < 0)
- byte_copy(oldest, 27, f->d_name);
+ if (str_diff(f->d_name, oldest) < 0) byte_copy(oldest, 27, f->d_name);
}
if (errno) warn2("unable to read directory", ld->name);
closedir(d);
if (ld->nmax && (n >= ld->nmax)) {
- if (verbose)
- strerr_warn5(INFO, "delete: ", ld->name, "/", oldest, 0);
+ if (verbose) strerr_warn5(INFO, "delete: ", ld->name, "/", oldest, 0);
if ((*oldest == '@') && (unlink(oldest) == -1))
warn2("unable to unlink oldest logfile", ld->name);
}
@@ -258,7 +258,6 @@ unsigned int rotate(struct logdir *ld) {
if (ld->processor.len) {
processorstart(ld);
}
-
while (fchdir(fdwdir) == -1)
pause1("unable to change to initial working directory");
return(1);
@@ -269,15 +268,16 @@ void logdir_close(struct logdir *ld) {
if (verbose) strerr_warn3(INFO, "close: ", ld->name, 0);
close(ld->fddir);
ld->fddir =-1;
- if (ld->fdcur) {
- buffer_flush(&ld->b);
- while (fsync(ld->fdcur) == -1)
- pause2("unable to fsync current logfile", ld->name);
- while (fchmod(ld->fdcur, 0744) == -1)
- pause2("unable to set mode of current", ld->name);
- close(ld->fdcur);
- }
- if (ld->fdlock) close(ld->fdlock);
+ if (ld->fdcur == -1) return; /* impossible */
+ buffer_flush(&ld->b);
+ while (fsync(ld->fdcur) == -1)
+ pause2("unable to fsync current logfile", ld->name);
+ while (fchmod(ld->fdcur, 0744) == -1)
+ pause2("unable to set mode of current", ld->name);
+ close(ld->fdcur);
+ ld->fdcur =-1;
+ if (ld->fdlock == -1) return; /* impossible */
+ close(ld->fdlock);
ld->fdlock =-1;
}
@@ -346,8 +346,7 @@ unsigned int logdir_open(struct logdir *ld, const char *fn) {
if (ld->nmax == 1) ld->nmax =2;
break;
case '!':
- while (! stralloc_copys(&ld->processor, &sa.s[i +1]))
- pause_nomem();
+ while (! stralloc_copys(&ld->processor, &sa.s[i +1])) pause_nomem();
while (! stralloc_0(&ld->processor)) pause_nomem();
break;
}
@@ -440,7 +439,8 @@ unsigned int linestart(struct logdir *ld, char *s, int len) {
if (ld->match == '-') return(0);
if (timestamp) {
buffer_puts(&ld->b, stamp);
- ld->size +=26;
+ if (timestamp != 3) ld->size +=26;
+ else ld->size +=20;
}
buffer_put(&ld->b, s, len);
ld->size +=len;
@@ -561,7 +561,7 @@ int main(int argc, const char **argv) {
dir =(struct logdir*)alloc(dirn *sizeof(struct logdir));
if (! dir) die_nomem();
for (i =0; i < dirn; ++i) {
- dir[i].fddir =-1;
+ dir[i].fddir =-1; dir[i].fdcur =-1;
dir[i].btmp =(char*)alloc(buflen *sizeof(char));
if (! dir[i].btmp) die_nomem();
dir[i].ppid =0;