Index: head/sysutils/runit/Makefile =================================================================== --- head/sysutils/runit/Makefile (revision 420104) +++ head/sysutils/runit/Makefile (revision 420105) @@ -1,59 +1,65 @@ # Created by: Sergei Kolobov # $FreeBSD$ PORTNAME= runit PORTVERSION= 2.1.2 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils MASTER_SITES= http://smarden.org/${PORTNAME}/ \ http://www.bayofrum.net/dist/${PORTNAME}/ MAINTAINER= crees@FreeBSD.org COMMENT= Service supervision tools compatible with DJB daemontools LICENSE= BSD3CLAUSE LICENSE_FILE= ${WRKSRC}/package/COPYING 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 @${MKDIR} ${WRKDIR}/etc/getty-ttyv4 .for file in ${CONFIG} @${SED} -e 's!/etc/runit!${ETCDIR}!g' \ -e 's!/service!${SERVICE_DIR}!g' \ -e 's!/usr/local!${PREFIX}!g' \ ${WRKSRC}/${file} > ${WRKDIR}/${file:S!freebsd/!!}.sample .endfor do-install: ${INSTALL_PROGRAM} ${WRKSRC}/command/* ${STAGEDIR}${PREFIX}/sbin ${INSTALL_MAN} ${WRKSRC}/man/* ${STAGEDIR}${PREFIX}/man/man8/ @${MKDIR} ${STAGEDIR}${ETCDIR}/getty-ttyv4 ${INSTALL_SCRIPT} ${WRKDIR}/etc/[123c]* ${STAGEDIR}${ETCDIR} ${INSTALL_SCRIPT} ${WRKDIR}/etc/getty-ttyv4/* \ ${STAGEDIR}${ETCDIR}/getty-ttyv4 @${MKDIR} ${STAGEDIR}${DOCSDIR} .for doc in ${DOCS} ${INSTALL_DATA} ${WRKSRC}/${doc} ${STAGEDIR}${DOCSDIR} .endfor .include Index: head/sysutils/runit/files/patch-etc_freebsd_finish =================================================================== --- head/sysutils/runit/files/patch-etc_freebsd_finish (nonexistent) +++ head/sysutils/runit/files/patch-etc_freebsd_finish (revision 420105) @@ -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 Property changes on: head/sysutils/runit/files/patch-etc_freebsd_finish ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/runit/files/patch-etc_freebsd_run =================================================================== --- head/sysutils/runit/files/patch-etc_freebsd_run (nonexistent) +++ head/sysutils/runit/files/patch-etc_freebsd_run (revision 420105) @@ -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 Property changes on: head/sysutils/runit/files/patch-etc_freebsd_run ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/runit/files/patch-etc_freebsd_whichtty =================================================================== --- head/sysutils/runit/files/patch-etc_freebsd_whichtty (nonexistent) +++ head/sysutils/runit/files/patch-etc_freebsd_whichtty (revision 420105) @@ -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 Property changes on: head/sysutils/runit/files/patch-etc_freebsd_whichtty ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/runit/files/patch-src_runit-init.c =================================================================== --- head/sysutils/runit/files/patch-src_runit-init.c (nonexistent) +++ head/sysutils/runit/files/patch-src_runit-init.c (revision 420105) @@ -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], ": "); + } Property changes on: head/sysutils/runit/files/patch-src_runit-init.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/runit/files/patch-src_runit.c =================================================================== --- head/sysutils/runit/files/patch-src_runit.c (nonexistent) +++ head/sysutils/runit/files/patch-src_runit.c (revision 420105) @@ -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) Property changes on: head/sysutils/runit/files/patch-src_runit.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/runit/files/pkg-message.in =================================================================== --- head/sysutils/runit/files/pkg-message.in (nonexistent) +++ head/sysutils/runit/files/pkg-message.in (revision 420105) @@ -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. Property changes on: head/sysutils/runit/files/pkg-message.in ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/runit/pkg-plist =================================================================== --- head/sysutils/runit/pkg-plist (revision 420104) +++ head/sysutils/runit/pkg-plist (revision 420105) @@ -1,24 +1,25 @@ @sample %%ETCDIR%%/1.sample @sample %%ETCDIR%%/2.sample @sample %%ETCDIR%%/3.sample @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 man/man8/runsv.8.gz man/man8/runsvchdir.8.gz man/man8/runsvdir.8.gz man/man8/sv.8.gz man/man8/svlogd.8.gz man/man8/utmpset.8.gz sbin/chpst sbin/runit sbin/runit-init sbin/runsv sbin/runsvchdir sbin/runsvdir sbin/sv sbin/svlogd sbin/utmpset