~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to utopic/etc/init.d/apt-cacher

  • 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
 
 
4
 
### BEGIN INIT INFO
5
 
# Provides:          apt-cacher
6
 
# Required-Start:    $remote_fs
7
 
# Required-Stop:     $remote_fs
8
 
# Default-Start:     2 3 4 5
9
 
# Default-Stop:      0 1 6
10
 
# Short-Description: apt-cacher package caching proxy daemon 
11
 
# Description:       The apt-cacher service is used to cache packages for a system or LAN
12
 
### END INIT INFO
13
 
 
14
 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
15
 
DESC="Apt-Cacher"
16
 
NAME=apt-cacher
17
 
DAEMON=/usr/sbin/$NAME
18
 
PIDFILE=/var/run/$NAME/$NAME.pid
19
 
SCRIPTNAME=/etc/init.d/$NAME
20
 
 
21
 
# Gracefully exit if the package has been removed.
22
 
test -x $DAEMON || exit 0
23
 
 
24
 
# Read config file if it is present.
25
 
if [ -r /etc/default/$NAME ]
26
 
then
27
 
        . /etc/default/$NAME
28
 
fi
29
 
 
30
 
. /lib/lsb/init-functions
31
 
 
32
 
#
33
 
#       Function that starts the daemon/service.
34
 
#
35
 
d_start() {
36
 
 
37
 
    if test "$AUTOSTART" = 1 ; then
38
 
        start-stop-daemon --start --quiet  \
39
 
            --exec $DAEMON -- -R 3 -d -p $PIDFILE $EXTRAOPT && \
40
 
            echo "$NAME."
41
 
    else
42
 
        echo "Not started (AUTOSTART not enabled in /etc/default/$NAME)";
43
 
    fi
44
 
}
45
 
 
46
 
#
47
 
#       Function that stops the daemon/service.
48
 
#
49
 
d_stop() {
50
 
        start-stop-daemon --stop --quiet --retry=TERM/10/KILL/5 --pidfile $PIDFILE \
51
 
                --name $NAME
52
 
 
53
 
        # Also stop any running libcurl backend
54
 
        /usr/share/apt-cacher/libcurl.pl EXIT
55
 
}
56
 
 
57
 
case "$1" in
58
 
  start)
59
 
        echo -n "Starting $DESC: "
60
 
        d_start
61
 
        ;;
62
 
  stop)
63
 
        echo -n "Stopping $DESC: "
64
 
        d_stop
65
 
        echo "$NAME."
66
 
        ;;
67
 
  restart)
68
 
        echo -n "Restarting $DESC: "
69
 
        d_stop
70
 
        sleep 1
71
 
        d_start
72
 
        ;;
73
 
  force-reload|reload)
74
 
        echo -n "Reloading configuration of $DESC: "
75
 
        test -f $PIDFILE && pid=`cat $PIDFILE`
76
 
        if test -z "$pid" ; then
77
 
            echo "$NAME not running."
78
 
        else
79
 
            kill -HUP $pid && echo "done!."
80
 
        fi
81
 
        ;;
82
 
  status)
83
 
        status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
84
 
        ;;
85
 
  *)
86
 
        echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2
87
 
        exit 1
88
 
        ;;
89
 
esac
90
 
 
91
 
exit 0