Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 - 1
#!/bin/bash
2
#
3
# sendmail      This shell script takes care of starting and stopping
4
#               sendmail.
5
#
6
# chkconfig: 2345 80 30
7
# description: Sendmail is a Mail Transport Agent, which is the program \
8
#              that moves mail from one machine to another.
9
# processname: sendmail
10
# config: /etc/mail/sendmail.cf
11
# pidfile: /var/run/sendmail.pid
12
 
13
### BEGIN INIT INFO
14
# Provides: sendmail MTA smtpdaemon
15
# Required-Start: $local_fs $network
16
# Required-Stop: $local_fs $network
17
# Default-Start: 2 3 4 5
18
# Default-Stop: 0 1 6
19
# Short-Description: start and stop sendmail
20
# Description: sendmail is a Mail Transport Agent (MTA)
21
### END INIT INFO
22
 
23
# Source function library.
24
. /etc/rc.d/init.d/functions
25
 
26
# Source networking configuration.
27
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
28
 
29
# Source sendmail configureation.
30
if [ -f /etc/sysconfig/sendmail ]; then
31
    . /etc/sysconfig/sendmail
32
else
33
    DAEMON=no
34
    QUEUE=1h
35
fi
36
[ -z "$SMQUEUE" ] && SMQUEUE="$QUEUE"
37
[ -z "$SMQUEUE" ] && SMQUEUE=1h
38
 
39
# Check that we're a privileged user
40
[ `id -u` = 0 ] || exit 4
41
 
42
# Check that networking is up.
43
[ "${NETWORKING}" = "no" ] && exit 1
44
 
45
[ -x /usr/sbin/sendmail ] || exit 5
46
 
47
prog="sendmail"
48
 
49
updateconf() {
50
    /etc/mail/make > /dev/null 2>&1
51
    if [ $? -eq 15 ]; then
52
	echo -n $"Package sendmail-cf is required to update configuration."
53
	warning
54
	echo
55
    fi
56
    /etc/mail/make aliases > /dev/null 2>&1
57
}
58
 
59
start() {
60
    # Start daemons.
61
    ret=0
62
    updateconf
63
    echo -n $"Starting $prog: "
64
    daemon /usr/sbin/sendmail $([ "x$DAEMON" = xyes ] && echo -bd) \
65
	$([ -n "$QUEUE" ] && echo -q$QUEUE) $SENDMAIL_OPTARG
66
    RETVAL=$?
67
    echo
68
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail
69
    let ret+=$RETVAL
70
 
71
    if [ ! -f /var/run/sm-client.pid ]; then
72
	echo -n $"Starting sm-client: "
73
	touch /var/run/sm-client.pid
74
	chown smmsp:smmsp /var/run/sm-client.pid
75
	if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
76
	    /sbin/restorecon /var/run/sm-client.pid
77
	fi
78
	daemon --check sm-client /usr/sbin/sendmail -L sm-msp-queue -Ac \
79
	    -q$SMQUEUE $SENDMAIL_OPTARG
80
	RETVAL=$?
81
	echo
82
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sm-client
83
	let ret+=$RETVAL
84
    fi
85
 
86
    [ $ret -eq 0 ] && return 0 || return 1
87
}
88
 
89
reload() {
90
    updateconf
91
    echo -n $"Reloading $prog: "
92
    killproc sendmail -HUP
93
    RETVAL=$?
94
    echo
95
    if [ $RETVAL -eq 0 -a -f /var/run/sm-client.pid ]; then
96
        echo -n $"reloading sm-client: "
97
	killproc sm-client -HUP
98
	RETVAL=$?
99
	echo
100
    fi
101
    return $RETVAL
102
}
103
 
104
stop() {
105
    # Stop daemons.
106
    if [ -f /var/run/sm-client.pid ]; then
107
	echo -n $"Shutting down sm-client: "
108
	killproc sm-client
109
	RETVAL=$?
110
	echo
111
	[ $RETVAL -eq 0 ] && rm -f /var/run/sm-client.pid
112
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sm-client
113
    fi
114
    echo -n $"Shutting down $prog: "
115
    killproc sendmail
116
    RETVAL=$?
117
    echo
118
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail
119
    return $RETVAL
120
}
121
 
122
status -p /var/run/sendmail.pid >/dev/null || status -p /var/run/sm-client.pid >/dev/null
123
running=$?
124
 
125
# See how we were called.
126
case "$1" in
127
    start)
128
	[ $running -eq 0 ] && exit 0
129
	start
130
	RETVAL=$?
131
	;;
132
    stop)
133
	[ $running -eq 0 ] || exit 0
134
	stop
135
	RETVAL=$?
136
	;;
137
    reload)
138
	[ $running -eq 0 ] || exit 7
139
	reload
140
	RETVAL=$?
141
	;;
142
    restart|force-reload)
143
	stop
144
	start
145
	RETVAL=$?
146
	;;
147
    condrestart|try-restart)
148
	[ $running -eq 0 ] || exit 0
149
	stop
150
	start
151
	RETVAL=$?
152
	;;
153
    status)
154
	echo -n sendmail; status -p /var/run/sendmail.pid -l sendmail
155
	RETVAL=$?
156
	echo -n sm-client; status -p /var/run/sm-client.pid -l sm-client
157
	[ $RETVAL -eq 0 ] && RETVAL=$?
158
	;;
159
    *)
160
	echo $"Usage: $0 {start|stop|restart|condrestart|status}"
161
	RETVAL=2
162
esac
163
 
164
exit $RETVAL