- Fix init script to conform to Fedora guidelines

- Do not overuse macros
This commit is contained in:
Miloš Jakubíček 2010-05-01 11:19:40 +00:00
parent cc52a7b495
commit acab9db20c
2 changed files with 184 additions and 8 deletions

174
trousers-init.patch Normal file
View File

@ -0,0 +1,174 @@
--- dist/fedora/fedora.initrd.tcsd.orig 2010-05-01 13:16:32.000000000 +0200
+++ dist/fedora/fedora.initrd.tcsd 2010-05-01 13:16:53.000000000 +0200
@@ -1,51 +1,46 @@
#!/bin/bash
#
-# Init file for the TrouSerS TCG Core Services daemon
+# tcsd Init script for the TrouSerS TCG Core Services daemon
#
# chkconfig: - 90 10
# description: TrouSerS server daemon
-#
-# processname: tcsd
-# config: /etc/tcsd.conf
-# pidfile: /var/run/tcsd.pid
-#
-# Return values according to LSB for all commands but status:
-# 0 - success
-# 1 - generic or unspecified error
-# 2 - invalid or excess argument(s)
-# 3 - unimplemented feature (e.g. "reload")
-# 4 - insufficient privilege
-# 5 - program is not installed
-# 6 - program is not configured
-# 7 - program is not running
-#
+### BEGIN INIT INFO
+# Provides:
+# Required-Start:
+# Required-Stop:
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Init script for TCSD
+# Description: TrouSerS TCG Core Services daemon
+### END INIT INFO
+
+exec="/usr/sbin/tcsd"
prog="tcsd"
+config="/etc/tcsd.conf"
+PID_FILE="/var/run/tcsd.pid"
+INSMOD="/sbin/insmod"
+LSMOD="/sbin/lsmod"
+GREP="/bin/grep"
# source function library
. /etc/rc.d/init.d/functions
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
# Allow anyone to run status
-if [ "$1" = "status" ] ; then
- status $prog
+if [ "$1" = "status" -o "$1" = "rh_status" -o "$1" = "rh_status_q" ] ; then
+ $1 $prog
RETVAL=$?
exit $RETVAL
fi
# Check that we are root ... so non-root users stop here
-test $EUID = 0 || exit 4
-
-# pull in sysconfig settings
-test -f /etc/sysconfig/tcsd && . /etc/sysconfig/tcsd
-
-RETVAL=0
-
-# Some variables to make the below more readable
-TCSD=/usr/sbin/tcsd
-PID_FILE=/var/run/tcsd.pid
-INSMOD=/sbin/insmod
-LSMOD=/sbin/lsmod
-GREP=/bin/grep
+test $EUID = 0 || exit 4
load_drivers()
{
@@ -64,14 +59,15 @@
start()
{
- test -x $TCSD || exit 5
- test -f /etc/tcsd.conf || exit 6
+ test -x $exec || exit 5
+ test -f $config || exit 6
check_drivers || load_drivers || failure
echo -n $"Starting $prog: "
- $TCSD $OPTIONS && success || failure
+ $exec $OPTIONS && success || failure
RETVAL=$?
- [ "$RETVAL" = 0 ] && touch /var/lock/subsys/tcsd
echo
+ [ "$RETVAL" = 0 ] && touch $lockfile
+ return $RETVAL
}
stop()
@@ -79,32 +75,59 @@
echo -n $"Stopping $prog: "
killproc $prog
RETVAL=$?
- [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/tcsd
echo
+ [ "$RETVAL" = 0 ] && rm -f $lockfile
+ return $RETVAL
+}
+
+restart() {
+ stop
+ start
}
+reload() {
+ restart
+}
+
+force_reload() {
+ restart
+}
+
+rh_status() {
+ # run checks to determine if the service is running or use generic status
+ status $prog
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+
case "$1" in
start)
- start
+ rh_status_q && exit 0
+ $1
;;
stop)
- stop
+ rh_status_q || exit 0
+ $1
;;
restart)
- test -f /etc/tcsd.conf || exit 6
- stop
- start
+ $1
;;
- reload|force-reload)
- restart
+ reload)
+ rh_status_q || exit 7
+ $1
;;
+ force-reload)
+ force_reload
+ ;;
condrestart|try-restart)
- if [ -f /var/lock/subsys/tcsd ] ; then
- restart
- fi
+ rh_status_q || exit 0
+ restart
;;
*)
- echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}"
- RETVAL=3
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+ exit 2
esac
-exit $RETVAL
+exit $?

View File

@ -1,18 +1,15 @@
%global name trousers
%global version 0.3.4
%global tarballrev -1
%global release 2
Name: %{name}
Name: trousers
Summary: TCG's Software Stack v1.2
Version: %{version}
Release: %{release}%{?dist}
Version: 0.3.4
Release: 3%{?dist}
License: CPL
Group: System Environment/Libraries
Url: http://trousers.sourceforge.net
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
# Patch from upstream cleaning up some use of free()
Patch1: trousers-0.3.4-free.patch
# Patch init script to conform to our guidelines
Patch2: trousers-init.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: libtool, openssl-devel
Requires(pre): shadow-utils
@ -51,6 +48,7 @@ applications.
%prep
%setup -q
%patch1 -p1
%patch2
%build
%configure --with-gui=openssl
@ -116,6 +114,10 @@ fi
%{_libdir}/libtddl.a
%changelog
* Sat May 01 2010 Miloš Jakubíček <xjakub@fi.muni.cz> - 0.3.4-3
- Fix init script to conform to Fedora guidelines
- Do not overuse macros
* Mon Feb 08 2010 Steve Grubb <sgrubb@redhat.com> 0.3.4-2
- Fix issue freeing a data structure