File: g15daemon.init

package info (click to toggle)
g15daemon 1.9.5.3-12
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 2,144 kB
  • sloc: sh: 9,189; ansic: 3,188; perl: 115; makefile: 66
file content (125 lines) | stat: -rw-r--r-- 2,825 bytes parent folder | download
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#! /bin/sh

### BEGIN INIT INFO
# Provides:          g15daemon
# Required-Start:    $syslog $local_fs $remote_fs
# Required-Stop:     $syslog $local_fs $remote_fs
# Should-Start:      $remote_fs
# Should-Stop:       $remote_fs
# X-Start-Before:    xdm kdm gdm ldm sdm
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: load deamon for Logitech G15 keyboard lcd display
# Description:       load deamon for Logitech G15 keyboard lcd display
### END INIT INFO


PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/g15daemon
NAME=g15daemon
DESC="Logitech G15 keyboard LCD multiplexer"

[ -x "$DAEMON" ] || exit 0

. /lib/lsb/init-functions

# Include g15daemon defaults if available
if [ -f /etc/default/g15daemon ] ; then
    . /etc/default/g15daemon
fi

if [ "$G15DEBUG" = "on" ]; then

log() {
    logger -p daemon.debug -t g15 -- "$*"
}
else

log() {
    true
}

fi

check_new_init() {
    if [ -d /run/systemd/system ] ; then
        exit $1
    fi
}

load_uinput() {
    if [ ! -e /dev/uinput ] ; then
        modprobe -q uinput
        udevadm settle -t 5 -E /dev/uinput
        [ -e /dev/uinput 3 ] || return 1
    fi
}

is_running() {
   start-stop-daemon --stop --test --quiet --pidfile \
        /var/run/$NAME.pid --exec $DAEMON
}

do_start() {
    start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
        --exec $DAEMON -- $DAEMON_OPTS
}

do_stop() {
    start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
        --oknodo --retry 5 --exec $DAEMON
}

case "$1" in
    start)
        log_daemon_msg "Starting $DESC" $NAME
        load_uinput || log_warning_msg "/dev/uinput not found"
        do_start
        log_end_msg $?
        ;;
    stop)
        log_daemon_msg "Stopping $DESC" $NAME
        if do_stop ; then
            log_end_msg 0
        else
            log_end_msg 1
            exit 1
        fi
        ;;
    force-reload)
        is_running && $0 restart || exit 0
        ;;
    restart)
        log_daemon_msg "Restarting $DESC" $NAME
        if ! do_stop ; then
            log_end_msg 1
            exit 1
        fi
        # the device is slow to shut-down
        sleep 1
        load_uinput || log_warning_msg "/dev/uinput not found"
        do_start
        log_end_msg $?
        ;;
    status)
        is_running
        exit $?
        ;;
    udev)
        check_new_init 0
        log "calling g15 udev; action: $ACTION, product $PRODUCT"
        if [ "x$ACTION" = "xadd" ] ; then
            # If g15daemon is running, it will handle replugging.
            is_running && exit 0
            load_uinput
            do_start
        fi
        ;;
    *)
        N=/etc/init.d/$NAME
        log_action_msg "Usage: $N {start|stop|restart|force-reload|status}"
        exit 1
        ;;
esac

exit 0