File: pinto.init

package info (click to toggle)
pinto 0.14000-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,904 kB
  • sloc: perl: 12,566; sh: 255; makefile: 7
file content (110 lines) | stat: -rw-r--r-- 2,553 bytes parent folder | download | duplicates (4)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#! /bin/sh

### BEGIN INIT INFO
# Provides:          pinto
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start and stop the web interface to a Pinto repository
# Description:       Controls the pinto perl module repository daemon "pintod".
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/pintod
NAME=pintod
PIDFILE=/var/run/pinto/$NAME.pid
DESC="pinto perl module repository"

umask 0037

test -f $DAEMON || exit 0

set -e

. /lib/lsb/init-functions

check_started() {
    if [ -f "$PIDFILE" ]; then
        pid="$(cat $PIDFILE)"
        if [ "$pid" ] && kill -0 $pid >/dev/null 2>/dev/null; then
            return 0    # Is started
        fi
    fi
    return 1      # Isn't started
}

start() {
    if ! check_started; then
        log_daemon_msg "Starting $DESC" "$NAME"

        # Could be removed during boot
        test -e /var/run/pinto || install -m 750 -o pinto -g pinto -d /var/run/pinto

        if ! START_ERROR=`start-stop-daemon --chuid pinto -u pinto --start \
            --pidfile $PIDFILE --exec $DAEMON -- \
            --root=/var/lib/pinto/repository/default/ --auth backend=Passwd \
            --auth path=/etc/pinto/htpasswd.users \
            --access-log=/var/log/pinto/access.log \
            --error-log=/var/log/pinto/error.log --daemonize \
            --pid $PIDFILE 2>&1`; then
            echo -n " "
            log_action_end_msg 1 "$START_ERROR"
            exit 0
        else
            log_end_msg 0
        fi
    else
        log_warning_msg "already running!"
    fi
}

stop() {
    log_daemon_msg "Stopping $DESC" "$NAME"
    killproc -p $PIDFILE /usr/bin/starman
    RETVAL=$?
    [ $RETVAL = 0 ] && rm -f $PIDFILE
    log_end_msg "$RETVAL"
}

restart() {
    stop
    sleep 1
    start
}

status() {
    log_action_begin_msg "checking $DAEMON"
    if check_started; then
        log_action_end_msg 0 "running"
    else
        if [ -e "$PIDFILE" ]; then
            log_action_end_msg 1 "$DAEMON failed"
            exit 1
        else
            log_action_end_msg 1 "not running"
            exit 3
        fi
    fi
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart|reload|force-reload)
        restart
        ;;
    status)
        status
        ;;
    *)
        log_warning_msg "Usage: $0 {start|stop|restart|reload|force-reload|status}" >&2
        exit 1
        ;;
esac

exit 0