rpms/poker-network/F-9 poker-bot.init, 1.1, 1.2 poker-network.spec, 1.11, 1.12 poker-server.init, 1.1, 1.2

Christopher Stone (xulchris) fedora-extras-commits at redhat.com
Sat May 24 02:03:49 UTC 2008


Author: xulchris

Update of /cvs/extras/rpms/poker-network/F-9
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22786/F-9

Modified Files:
	poker-bot.init poker-network.spec poker-server.init 
Log Message:
Conform for fedora initscript standards (bz #247022)


Index: poker-bot.init
===================================================================
RCS file: /cvs/extras/rpms/poker-network/F-9/poker-bot.init,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- poker-bot.init	20 Feb 2007 01:59:53 -0000	1.1
+++ poker-bot.init	24 May 2008 02:01:01 -0000	1.2
@@ -2,127 +2,48 @@
 #
 # poker-bot    poker-network bots
 #
-# chkconfig:   - 66 34
+# chkconfig:   - 70 30
 # description: Multi player online poker server with \
 #              bots running according to /etc/poker-network
-# processname: poker-bot
-# config:      /etc/poker-network/poker.bot.xml
-# pidfile:     /var/run/poker-bot.pid
+
+### BEGIN INIT INFO
+# Provides: poker-bot
+# Required-Start: $local_fs $network poker-server
+# Required-Stop: $local_fs $network poker-server
+# Short-Description: poker-network bots
+# Description: Multi player online poker server with
+#              bots running according to /etc/poker-network
+### END INIT INFO
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
-# Source networking configuration.
-. /etc/sysconfig/network
-
-# Check that networking is up.
-[ "$NETWORKING" = "no" ] && exit 0
-
-selinuxwrapper=/usr/bin/poker-bot-selinux
-
-python=/usr/bin/python
-twistd=/usr/bin/twistd
-reactor=poll
-
-opt_args=--no_save
-
 exec="PYTHON_SITELIB/pokernetwork/pokerbot.py"
 prog=poker-bot
-
-pidfile=/var/run/poker-network/$prog.pid
-logfile=/var/log/poker-network/$prog.log
-
-serverpidfile=/var/run/poker-network/poker-server.pid
+config=/etc/poker-network/poker.bot.xml
 
 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
 
 lockfile=/var/lock/subsys/$prog
-
-# Possible return values:
-# 0 = service is running
-# 1 = pid file exists, but process is dead
-# 2 = pid file gone, process is gone, but lockfile exists
-# 3 = service not running
-isrunning() {
-    local base=pokerbot
-    local pid
-
-    if [ -f ${pidfile} ] ; then
-        read pid < ${pidfile}
-        ps $pid | grep $base 2>&1 > /dev/null
-        running=$?
-        if [ "$running" = 0 ] ; then
-            return 0
-        fi
-
-        if [ -n "$pid" ]; then
-            return 1
-        fi
-    fi
-    if [ -f ${lockfile} ]; then
-            return 2
-    fi
-
-    return 3
-}
-
-poker_status() {
-    isrunning
-    retval=$?
-    case $retval in
-        0)  echo "$prog is running."
-            ;;
-        1)  echo "$prog stopped but pid file exists..."
-            ;;
-        2)  echo "$prog stopped but subsys locked..."
-            ;;
-        3)  echo "$prog is stopped."
-            ;;
-    esac
-}
+pidfile=/var/run/poker-network/$prog.pid
+logfile=/var/log/poker-network/$prog.log
 
 start() {
+    [ -f $exec ] || exit 5
+    [ -f $config ] || exit 6
     echo -n $"Starting $prog: "
-    isrunning
-    retval=$?
-    case $retval in
-        0)  echo -n $"$prog already running"
-            failure
-            echo
-            return 1
-            ;;
-        1)  echo -n $"$prog stopped but pid file exists..."
-            ;;
-        2)  echo -n $"$prog stopped but subsys locked..."
-            ;;
-    esac
-
-    if [ ! -f ${serverpidfile} ]; then
-        echo -n $"poker-server must be running"
-        failure
-        echo
-        return 1
-    fi
-
-    daemon --user=POKER_USER ${selinuxwrapper} \
-            --pidfile=${pidfile} --logfile=${logfile} \
-            --quiet ${opt_args} --reactor=${reactor}
-
+    daemon --user=POKER_USER /usr/bin/poker-bot-selinux \
+            --pidfile=$pidfile --logfile=$logfile \
+            --quiet --no_save --reactor=poll
     retval=$?
-    if [ $retval -eq 0 ]; then
-        success
-        touch $lockfile
-    else
-        failure
-    fi
     echo
