%define name runit %define version 1.7.0 %define release 5.diet.js %define mybindir /sbin # default directories %define servicedir /var/service %define servicelogdir /var/log/svlog %define servicescriptdir %{_sysconfdir}/sv %define noShell /sbin/nologin %define nofilesGrp 2108 %define multilogUsr 7800 #.............................................................................. Summary: Gerrit Pape's UN*X init scheme with service supervision Name: %{name} Version: %{version} Release: %{release} License: BSD Group: System Environment/Daemons/DJB URL: http://smarden.org/runit/ Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires: sed BuildRequires: dietlibc #.............................................................................. %description runit is a daemontools alike replacement for SysV-init and other init schemes. It currently runs on GNU/Linux, OpenBSD, FreeBSD, and can easily be adapted to other Unix operating systems. runit implements a simple three-stage concept. Stage 1 performs the system's one-time initialization tasks. Stage 2 starts the system's uptime services (via the runsvdir program). Stage 3 handles the tasks necessary to shutdown and halt or reboot. This feature isn't used by this RPM. We use runit's service supervision without replacing the init scheme of the system. We simply run the stage 2 of runit as a service with your current init. This is done by adding an entry for %{mybindir}/runsvdir-start to /etc/inittab. servicedir %{servicedir} servicescriptdir %{servicescriptdir} servicelogdir %{servicelogdir} NOTE: the runit tools will be placed in %{mybindir} %prep %setup -n admin -q ( cd %{name}-%{version} #Change the conf-cc and conf-ld to use diet echo 'diet -Os gcc -O2 -Wall' >src/conf-cc echo 'diet -Os gcc -s -Os -pipe' >src/conf-ld ) #.............................................................................. %build ( cd %{name}-%{version} echo "$RPM_BUILD_ROOT/" > src/conf-home ./package/compile ./package/check ) #.............................................................................. %install rm -rf $RPM_BUILD_ROOT install -d %{buildroot}%{mybindir} install -d %{buildroot}%{_mandir}/man8 (cd %{name}-%{version} # runit script, replace servicedir and PATH cat etc/debian/2 | \ sed 's@/var/service@%{servicedir}@g' | \ sed 's@^PATH=.*@PATH=/bin:/sbin:/usr/bin:/usr/sbin@' > %{buildroot}%{mybindir}/runsvdir-start # executables cp command/* %{buildroot}%{mybindir}/ # manual install of the manpages cp man/*.8 %{buildroot}%{_mandir}/man8/ ) # service directories %{__install} -dDp -m0755 %{buildroot}%{servicedir} %{__install} -dDp -m0755 %{buildroot}%{servicelogdir} %{__install} -dDp -m0755 %{buildroot}%{servicescriptdir} #.............................................................................. %pre # only update if [ "$1" = "2" ]; then echo "removing old runit entries in /etc/inittab" sed -e '/^# runit/d' /etc/inittab.new && mv /etc/inittab /etc/inittab.old && mv /etc/inittab.new /etc/inittab sed -e '/^RS:123456:respawn:\/sbin\/runsvd/d' /etc/inittab.new && mv /etc/inittab /etc/inittab.old && mv /etc/inittab.new /etc/inittab fi # Add user and groups if necessary %{_sbindir}/groupadd -g %{nofilesGrp} nofiles 2>/dev/null %{_sbindir}/useradd -d %{servicelogdir} -s %{noShell} -M -g nofiles -u %{multilogUsr} multilog 2>/dev/null exit 0 #.............................................................................. %post # always add inittab entries echo "appending new runit entries in /etc/inittab" echo "# runit automatically added -------------------------------------------- BEGIN" >> /etc/inittab echo "RS:123456:respawn:/sbin/runsvdir-start /dev/console 2>/dev/console" >> /etc/inittab echo "# runit automatically added ---------------------------------------------- END" >> /etc/inittab # send a HUP to the init process for reloading inittab kill -HUP 1 #.............................................................................. %preun # only deinstall if [ "$1" = "0" ]; then echo "removing obsolete runit entries in /etc/inittab" sed -e '/^# runit/d' /etc/inittab.new && mv /etc/inittab /etc/inittab.old && mv /etc/inittab.new /etc/inittab sed -e '/^RS:123456:respawn:\/sbin\/runsvd/d' /etc/inittab.new && mv /etc/inittab /etc/inittab.old && mv /etc/inittab.new /etc/inittab # send a HUP to the init process for reloading inittab kill -HUP 1 fi #........................................................................ %postun # only deinstall (so not upgraded): if [ $1 = 0 ]; then # this is needed for user* and group* programs export PATH=$PATH:/usr/sbin echo "Removing runit users (if they exist):" function user_del() { if id -u $1 >/dev/null 2> /dev/null ; then echo " Removing $1 user ..." userdel $1 fi } for i in multilog; do user_del $i done ## update nis database if /sbin/pidof ypserv >/dev/null 2>/dev/null; then (cd /var/yp; make) fi echo "" echo "Removing runit groups (if they exist):" function group_del() { if groupmod $1 >/dev/null 2> /dev/null; then echo " Removing $1 group ..." groupdel $1 fi } for i in nofiles; do group_del $i done ## update nis database if /sbin/pidof ypserv >/dev/null 2>/dev/null; then (cd /var/yp; make) fi fi exit 0 #.............................................................................. %clean rm -rf $RPM_BUILD_ROOT #.............................................................................. %files %defattr(-,root,root) %doc %{name}-%{version}/package/CHANGES %doc %{name}-%{version}/package/README %doc %{name}-%{version}/package/THANKS %doc %{name}-%{version}/doc/* %doc %{name}-%{version}/etc/2 %doc %{name}-%{version}/etc/debian/* %attr(0755,root,root) %{mybindir}/* %doc %{_mandir}/man8/* %dir %{servicedir} %dir %{servicescriptdir} %attr(0755,multilog,nofiles) %dir %{servicelogdir} #.............................................................................. %changelog * Wed Oct 25 2006 Jochen Schlick 1.7.0-5.diet.js - avoid inittab conflicts with daemontools - using sed to create runsvdir-start * Tue Oct 24 2006 Jochen Schlick 1.7.0-4.diet.js - missing man pages added * Tue Oct 24 2006 Jochen Schlick 1.7.0-2.diet.js - bugfix * Sat Oct 14 2006 Jochen Schlick 1.7.0-1.diet.js - initial version