File: postman.init

package info (click to toggle)
postman 2.1-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 8,240 kB
  • ctags: 3,249
  • sloc: cpp: 33,376; ansic: 2,014; sh: 780; makefile: 300
file content (74 lines) | stat: -rw-r--r-- 2,117 bytes parent folder | download | duplicates (2)
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
#! /bin/sh
#
# skeleton	example file to build /etc/init.d/ scripts.
#		This file should be used to construct scripts for /etc/init.d.
#
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian GNU/Linux
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:	@(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
#
# This file was automatically customized by dh-make on Sun, 21 Jul 2002 22:30:22 +0200

PATH="/sbin:/bin:/usr/sbin:/usr/bin"
DAEMON="/usr/sbin/interdaemon"
NAME="interdaemon"
USER="postman"
DESC="Postman daemon"
CONFIG="/etc/postman/interdaemon.cfg"
PIDFILE="/var/lib/postman/server/${NAME}.pid"

# Test daemon and config file
[ -x "$DAEMON" ] || exit 0
[ -f "$CONFIG" ] || exit 0

set -e

var_clean(){
  test -d /var/lib/postman/locks    \
    && find /var/lib/postman/locks -type f -exec rm {} \;
  test -d /var/lib/postman/sessions \
    && find /var/lib/postman/sessions -type s -exec rm {} \;
  test -d /var/lib/postman/tmp      \
    && find /var/lib/postman/tmp -type f -exec rm {} \;
}

case "$1" in
  start)
    if test -f "$PIDFILE" && kill -0 `cat "$PIDFILE"` 2>/dev/null; then
      echo "$DESC '$NAME' already running."
    else
      var_clean
      echo -n "Starting $DESC: $NAME"
      start-stop-daemon --start --oknodo --quiet --pidfile "$PIDFILE" \
        --background --chuid "$USER" --exec "$DAEMON" -- "$CONFIG"
      echo "."
    fi
    ;;
  stop)
    if test -f "$PIDFILE" && kill -0 `cat "$PIDFILE"` 2>/dev/null; then
      echo -n "Stopping $DESC: $NAME"
      start-stop-daemon --stop --oknodo --quiet --pidfile "$PIDFILE" \
        --exec "$DAEMON"
      echo "."
    else
      echo "$DESC '$NAME' was not running."
    fi
    ;;
  restart|force-reload)
    echo -n "Restarting $DESC: $NAME"
    start-stop-daemon --stop --oknodo --quiet --pidfile "$PIDFILE" \
      --exec "$DAEMON"
    var_clean
    start-stop-daemon --start --oknodo --quiet --pidfile "$PIDFILE" \
      --background --chuid "$USER" --exec "$DAEMON" -- "$CONFIG"
    echo "."
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
esac

exit 0