Changes of Revision 2
[-] | Changed | cdemu-daemon.spec |
x 1
2 Group: System Environment/Base 3 URL: http://cdemu.sourceforge.net 4 Source0: http://downloads.sourceforge.net/cdemu/%{name}-%{version}.tar.bz2 5 -Source1: cdemu-daemon.init 6 +Source1: cdemu-daemon.init.suse 7 Source2: cdemu-daemon.sysconfig 8 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 9 BuildRequires: dbus-1-devel >= 0.90 10
11 12 %if %{WITH_SYSV} 13 %{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig 14 -%{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d 15 -%{__install} -Dpm 644 cdemu-daemon.init $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/cdemu-daemon 16 -%{__install} -Dpm 755 cdemu-daemon.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/cdemu-daemon 17 +%{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/init.d 18 +%{__install} -Dpm 755 cdemu-daemon.init $RPM_BUILD_ROOT%{_sysconfdir}/init.d/cdemu-daemon 19 +%{__install} -Dpm 644 cdemu-daemon.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/cdemu-daemon 20 %endif 21 22 23
24 %post sysv 25 # Run cdemu-daemon by default: 26 /sbin/chkconfig --add cdemu-daemon >/dev/null 2>&1 || : 27 +ln -s %{_sysconfdir}/init.d/cdemu-daemon %{_sbindir}/rccdemu-daemon 28 29 %preun sysv 30 if [ "$1" -eq 0 ]; then 31 /sbin/service cdemu-daemon stop > /dev/null 2>&1 || : 32 /sbin/chkconfig --del cdemu-daemon 33 + rm -f %{_sbindir}/rccdemu-daemon 34 fi 35 36 %postun sysv 37
38 %files sysv 39 %defattr(-,root,root,-) 40 %config(noreplace) %{_sysconfdir}/sysconfig/cdemu-daemon 41 -%attr(0755,root,root) %{_sysconfdir}/rc.d/init.d/cdemu-daemon 42 +%attr(0755,root,root) %{_sysconfdir}/init.d/cdemu-daemon 43 %endif 44 45 %changelog 46 |
||
[+] | Added | cdemu-daemon.init.suse ^ |
@@ -0,0 +1,166 @@ +#!/bin/sh +# +# cdemu-daemon: CDEmu userspace daemon +# +# /etc/init.d/cdemu-daemon +# +# and symbolic its link +# +# /usr/sbin/rccdemu-daemon +# +### BEGIN INIT INFO +# Provides: cdemu-daemon +# Required-Start: $network $remote_fs +# Required-Stop: $network $remote_fs +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Description: Start the cdemu-daemon +### END INIT INFO + +CDEMUD_BIN=/usr/bin/cdemud +test -x $CDEMUD_BIN || exit 5 + +CDEMUD_SYSCONFIG=/etc/sysconfig/cdemu-daemon +test -r $CDEMUD_SYSCONFIG || exit 6 +. $CDEMUD_SYSCONFIG + +CDEMUD_PIDFILE=/var/run/cdemud.pid + +. /etc/rc.status + +# Shell functions sourced from /etc/rc.status: +# rc_check check and set local and overall rc status +# rc_status check and set local and overall rc status +# rc_status -v ditto but be verbose in local rc status +# rc_status -v -r ditto and clear the local rc status +# rc_failed set local and overall rc status to failed +# rc_reset clear local rc status (overall remains) +# rc_exit exit appropriate to overall rc status + +# First reset status of this service +rc_reset + + +start() { + # Load module + if [ -n "$MODULE" ]; then + echo -n $" Inserting kernel module ($MODULE): " + /sbin/modprobe $MODULE >/dev/null 2>&1 + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + : + else + return $RETVAL + fi + fi + + # Wait until control device is created... + if [ -n "$CTL_DEVICE" ]; then + echo -n " Waiting for $CTL_DEVICE to be created: " + until [ -c "$CTL_DEVICE" ]; do + echo -n "" + done + fi + + RETVAL=0 + if [ $RETVAL -eq 0 ] ; then + : + else + return $RETVAL + fi + + # Daemon arguments + DAEMON_ARGS="--daemonize" + + if [ -n "$DEVICES" ]; then + DAEMON_ARGS="$DAEMON_ARGS --num-devices=$DEVICES" + fi + if [ -n "$CTL_DEVICE" ]; then + DAEMON_ARGS="$DAEMON_ARGS --ctl-device=$CTL_DEVICE" + fi + if [ -n "$AUDIO_BACKEND" ]; then + DAEMON_ARGS="$DAEMON_ARGS --audio-driver=$AUDIO_BACKEND" + fi + + # Start daemon + echo -n " Starting daemon: " + startproc -f -p $CDEMUD_PIDFILE $CDEMUD_BIN $DAEMON_ARGS + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + touch /var/lock/subsys/$servicename + else + return $RETVAL + fi + + return $RETVAL +} + +stop() { + # Kill daemon with 'cdemud -k' + echo -n " Killing daemon: " + killproc -p $CDEMUD_PIDFILE -TERM $CDEMUD_BIN + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + : + else + return $RETVAL + fi + + # Unload module + if [ -n "$MODULE" ]; then + echo -n " Removing kernel module ($MODULE): " + /sbin/rmmod $MODULE >/dev/null 2>&1 + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + : + else + return $RETVAL + fi + fi + + if [ $RETVAL -eq 0 ]; then + rm -f /var/lock/subsys/$servicename + fi + + return $RETVAL +} + +# See how we were called. +case "$1" in + start) + echo -n "Starting CDEmu daemon: " + start + rc_status -v + ;; + stop) + echo -n "Stopping CDEmu daemon: " + stop + rc_status -v + ;; + status) + checkproc -p $CDEMUD_PIDFILE $CDEMUD_BIN + rc_status -v + ;; + restart) + $0 stop + $0 start + rc_status + ;; + condrestart) + if [ -f /var/lock/subsys/$servicename ]; then + echo "Stopping CDEmu daemon: " + stop + RETVAL=$? + if [ $RETVAL -eq 0]; then + sleep 3 + echo "Starting CDEmu daemon: " + start + fi + fi + rc_status + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart}" + ;; +esac +rc_exit |