File: init.d

package info (click to toggle)
xmail 1.22-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,840 kB
  • ctags: 3,857
  • sloc: cpp: 33,585; sh: 625; makefile: 102; perl: 56; sql: 31
file content (90 lines) | stat: -rw-r--r-- 1,926 bytes parent folder | download
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
#! /bin/sh
#
#               Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#               Modified by Davide Libenzi <davidel@xmailserver.org>.
#               Modified by Radu Spineanu <radu@timisoara.roedu.net>.

### BEGIN INIT INFO
# Provides:          xmail mail-transport-agent pop3-server finger-server
# Required-Start:    $local_fs $remote_fs $syslog $network $time
# Required-Stop:     $local_fs $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: ESMTP/POP3 mail server
### END INIT INFO


XMAIL_ROOT=/var/lib/xmail
XMAIL_CMD_LINE=`cat /etc/xmail/cmd_line`
PATH=$XMAIL_ROOT/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=$XMAIL_ROOT/bin/XMail
NAME=XMail
DESC="XMail server"

if [ -f /etc/xmail/default_domain ]; then
	DEFAULT_DOMAIN=`cat /etc/xmail/default_domain`
fi


test -f $DAEMON || exit 0

set -e

# create message.id file if not exists
check_msgid()
{
 if [ ! -f /var/lib/xmail/message.id ] ; then
   echo -e '1\r\n\0' > /var/lib/xmail/message.id
 fi
}

start_xmail()
{
    MAIL_ROOT=$XMAIL_ROOT
	export MAIL_ROOT
    MAIL_CMD_LINE=$XMAIL_CMD_LINE
	export MAIL_CMD_LINE
    export DEFAULT_DOMAIN
    
    check_msgid
    start-stop-daemon --start --exec $DAEMON 
    while [ ! -f /var/run/$NAME.pid ]
    do
        sleep 1
    done
}


stop_xmail()
{
      start-stop-daemon --stop --pid /var/run/$NAME.pid --retry 120 --name $NAME --oknodo --signal 2 --quiet
}


case "$1" in
  start)
      echo -n "Starting $DESC: "
      start_xmail
      #echo "$NAME. [" `cat /var/run/$NAME.pid` "]"
      echo "$NAME."
	;;
  stop)
      echo -n "Stopping $DESC: "
      stop_xmail
      echo "$NAME."
	;;
  restart|force-reload)
	echo -n "Restarting $DESC: "
	stop_xmail
	sleep 1
	start_xmail
        echo "$NAME."
	;;
  *)
	N=/etc/init.d/xmail
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0