supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* runit spec file for Fedora Core XX
@ 2006-10-29 19:13 j.schlick
  2006-11-01 11:47 ` Gerrit Pape
  0 siblings, 1 reply; 2+ messages in thread
From: j.schlick @ 2006-10-29 19:13 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 490 bytes --]

Hi, I've created a RPM Spec-File for RedHat/Fedora
Core 6.
  - it uses dietlibc to create the binaries.
  - it uses the default sysv init scheme and
    adds/removes automatically the runit lines to
    the /etc/inittab file.

Perhaps there is someone who likes it or feel free
to add it to the runit package.

best regards
-- 
  =================================================
         Jochen Schlick
  mailto: j.schlick_at_decagon.de
  =================================================

[-- Attachment #2: runit.spec --]
[-- Type: text/plain, Size: 6874 bytes --]

%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 >/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 >/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/null >/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 >/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 >/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 <j.schlick_at_web_de> 1.7.0-5.diet.js
- avoid inittab conflicts with daemontools
- using sed to create runsvdir-start

* Tue Oct 24 2006 Jochen Schlick <j.schlick_at_web_de> 1.7.0-4.diet.js
- missing man pages added

* Tue Oct 24 2006 Jochen Schlick <j.schlick_at_web_de> 1.7.0-2.diet.js
- bugfix

* Sat Oct 14 2006 Jochen Schlick <j.schlick_at_web_de> 1.7.0-1.diet.js
- initial version



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: runit spec file for Fedora Core XX
  2006-10-29 19:13 runit spec file for Fedora Core XX j.schlick
@ 2006-11-01 11:47 ` Gerrit Pape
  0 siblings, 0 replies; 2+ messages in thread
From: Gerrit Pape @ 2006-11-01 11:47 UTC (permalink / raw)


On Sun, Oct 29, 2006 at 08:13:46PM +0100, j.schlick@decagon.de wrote:
> Hi, I've created a RPM Spec-File for RedHat/Fedora
> Core 6.
>  - it uses dietlibc to create the binaries.
>  - it uses the default sysv init scheme and
>    adds/removes automatically the runit lines to
>    the /etc/inittab file.
> 
> Perhaps there is someone who likes it or feel free
> to add it to the runit package.

Thanks, I'll take a look at it, and then most probably add it to the
package.

Regards, Gerrit.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-11-01 11:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-29 19:13 runit spec file for Fedora Core XX j.schlick
2006-11-01 11:47 ` Gerrit Pape

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).