File: github-webhook-ofiwg-init.d-ubuntu

package info (click to toggle)
libfabric 2.1.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,108 kB
  • sloc: ansic: 387,262; python: 3,171; sh: 2,555; makefile: 1,313; cpp: 617; perl: 474; ruby: 123; asm: 27
file content (85 lines) | stat: -rwxr-xr-x 1,657 bytes parent folder | download | duplicates (9)
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
#! /bin/sh
### BEGIN INIT INFO
# Provides:          github-webhook-ofiwg
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop:      0
# Short-Description: Run the Github webhook for ofiwg
# Description:
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
[ -f /etc/default/github-webhook-ofiwg ] && . /etc/default/github-webhook-ofiwg

. /lib/lsb/init-functions

RETVAL=0
prog="/var/www/html/github-webhooks/ofiwg/verify-signed-off.rb"
desc="Github webhook listener for ofiwg"
pidfile="/var/run/github-webhook-ofiwg.pid"

do_start() {
    [ -x $prog ] || exit 5

    log_action_msg "Starting $desc"

    pid=`ps -eadf | grep "ruby $prog" | grep -v grep | awk '{ print $2 }'`
    if test -z "$pid"; then
	$prog > /dev/null 2>&1 &
	RETVAL=$?
    else
	RETVAL=1
    fi
    [ $RETVAL -eq 0 ] && log_success_msg
    [ $RETVAL -ne 0 ] && log_failure_msg
    log_end_msg $RETVAL
    return $RETVAL
}

do_stop() {
    [ -x $prog ] || exit 5

    log_action_msg "Stopping $desc"
    pid=`ps -eadf | grep "ruby $prog" | grep -v grep | awk '{ print $2 }'`
    if test -n "$pid"; then
	kill $pid > /dev/null 2>&1
	RETVAL=$?
    else
	RETVAL=1
    fi
    [ $RETVAL -eq 0 ] && log_success_msg
    [ $RETVAL -ne 0 ] && log_failure_msg
    log_end_msg $RETVAL
    return $RETVAL
}

do_restart() {
    do_stop
    sleep 1
    do_start
}

case "$1" in
  start)
        do_start
	;;
  restart)
	do_restart
	;;
  reload|force-reload)
	log_action_msg "Error: argument '$1' not supported"
        log_action_end_msg 7
	exit 7
	;;
  stop)
	do_stop
	;;
  *)
	log_action_msg "Usage: $0 start|stop|restart"
        log_action_end_msg 3
	exit 3
	;;
esac

exit $RETVAL