158562202dbc092b5a19f5e90132640d61d47a1f
[myplc.git] / plc.d / mail
1 #!/bin/bash
2 #
3 # priority: 200
4 #
5 # Start local mail server.
6 #
7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2006 The Trustees of Princeton University
9 #
10
11 # Source function library and configuration
12 . /etc/plc.d/functions
13 . /etc/planetlab/plc_config
14
15 # Be verbose
16 set -x
17
18 case "$1" in
19     start)
20         if [ "$PLC_MAIL_ENABLED" != "1" ] ; then
21             exit 0
22         fi
23
24         MESSAGE=$"Starting mail server"
25         dialog "$MESSAGE"
26
27         # Add apache to list of users that can send mail as others
28         # without a warning, so that the API can send out mail.
29         count=$(grep ^apache /etc/mail/trusted-users|wc -l)
30         if [ $count -eq 0 ] ; then
31                 echo "apache" >>/etc/mail/trusted-users
32         fi
33
34         (exec 3>&- 4>&- ; service sendmail start)
35         check
36
37         result "$MESSAGE"
38         ;;
39
40     stop)
41         MESSAGE=$"Stopping mail server"
42         dialog "$MESSAGE"
43
44         service sendmail stop
45         check
46
47         result "$MESSAGE"
48         ;;
49 esac
50
51 exit $ERRORS