1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
#! /bin/bash
#############################################################################
# Liquid War is a multiplayer wargame #
# Copyright (C) 1998-2005 Christian Mauduit #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
# #
# Liquid War homepage : http://www.ufoot.org/liquidwar #
# Contact author : ufoot@ufoot.org #
#############################################################################
# Script used to start Liquid War servers, and run them as UNIX daemons.
#
# Typically, you could place this file in /etc/init.d, so that servers
# are started automatically when you boot your computer.
#
# Keep in mind that Liquid War is a *game* so its code might not be
# 100% exploit proof, and anyway, since Liquid War comes with
# NO WARRANTY at all, you simply run it at your own risks.
# This is not to scare you, but rather to insist on the fact that
# you should never run Liquid War servers as root. Run it under a
# "basic" user, which has very few rights, since the only rights the
# Liquid War daemon needs are:
# - be able to bind on a socket > 1024
# - be able to append stuff to a log file
# - be able to write its pid in a file
# None of these requires to be logged as root, so don't do it.
#
# Also keep in mind that running this script with its default options
# will make the Liquid War server you run on your computer register
# itself on the meta-server on www.ufoot.org. So people will be aware
# that you have a Liquid War server on your machine. While this is good
# for people who try to automatically find other online fellows,
# you might find this behaviour somewhat intrusive. Change the $PRIVACY
# value if the default behaviour does not match your needs.
# Clear our environment so we don't leak.
unset `env | sed s/=.*//`
prefix=@prefix@
NAME=liquidward
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=$prefix/games/liquidwar-server
PIDFILE=/var/games/liquidwar/$NAME.pid
LOGFILE=/var/games/liquidwar/$NAME.log
# As start-stop-daemon seems to be a quite Debian-specific utility,
# this script is in a way designed for Debian. If you want to run it
# on a box which does not have start-top-daemon, you'll need to
# edit the $START and $STOP commands to match your system.
START="start-stop-daemon --start --background --make-pidfile"
STOP="start-stop-daemon --stop"
# maximum number of players who can connect on this server
# by default: 6, which is the maximum
NBPLAYERS=6
# privacy policy:
# public -> the server is listed on www.ufoot.org
# private -> the server does not register itself
# by default, it is public, but you might want to change this
PRIVACY=public
# the password which client will have to give to be able
# to connect themselves on this server
# by default, no password is used
PASSWORD=
# the comment which will be associated to the server
# by default, it contains the name of the machine, but you might
# want to put your e-mail here for instance
COMMENT="Public_server_running_on_"`hostname`
# the user which should be used to start the daemon
# by default, it is set to "nobody:games", this assumes that
# there's a games group on your machine which has sufficient rights
# to write the pid and log files. If this is not the case, you'll
# need to either create a games group (and maybe a nobody user as weel)
# or change the $USER value, but remember: do *not* set it to root!
USER=nobody:games
# if you want the server to warn you whenevver someone connects on it,
# you might set up a callback script by uncommenting the line below.
# You'll also need to edit and install the liquidwar_notify.sh script
# manually
CALLBACK=$prefix/games/liquidwar_notify.sh
OPTIONS=" -"$NBPLAYERS" -"$PRIVACY" -log "$LOGFILE" -password "$PASSWORD" -comment \""$COMMENT"\" -callback "$CALLBACK
export LANG=C
export PATH
test -f $DAEMON || exit 0
case "$1" in
start)
echo "Starting" $NAME
$START --pidfile $PIDFILE --chuid $USER --exec $DAEMON -- $OPTIONS
;;
stop)
$STOP --pidfile $PIDFILE --chuid $USER
rm -f $PIDFILE
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $NAME {start|stop|restart}"
exit 1
;;
esac
exit 0
|