aboutsummaryrefslogtreecommitdiff
path: root/sysutils/runit
diff options
context:
space:
mode:
authorChris Rees <crees@FreeBSD.org>2016-08-11 21:06:42 +0000
committerChris Rees <crees@FreeBSD.org>2016-08-11 21:06:42 +0000
commitaa463ad2ec00fc013e7dc0d5900cb4da5f5bba4e (patch)
tree7337c30035019b65de576703b0b38d40accc1466 /sysutils/runit
parentae0b5222767d63c4bce56b206f29d43922869c31 (diff)
downloadports-aa463ad2ec00fc013e7dc0d5900cb4da5f5bba4e.tar.gz
ports-aa463ad2ec00fc013e7dc0d5900cb4da5f5bba4e.zip
Notes
Diffstat (limited to 'sysutils/runit')
-rw-r--r--sysutils/runit/Makefile12
-rw-r--r--sysutils/runit/files/patch-etc_freebsd_finish7
-rw-r--r--sysutils/runit/files/patch-etc_freebsd_run8
-rw-r--r--sysutils/runit/files/patch-etc_freebsd_whichtty8
-rw-r--r--sysutils/runit/files/patch-src_runit-init.c20
-rw-r--r--sysutils/runit/files/patch-src_runit.c51
-rw-r--r--sysutils/runit/files/pkg-message.in43
-rw-r--r--sysutils/runit/pkg-plist1
8 files changed, 147 insertions, 3 deletions
diff --git a/sysutils/runit/Makefile b/sysutils/runit/Makefile
index 073b004b8a33..b849157a28b6 100644
--- a/sysutils/runit/Makefile
+++ b/sysutils/runit/Makefile
@@ -3,7 +3,7 @@
PORTNAME= runit
PORTVERSION= 2.1.2
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= sysutils
MASTER_SITES= http://smarden.org/${PORTNAME}/ \
http://www.bayofrum.net/dist/${PORTNAME}/
@@ -18,21 +18,27 @@ USE_RC_SUBR= runsvdir
WRKSRC= ${WRKDIR}/admin/${DISTNAME}
SERVICE_DIR?= /var/service
+SUB_FILES= pkg-message
SUB_LIST= SERVICE_DIR="${SERVICE_DIR}"
PORTDOCS= *
DOCS= package/CHANGES package/README \
package/THANKS doc/*.html
CONFIG= etc/freebsd/1 etc/2 etc/freebsd/3 etc/freebsd/ctrlaltdel \
- etc/freebsd/getty-ttyv4/run etc/freebsd/getty-ttyv4/finish
+ etc/freebsd/getty-ttyv4/run etc/freebsd/getty-ttyv4/finish \
+ etc/freebsd/getty-ttyv4/whichtty
post-patch:
${REINPLACE_CMD} -i '' 's!/service/!${SERVICE_DIR}!' \
- ${WRKSRC}/man/* ${WRKSRC}/src/sv.c
+ ${PATCH_WRKSRC}/man/* ${PATCH_WRKSRC}/src/sv.c
+ ${REINPLACE_CMD} -i '' '\|^PATH=|s|$$|:${PREFIX}/bin:${PREFIX}/sbin|' \
+ ${PATCH_WRKSRC}/etc/freebsd/3
+ ${FIND} ${PATCH_WRKSRC} -name '*.orig' -delete
do-configure:
${ECHO_CMD} "${CC} ${CFLAGS}" > ${WRKSRC}/src/conf-cc
${ECHO_CMD} "${CC}" > ${WRKSRC}/src/conf-ld
+ ${ECHO_CMD} '#define PREFIX "${PREFIX}"' >> ${WRKSRC}/src/runit.h
do-build:
cd ${WRKSRC} && package/compile && package/check
diff --git a/sysutils/runit/files/patch-etc_freebsd_finish b/sysutils/runit/files/patch-etc_freebsd_finish
new file mode 100644
index 000000000000..540a35fc98ff
--- /dev/null
+++ b/sysutils/runit/files/patch-etc_freebsd_finish
@@ -0,0 +1,7 @@
+--- etc/freebsd/getty-ttyv4/finish 2016-07-28 16:39:47.000000000 +0100
++++ finish 2016-08-10 22:28:28.274811000 +0100
+@@ -1,2 +1,3 @@
+ #!/bin/sh
+-exec utmpset -w ttyv4
++. whichtty
++exec utmpset -w $tty
diff --git a/sysutils/runit/files/patch-etc_freebsd_run b/sysutils/runit/files/patch-etc_freebsd_run
new file mode 100644
index 000000000000..0dde7abf07fc
--- /dev/null
+++ b/sysutils/runit/files/patch-etc_freebsd_run
@@ -0,0 +1,8 @@
+--- etc/freebsd/getty-ttyv4/run 2016-07-28 16:39:47.000000000 +0100
++++ run 2016-08-10 22:28:33.566527000 +0100
+@@ -1,2 +1,4 @@
+ #!/bin/sh
+-exec /usr/libexec/getty Pc ttyv4
++export TERM=xterm
++. whichtty
++exec /usr/libexec/getty Pc $tty
diff --git a/sysutils/runit/files/patch-etc_freebsd_whichtty b/sysutils/runit/files/patch-etc_freebsd_whichtty
new file mode 100644
index 000000000000..6dafeff2f10d
--- /dev/null
+++ b/sysutils/runit/files/patch-etc_freebsd_whichtty
@@ -0,0 +1,8 @@
+--- etc/freebsd/getty-ttyv4/whichtty 1970-01-01 01:00:00.000000000 +0100
++++ etc/freebsd/getty-ttyv4/whichtty 2016-08-10 22:34:36.558752671 +0100
+@@ -0,0 +1,5 @@
++realpath=`realpath $0`
++dirname=`dirname $realpath`
++dirname=`basename $dirname`
++tty=`expr $dirname : 'getty-\(ttyv[0-9]\)'`
++[ -z "${tty%0}" ] && echo "Name of directory must be getty-ttyvx, where x is 0-9" && exit 1
diff --git a/sysutils/runit/files/patch-src_runit-init.c b/sysutils/runit/files/patch-src_runit-init.c
new file mode 100644
index 000000000000..9f23f804b2d6
--- /dev/null
+++ b/sysutils/runit/files/patch-src_runit-init.c
@@ -0,0 +1,20 @@
+$FreeBSD$
+
+runit is designed to be placed in /sbin. However, there is no reason that
+PREFIX cannot be respected here, so should a user define in loader.conf this
+in place, then it will still be found.
+
+init_path=/usr/local/sbin/runit-init:/sbin/init
+
+--- src/runit-init.c.orig 2016-08-10 20:53:15 UTC
++++ src/runit-init.c
+@@ -53,6 +53,9 @@ int main (int argc, const char * const *
+ /* kernel is starting init, runit does the job. */
+ execve(RUNIT, (char *const *)prog, envp);
+
++ /* OK, running from PREFIX-- should be default */
++ execve(PREFIX RUNIT, (char *const *)prog, envp);
++
+ /* serious error */
+ strerr_die4sys(111, FATAL, "unable to start ", prog[0], ": ");
+ }
diff --git a/sysutils/runit/files/patch-src_runit.c b/sysutils/runit/files/patch-src_runit.c
new file mode 100644
index 000000000000..04331517103b
--- /dev/null
+++ b/sysutils/runit/files/patch-src_runit.c
@@ -0,0 +1,51 @@
+$FreeBSD$
+
+Should the user neglect to add the symlink, rather than stick them in a
+reboot loop give a warning.
+
+--- src/runit.c.orig 2016-08-10 21:03:05 UTC
++++ src/runit.c
+@@ -22,10 +22,13 @@
+ #define WARNING "- runit: warning: "
+ #define FATAL "- runit: fatal: "
+
+-const char * const stage[3] ={
++const char * const stage[] ={
+ "/etc/runit/1",
+ "/etc/runit/2",
+- "/etc/runit/3" };
++ "/etc/runit/3",
++ PREFIX "/etc/runit/1",
++ PREFIX "/etc/runit/2",
++ PREFIX "/etc/runit/3" };
+
+ int selfpipe[2];
+ int sigc =0;
+@@ -134,6 +137,13 @@ int main (int argc, const char * const *
+
+ strerr_warn3(INFO, "enter stage: ", stage[st], 0);
+ execve(*prog, (char *const *)prog, envp);
++ /* Try with PREFIX */
++ prog[0] = stage[st+3];
++ strerr_warn3(INFO,
++ "Trying in " PREFIX "; not found in /etc: ", stage[st], 0);
++ strerr_warn3(INFO,
++ "Must run ln -s " PREFIX "/etc/runit /etc/ to work!", stage[st], 0);
++ execve(*prog, (char *const *)prog, envp);
+ strerr_die4sys(0, FATAL, "unable to start child: ", stage[st], ": ");
+ }
+
+@@ -229,6 +239,13 @@ int main (int argc, const char * const *
+ /* child */
+ strerr_warn3(INFO, "enter stage: ", prog[0], 0);
+ execve(*prog, (char *const *) prog, envp);
++ /* Try with PREFIX */
++ prog[0] = stage[st+3];
++ strerr_warn3(INFO,
++ "Trying in " PREFIX "; not found: ", stage[st], 0);
++ strerr_warn3(INFO,
++ "Must run ln -s " PREFIX "/etc/runit /etc/ to work!", stage[st], 0);
++ execve(*prog, (char *const *) prog, envp);
+ strerr_die4sys(0, FATAL, "unable to start child: ", prog[0], ": ");
+ }
+ if (wait_pid(&wstat, pid2) == -1)
diff --git a/sysutils/runit/files/pkg-message.in b/sysutils/runit/files/pkg-message.in
new file mode 100644
index 000000000000..653ecfadb8a3
--- /dev/null
+++ b/sysutils/runit/files/pkg-message.in
@@ -0,0 +1,43 @@
+Using runit with FreeBSD init:
+
+# mkdir %%SERVICE_DIR%%
+# cp -R %%PREFIX%%/etc/runit /etc/runit
+# echo runsvdir_enable=yes >> /etc/rc.conf
+
+runit is very easily used instead of init on FreeBSD, but the port maintainer
+suggests the following alternative method (as opposed to the website method):
+
+1. Copy all of the etc files from %%PREFIX%%/etc/runit to /etc/runit;
+
+# cp -R %%PREFIX%%/etc/runit /etc/runit
+
+2. Copy runit-init AND runit into /sbin;
+
+# cp /usr/local/sbin/runit* /sbin
+
+3. Create service directories, enable ttyv4 and disable it in ttys:
+
+# mkdir %%SERVICE_DIR%%
+# cp -R /etc/runit/getty-ttyv4 %%SERVICE_DIR%%
+# sed 's/^ttyv4/#&/' /etc/ttys
+
+(The getty-ttyvx directory will getty on whichever vtty x is on, for example
+ # cp -R %%SERVICE_DIR%%/getty-ttyv4 %%SERVICE_DIR%%/getty-ttyv3
+ will result in a tty on ttyv3 as well)
+
+4. Don't replace FreeBSD init in place, tell loader to use runit instead:
+
+# echo 'init_path="/sbin/runit-init:/sbin/init:/sbin/oinit:/sbin/init.bak:/rescue/init"' >> /boot/loader.conf
+
+5. Reboot!
+
+Note: On FreeBSD, runit-init works in %%PREFIX%%/sbin, but
+ *only* if %%PREFIX%%/sbin is on the same filesystem as /; check with:
+
+# df %%PREFIX%%/sbin/runit | sed -ne 's,.* /,/,p' # If this does not return "/"
+
+ If the output is "/", you may skip step 2 and modify step 4:
+
+# echo 'init_path="%%PREFIX%%/sbin/runit-init:/sbin/init:/sbin/oninit:/sbin/init.bak:/rescue/init"' >> /boot/loader.conf
+
+ making upgrades easier.
diff --git a/sysutils/runit/pkg-plist b/sysutils/runit/pkg-plist
index 2c5261e65c4d..abdf8299290b 100644
--- a/sysutils/runit/pkg-plist
+++ b/sysutils/runit/pkg-plist
@@ -4,6 +4,7 @@
@sample %%ETCDIR%%/ctrlaltdel.sample
@sample %%ETCDIR%%/getty-ttyv4/run.sample
@sample %%ETCDIR%%/getty-ttyv4/finish.sample
+@sample %%ETCDIR%%/getty-ttyv4/whichtty.sample
man/man8/chpst.8.gz
man/man8/runit-init.8.gz
man/man8/runit.8.gz