rpms/liquidwar/devel liquidwar.init, NONE, 1.1 liquidwar.logrotate, NONE, 1.1 liquidwar.sysconfig, NONE, 1.1 liquidwar.spec, 1.1, 1.2

Michael Thomas (wart) fedora-extras-commits at redhat.com
Fri Nov 24 06:52:30 UTC 2006


Author: wart

Update of /cvs/extras/rpms/liquidwar/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26933

Modified Files:
	liquidwar.spec 
Added Files:
	liquidwar.init liquidwar.logrotate liquidwar.sysconfig 
Log Message:
Added support for running liquidwar as a daemon




--- NEW FILE liquidwar.init ---
#!/bin/sh
#
# liquidwar    This shell script takes care of starting and stopping
#              the liquidwar game server.
#
# chkconfig:   - 15 85
# description: The liquidwar server supports playing networked \
#              multi-player games.
# processname: liquidwar-server
# config:      /etc/sysconfig/liquidwar
# pidfile:     /var/run/liquidwar-server.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

exec="/usr/bin/liquidwar-server"
prog=$(basename $exec)
name=liquidwar
pidfile=/var/run/$prog.pid

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

start() {
    echo -n $"Starting liquidwar game server: "
    if [ -n "`/sbin/pidof $prog`" ]; then
        echo -n $"$prog already running"
        failure
        echo
        return 1
    fi

    # This doesn't properly detect startup failures
    daemon --user liquidwar $exec $LIQUIDWAR_OPTIONS >>/var/log/${prog}.log 2>&1 &
    retval=$?
    if [ $retval -eq 0 ]; then
        success
        touch $lockfile
    else
        failure
    fi
    echo
    return $retval
}

stop() {
    echo -n $"Stopping liquidwar game server: "
    killproc $prog
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

reload() {
    restart
}

force_reload() {
    restart
}

fdr_status() {
    status $prog
}

case "$1" in
    start|stop|restart|reload)
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        fdr_status
        ;;
    condrestart|try-restart)
        [ ! -f $lockfile ] || restart
    ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
        exit 2
esac


--- NEW FILE liquidwar.logrotate ---
/var/log/liquidwar-server.log {
    copytruncate
    notifempty
    missingok
}


--- NEW FILE liquidwar.sysconfig ---
#
# liquidwar-server(6) options. Pick a custom port here if needed, for example.
#

# The default options call for a 2 player game that is not advertised to
# the public metaserver.  The default port that the game uses is tcp/8035.  Be
# sure to open up this port in your firewall, or change the port in the
# options below.
LIQUIDWAR_OPTIONS="-2 -private"


Index: liquidwar.spec
===================================================================
RCS file: /cvs/extras/rpms/liquidwar/devel/liquidwar.spec,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- liquidwar.spec	23 Nov 2006 20:18:49 -0000	1.1
+++ liquidwar.spec	24 Nov 2006 06:52:00 -0000	1.2
@@ -1,15 +1,23 @@
 Name:           liquidwar
 Version:        5.6.3
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Multiplayer wargame with liquid armies
 Group:          Amusements/Games
 License:        GPL
 URL:            http://www.ufoot.org/liquidwar/v5
-Source:         http://download.savannah.nongnu.org/releases/%{name}/%{name}-%{version}.tar.gz
+Source0:        http://download.savannah.nongnu.org/releases/%{name}/%{name}-%{version}.tar.gz
+Source1:        liquidwar.init 
+Source2:        liquidwar.sysconfig 
+Source3:        liquidwar.logrotate 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires:  allegro-devel allegro-tools tetex-latex python texinfo
 Requires(post): /sbin/install-info
 Requires(preun): /sbin/install-info
+Requires(post): /sbin/chkconfig
+Requires(post): /sbin/service
+Requires(preun): /sbin/chkconfig
+Requires(preun): /sbin/service
+Requires(postun): /sbin/service
 
 %description
 Liquid War is a unique multiplayer wargame. You control an army of liquid
@@ -27,6 +35,13 @@
 This package contains the documentation of LiquidWar in html, pdf, ps and txt
 format.
 
+%package server
+Summary:        Network game server for the LiquidWar game
+Group:          Amusements/Games
+Requires:       %{name} = %{version}-%{release}
+%description server
+This package contains the server for hosting network LiquidWar games.
+
 
 %prep
 %setup -q
@@ -76,6 +91,12 @@
 install -p -m 644 misc/%{name}.xpm \
   $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/48x48/apps/%{name}.xpm
 
+install -p -D -m 755 %{SOURCE1} \
+        $RPM_BUILD_ROOT/%{_initrddir}/%{name}-server
+install -p -D -m 644 %{SOURCE2} \
+        $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/%{name}-server
+install -p -D -m 644 %{SOURCE3} \
+        $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/%{name}-server
 
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -99,14 +120,38 @@
    %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
 fi
 
+%pre server
+user_uid=`id -u %{name} 2>/dev/null`
+if [ x"$user_uid" = x ] ; then
+    useradd -r -s /sbin/nologin -d %{_datadir}/%{name} -M \
+            -c 'LiquidWar Server' \
+            %{name} >/dev/null || :
+fi
+
+%post server
+/sbin/chkconfig --add %{name}-server
+
+%preun server
+if [ "$1" -le "0" ]; then
+    /sbin/service %{name}-server stop > /dev/null 2>&1
+    /sbin/chkconfig --del %{name}-server
+fi
+
+%postun server
+if [ "$1" -ge "1" ]; then
+    /sbin/service %{name}-server condrestart > /dev/null 2>&1
+fi
+
 
 %files
 %defattr(-,root,root,-)
 %doc COPYING README
-%{_bindir}/%{name}*
+%{_bindir}/%{name}
+%{_bindir}/%{name}-mapgen
 %{_datadir}/%{name}
 %{_infodir}/%{name}.*
-%{_mandir}/man6/%{name}*.6.gz
+%{_mandir}/man6/%{name}.6.gz
+%{_mandir}/man6/%{name}-mapgen.6.gz
 %{_datadir}/applications/fedora-%{name}.desktop
 %{_datadir}/icons/hicolor/*/apps/%{name}.xpm
 
@@ -114,7 +159,17 @@
 %defattr(-,root,root,-)
 %doc liquidwardocs/*
 
+%files server
+%{_bindir}/%{name}-server
+%{_mandir}/man6/%{name}-server.6.gz
+%{_initrddir}/%{name}-server
+%config(noreplace) %{_sysconfdir}/sysconfig/%{name}-server
+%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}-server
+
 
 %changelog
+* Thu Nov 23 2006 Wart <wart at kobold.org> 5.6.3-2
+- Added init.d startup script for the game server
+
 * Sun Nov 19 2006 Hans de Goede <j.w.r.degoede at hhs.nl> 5.6.3-1
 - Initial Fedora Extras package




More information about the fedora-extras-commits mailing list