~ubuntu-branches/debian/experimental/minetest/experimental

« back to all changes in this revision

Viewing changes to debian/minetest-server.init

  • Committer: Package Import Robot
  • Author(s): Martin Quinson, Markus Koschany
  • Date: 2014-11-21 11:24:53 UTC
  • Revision ID: package-import@ubuntu.com-20141121112453-c09jjsgt3dh88n1p
Tags: 0.4.10+repack-3
* Team upload.

[ Markus Koschany ]
* minetest-server: Support systemd and SysV init systems. (Closes: #769965)
  - Add minetest-server.init.
  - Add minetest-server.postinst and minetest-server.postrm.
    Create an unprivileged system-wide user, Debian-minetest. The new home
    directory is /var/games/minetest-server. All log files are written to
    /var/log/minetest.
  - Add minetest-server@.service file. This is a template unit file which
    allows system administrators to run multiple instances of the server.
    See minetest-server.README.Debian for more information.
  - Add minetest-server.service to run the default configuration.
* Install minetestserver binary to /usr/lib/minetest.
* Add minetestserver wrapper script and install it to /usr/games.
* Install default configuration file to /etc/minetest/minetest.conf.
* Add minetest-server.logrotate and daily rotate log files in
  /var/log/minetest for 14 days.
* Declare compliance with Debian Policy 3.9.6.
* debian/control:
  - minetest-server: Depend on adduser for maintainer scripts.
  - minetest-dbg: Depend either on minetest OR minetest-server.
* Fix lintian error quilt-series-without-trailing-newline.
* Fix lintian warning empty-short-license-in-dep5-copyright.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
### BEGIN INIT INFO
 
3
# Provides:          minetest-server
 
4
# Required-Start:    $remote_fs $network
 
5
# Required-Stop:     $remote_fs $network
 
6
# Default-Start:     2 3 4 5
 
7
# Default-Stop:      0 1 6
 
8
# Short-Description: Start minetest network game server
 
9
# Description:       dedicated game server for Minetest
 
10
### END INIT INFO
 
11
 
 
12
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
 
13
NAME="minetestserver"
 
14
DAEMON="/usr/games/$NAME"
 
15
DESC="minetest network game server"
 
16
PIDFILE="/var/run/$NAME.pid"
 
17
BINARY="/usr/lib/minetest/$NAME"
 
18
USER="Debian-minetest"
 
19
 
 
20
test -x $DAEMON || exit 0
 
21
 
 
22
. /lib/lsb/init-functions
 
23
 
 
24
# Include defaults if available
 
25
if [ -f /etc/default/$NAME ] ; then
 
26
    . /etc/default/$NAME
 
27
fi
 
28
 
 
29
minetest_start() {
 
30
    start-stop-daemon \
 
31
        --start \
 
32
        --quiet \
 
33
        --pidfile $PIDFILE \
 
34
        --oknodo \
 
35
        --background \
 
36
        --exec $BINARY \
 
37
        --startas $DAEMON \
 
38
        --make-pidfile --chuid $USER \
 
39
        -- $DAEMON_OPTS > /dev/null 2>&1 || return 1
 
40
    return 0
 
41
}
 
42
 
 
43
minetest_stop() {
 
44
    start-stop-daemon \
 
45
        --stop \
 
46
        --quiet \
 
47
        --pidfile $PIDFILE \
 
48
        --oknodo \
 
49
        --exec $BINARY || return 1
 
50
    rm -f $PIDFILE
 
51
    return 0
 
52
}
 
53
 
 
54
case "$1" in
 
55
    start)
 
56
        log_begin_msg "Starting $DESC: $NAME"
 
57
        minetest_start
 
58
        log_end_msg $?
 
59
    ;;
 
60
    stop)
 
61
        log_begin_msg "Stopping $DESC: $NAME"
 
62
        minetest_stop
 
63
        log_end_msg $?
 
64
    ;;
 
65
    restart|force-reload)
 
66
        log_begin_msg "Restarting $DESC: $NAME"
 
67
        minetest_stop && sleep 1 && minetest_start
 
68
        log_end_msg $?
 
69
    ;;
 
70
    status)
 
71
    status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
 
72
    ;;
 
73
    *)
 
74
    # echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
 
75
    echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
 
76
    exit 1
 
77
    ;;
 
78
esac
 
79
 
 
80
exit 0