~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to vivid/etc/init.d/cntlm

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
### BEGIN INIT INFO
 
4
# Provides:          cntlm
 
5
# Required-Start:    $remote_fs $syslog $time $network
 
6
# Required-Stop:     $remote_fs $syslog $time $network
 
7
# Default-Start:     2 3 4 5
 
8
# Default-Stop:      0 1 6
 
9
# Short-Description: Authenticating HTTP accelerator for NTLM secured proxies
 
10
# Description:       Cntlm is meant to be given your proxy address and becomming
 
11
#                    the primary proxy then, listening on a selected local port. 
 
12
#                    You point all your proxy-aware programs to it and don't ever
 
13
#                    have to deal with proxy authentication again.
 
14
### END INIT INFO
 
15
#
 
16
# DAEMON             Location of the binary
 
17
# PIDFILE            Make sure that you or, if used, -U uid can create/write it
 
18
# TIMEOUT            How long to wait for active connections to finish before 
 
19
#                    forcing cntlm to stop with a second signal 
 
20
# RUNAS              Name or number of the non-privileged account to run as
 
21
#
 
22
 
 
23
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
24
DAEMON=/usr/sbin/cntlm
 
25
NAME=cntlm
 
26
DESC="CNTLM Authentication Proxy"
 
27
 
 
28
# Set default values
 
29
PIDFILE=/var/run/cntlm/cntlm.pid
 
30
TIMEOUT=1
 
31
RUNAS=cntlm
 
32
 
 
33
test -x $DAEMON || exit 0
 
34
 
 
35
. /lib/lsb/init-functions
 
36
test -r /etc/default/rcS && . /etc/default/rcS
 
37
 
 
38
# Include custom values if available
 
39
if [ -f /etc/default/cntlm ] ; then
 
40
        . /etc/default/cntlm
 
41
fi
 
42
 
 
43
DAEMON_OPTS="$DAEMON_OPTS -U $RUNAS -P $PIDFILE"
 
44
PIDDIR=`dirname $PIDFILE 2>/dev/null`
 
45
 
 
46
start() {
 
47
        echo -n "Starting $DESC: "
 
48
 
 
49
        if [ -n "$PIDDIR" -a ! -d "$PIDDIR" ]; then
 
50
                mkdir -p "$PIDDIR" 2>/dev/null
 
51
                chown "$RUNAS" "$PIDDIR" 2>/dev/null
 
52
                chmod 755 "$PIDDIR" 2>/dev/null
 
53
        fi
 
54
 
 
55
        start-stop-daemon --oknodo --quiet --start --pidfile $PIDFILE --name $NAME --startas $DAEMON -- $DAEMON_OPTS 2>/dev/null
 
56
        if [ $? -eq 0 ]; then
 
57
                echo "$NAME."
 
58
        else
 
59
                echo "failed!"
 
60
        fi
 
61
}
 
62
 
 
63
stop() {
 
64
        echo -n "Stopping $DESC: "
 
65
        start-stop-daemon --oknodo --quiet --stop --retry -HUP/$TIMEOUT/-HUP/2/forever/-KILL --pidfile $PIDFILE --name $NAME
 
66
        if [ $? -eq 0 ]; then
 
67
                echo "$NAME."
 
68
        else
 
69
                echo "failed!"
 
70
        fi
 
71
}
 
72
 
 
73
case "$1" in
 
74
        start)
 
75
                start
 
76
                ;;
 
77
        stop)
 
78
                stop
 
79
                ;;
 
80
        restart|reload|force-reload)
 
81
                stop
 
82
                start
 
83
                ;;
 
84
        status)
 
85
          status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
 
86
          ;;
 
87
        *)
 
88
                echo "Usage: $0 {start|stop|restart|reload|force-reload|status}" >&2
 
89
                exit 2
 
90
                ;;
 
91
esac
 
92
 
 
93
exit 0