-
+    [ $retval -eq 0 ] && touch $lockfile
     return $retval
 }
 
 stop() {
     echo -n $"Stopping $prog: "
-    killproc -p ${pidfile} $prog
+    killproc -p $pidfile $prog
     retval=$?
     echo
     [ $retval -eq 0 ] && rm -f $lockfile
@@ -142,24 +63,43 @@
     restart
 }
 
-fdr_status() {
-    status $prog
+rh_status() {
+    status -p $pidfile $prog
+}
+
+rh_status_q() {
+    rh_status >/dev/null 2>&1
 }
 
+
 case "$1" in
-    start|stop|restart|reload)
+    start)
+        rh_status_q && exit 0
+        $1
+        ;;
+    stop)
+        rh_status_q || exit 0
+        $1
+        ;;
+    restart)
+        $1
+        ;;
+    reload)
+        rh_status_q || exit 7
         $1
         ;;
     force-reload)
         force_reload
         ;;
     status)
-        poker_status
+        rh_status
         ;;
     condrestart|try-restart)
-        [ ! -f $lockfile ] || restart
+        rh_status_q || exit 0
+        restart
         ;;
     *)
-        echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
         exit 2
 esac
+exit $?


Index: poker-network.spec
===================================================================
RCS file: /cvs/extras/rpms/poker-network/F-9/poker-network.spec,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- poker-network.spec	16 May 2008 23:15:06 -0000	1.11
+++ poker-network.spec	24 May 2008 02:01:01 -0000	1.12
@@ -9,7 +9,7 @@
 
 Name:             poker-network
 Version:          1.5.0
-Release:          1%{?dist}
+Release:          2%{?dist}
 Summary:          Base package for poker client and server
 
 Group:            Applications/Internet
@@ -66,9 +66,9 @@
 Requires:         MySQL-python SOAPpy
 Requires:         poker-client-lib = %{version}-%{release}
 Requires:         %{name} = %{version}-%{release}
-Requires(post):   /sbin/chkconfig
-Requires(preun):  /sbin/chkconfig
-Requires(preun):  /sbin/service
+Requires(post):   chkconfig
+Requires(preun):  chkconfig
+Requires(preun):  initscripts
 
 %description -n poker-server
 The server deals the cards and checks the user actions using a poker
@@ -89,9 +89,9 @@
 Group:            Applications/Internet
 BuildRequires:    apg
 Requires:         apg poker-client-lib = %{version}-%{release}
-Requires(post):   /sbin/chkconfig
-Requires(preun):  /sbin/chkconfig
-Requires(preun):  /sbin/service
+Requires(post):   chkconfig
+Requires(preun):  chkconfig
+Requires(preun):  initscripts
 
 %description -n poker-bot
 %{summary}.
@@ -221,7 +221,7 @@
 
 %preun -n poker-server
 if [ $1 = 0 ]; then
-    /sbin/service poker-server stop >/dev/null 2>&1 || :
+    /sbin/service poker-server stop >/dev/null 2>&1
     /sbin/chkconfig --del poker-server
 fi
 
@@ -235,7 +235,7 @@
 
 %preun -n poker-bot
 if [ $1 = 0 ]; then
-    /sbin/service poker-bot stop >/dev/null 2>&1 || :
+    /sbin/service poker-bot stop >/dev/null 2>&1
     /sbin/chkconfig --del poker-bot
 fi
 
@@ -366,6 +366,9 @@
 
 
 %changelog
