blob: 6f29e9c6ed4629aada240fd199656e273cd9eaea [file] [log] [blame]
Brad Bishopba6de432019-05-21 08:07:33 -04001#! /bin/sh
2### BEGIN INIT INFO
3# Provides: irda
4# Required-Start: $network $remote_fs
5# Required-Stop: $network $remote_fs
6# Default-Start: 2 3 4 5
7# Default-Stop: 0 1 6
8# Short-Description: Infrared port support
9### END INIT INFO
10
11NAME="irattach"
12test -x "$IRDA_DAEMON" || IRDA_DAEMON=/usr/sbin/irattach
13test -z "$IRATTACH_PID" && IRATTACH_PID=/var/run/irattach.pid
14
15# Source function library.
16. /etc/init.d/functions
17
18module_id() {
19 awk 'BEGIN { FS=": " } /Hardware/ { print $2 } ' </proc/cpuinfo
20}
21
22if [ ! -f /etc/sysconfig/irda ]; then
23 case `module_id` in
24 "HP iPAQ H2200" | "HP iPAQ HX4700" | "HTC Universal")
25 IRDA=yes
26 DEVICE=/dev/ttyS2
27 DONGLE=
28 DISCOVERY=
29 ;;
30 *)
31 IRDA=yes
32 DEVICE=/dev/ttyS1
33 DONGLE=
34 DISCOVERY=
35 ;;
36 esac
37else
38 . /etc/sysconfig/irda
39fi
40
41# Check that irda is up.
42[ ${IRDA} = "no" ] && exit 0
43
44[ -f /usr/sbin/irattach ] || exit 0
45
46ARGS=
47if [ $DONGLE ]; then
48 ARGS="$ARGS -d $DONGLE"
49fi
50if [ "$DISCOVERY" = "yes" ];then
51 ARGS="$ARGS -s"
52fi
53
54case "$1" in
55 start)
56 echo -n "Starting IrDA: $NAME"
57 start-stop-daemon --start --quiet --exec "$IRDA_DAEMON" ${DEVICE} ${ARGS} --pidfile "$IRATTACH_PID"
58 sleep 1
59 [ -f /var/run/irattach.pid ] && echo " done" || echo " fail"
60 ;;
61 stop)
62 echo "Stopping IrDA: $NAME"
63 start-stop-daemon --stop --quiet --exec "$IRDA_DAEMON" --pidfile "$IRATTACH_PID"
64 ;;
65 restart|force-reload)
66 $0 stop
67 $0 start
68 ;;
69 status)
70 status irattach
71 exit $?
72 ;;
73 *)
74 N=/etc/init.d/$NAME
75 echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
76 exit 1
77 ;;
78esac