summaryrefslogtreecommitdiff
path: root/system/displaylink/rc.displaylink
blob: 8fd7d9cd479f6410cdf6e298e7cfe80372b3724a (plain)
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
#!/bin/sh
# Start/stop DisplayLink

PIDFILE=/var/run/displaylink/displaylink.pid
DAEMON=@INSTALL_PATH@DisplayLinkManager

displaylink_start() {
  modprobe evdi
  $DAEMON &
  PID=$(echo $!)
  if [ ! -z $PID ]
  then
    echo $PID > $PIDFILE
  fi
  exit $?
}

displaylink_stop() {
 if [ -f $PIDFILE ]
 then
   kill -HUP $(cat $PIDFILE)
   rm -f $PIDFILE
 fi
 exit $?
}

displaylink_restart() {
  displaylink_start
  sleep 1
  displaylink_stop
}

print_usage() {
  echo "usage $0 start|stop|restart"
}

case "$1" in
  'start')
    displaylink_start
    ;;
  'stop')
    displaylink_stop
    ;;
  'restart')
    displaylink_restart
    ;;
  *)
    print_usage
    ;;
esac