+* Fri May 23 2008 Christopher Stone <chris.stone at gmail.com> 1.5.0-2
+- Conform for fedora initscript standards (bz #247022)
+
 * Fri May 16 2008 Christopher Stone <chris.stone at gmail.com> 1.5.0-1
 - Upstream sync
 - Remove no longer needed libtool and gettext-devel from BR


Index: poker-server.init
===================================================================
RCS file: /cvs/extras/rpms/poker-network/F-9/poker-server.init,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- poker-server.init	20 Feb 2007 01:59:53 -0000	1.1
+++ poker-server.init	24 May 2008 02:01:01 -0000	1.2
@@ -2,130 +2,51 @@
 #
 # poker-server poker-network server
 #
-# chkconfig:   - 65 35
+# chkconfig:   - 70 30
 # description: Multi player online poker server with \
 #              bots running according to /etc/poker-network
-# processname: pokerserver
-# config:      /etc/poker-network/poker.server.xml
-# pidfile:     /var/run/poker-server.pid
+
+### BEGIN INIT INFO
+# Provides: poker-server
+# Required-Start: $local_fs $network mysqld
+# Required-Stop: $local_fs $network mysqld
+# Short-Description: poker-network server
+# Description: Multi player online poker server with
+#              bots running according to /etc/poker-network
+### END INIT INFO
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
-# Source networking configuration.
-. /etc/sysconfig/network
-
-# Check that networking is up.
-[ "$NETWORKING" = "no" ] && exit 0
-
-selinuxwrapper=/usr/bin/poker-server-selinux
-
-python=/usr/bin/python
-twistd=/usr/bin/twistd
-reactor=poll
-
-opt_args=--no_save
-
 exec="PYTHON_SITELIB/pokernetwork/pokerserver.py"
 prog=poker-server
-
-pidfile=/var/run/poker-network/$prog.pid
-logfile=/var/log/poker-network/$prog.log
-
-botpidfile=/var/run/poker-network/poker-bot.pid
+config=/etc/poker-network/poker.server.xml
 
 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
 
 lockfile=/var/lock/subsys/$prog
-
-# Possible return values:
-# 0 = service is running
-# 1 = pid file exists, but process is dead
-# 2 = pid file gone, process is gone, but lockfile exists
-# 3 = service not running
-isrunning() {
-    local base=pokerserver
-    local pid
-
-    if [ -f ${pidfile} ] ; then
-        read pid < ${pidfile}
-        ps $pid | grep $base 2>&1 > /dev/null
-        running=$?
-        if [ "$running" = 0 ] ; then
-            return 0
-        fi
-
-        if [ -n "$pid" ]; then
-            return 1
-        fi
-    fi
-    if [ -f ${lockfile} ]; then
-        return 2
-    fi
-
-    return 3
-}
-
-poker_status() {
-    isrunning
-    retval=$?
-    case $retval in
-        0)  echo "$prog is running."
-            ;;
-        1)  echo "$prog stopped but pid file exists..."
-            ;;
-        2)  echo "$prog stopped but subsys locked..."
-            ;;
-        3)  echo "$prog is stopped."
-            ;;
-    esac
-}
+pidfile=/var/run/poker-network/$prog.pid
+logfile=/var/log/poker-network/$prog.log
 
 start() {
+    [ -f $exec ] || exit 5
+    [ -f $config ] || exit 6
     echo -n $"Starting $prog: "
-    isrunning
-    retval=$?
-    case $retval in
-        0)  echo -n $"$prog already running"
-            failure
-            echo
-            return 1
-            ;;
-        1)  echo -n $"$prog stopped but pid file exists..."
-            ;;
-        2)  echo -n $"$prog stopped but subsys locked..."
-            ;;
-    esac
-
     if selinuxenabled ; then
         /usr/sbin/semanage port -a -t pokerd_port_t -p tcp 19380-19383 &>/dev/null || :
     fi
-
-    daemon --user=POKER_USER ${selinuxwrapper} \
-            --pidfile=${pidfile} --logfile=${logfile} \
-            --quiet ${opt_args} --reactor=${reactor}
-
+    daemon --user=POKER_USER /usr/bin/poker-server-selinux \
+            --pidfile=$pidfile --logfile=$logfile \
+            --quiet --no_save --reactor=poll
     retval=$?
-    if [ $retval -eq 0 ]; then
-        success
-        touch $lockfile
-    else
-        failure
-    fi
     echo
-
+    [ $retval -eq 0 ] && touch $lockfile
     return $retval
 }
 
 stop() {
     echo -n $"Stopping $prog: "
-    if [ -f ${botpidfile} ]; then
-        echo -n $"Shut down poker-bot first!"
-        failure
-        echo
-        return 1
-    fi
-    killproc -p ${pidfile} $prog
+    killproc -p $pidfile $prog
     retval=$?
     echo
     [ $retval -eq 0 ] && rm -f $lockfile
@@ -145,24 +66,43 @@
     restart
 }
 
-fdr_status() {
-    status $prog
+rh_status() {
+    status -p $pidfile $prog
 }
 
+rh_status_q() {
+    rh_status >/dev/null 2>&1
+}
+
+
 case "$1" in
-    start|stop|restart|reload)
+    start)
+        rh_status_q && exit 0
+        $1
+        ;;
+    stop)
+        rh_status_q || exit 0
+        $1
+        ;;
+    restart)
+        $1
+        ;;
+    reload)
+        rh_status_q || exit 7
         $1
         ;;
     force-reload)
         force_reload
         ;;
     status)
-        poker_status
+        rh_status
         ;;
     condrestart|try-restart)
-        [ ! -f $lockfile ] || restart
+        rh_status_q || exit 0
+        restart
         ;;
     *)
-        echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
         exit 2
 esac
+exit $?




More information about the fedora-extras-commits mailing list