blob: 34ea52892663f78f1c068605aea10275db677206 (
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
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
|
#!/bin/sh
#
# avr_evtd Linkstation/Kuro AVR daemon
#
# Other files used are:
# /etc/default/avr_evtd - Optional configuration file
# /etc/avr_evtd/EventScript - Provides user with scripted
# AVR event points
# Optional files:
# /etc/melco/timer_Sleep - Standard Melco sleep settings
#
# Written by Bob Perry (2006) lb-source@users.sourceforge.net
#
#
# Location of the avr watchdog daemon and the init directory
#
DAEMON=/usr/sbin/avr_evtd
initdir=/etc/init.d
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
tag=linkstation
facility=user.info
test -e $DAEMON || exit 0
getDevice()
{
#
# Load custom settings
#
MIPS=NO
#
# Populate the configured settings
#
[ -f /etc/default/avr_evtd ] && . /etc/default/avr_evtd > /dev/null 2>&1
# Try and determine the UART used. The MIPS only has one UART
# available and the process is built accordingly. To support modified
# kernel's/kuro systems with polled over UARTs, drill into kernel
# configuration for the memory configuration of the UART to determine
# which tty to use if not set in the configuration file
uname -m | grep -q mips && MIPS=YES && DEVICE=/dev/ttyS0
if [ -z "$DEVICE" ] && [ "$MIPS" = "NO" ]
then
DEVICE=/dev/ttyS0
# Search for valid port address
PORT_ADDRESS=`$DAEMON -i -d /dev/ttyS1`
if [ $PORT_ADDRESS -eq 80004500 ] ; then DEVICE=/dev/ttyS1 ; fi
fi
}
start()
{
#
# Daemon options
# e.g -d /dev/ttyS1
#
daemonoptions=
CONSOLE=OFF
getDevice
# Establish daemon startup options based on configuration settings
if [ "$EMMODE" = "YES" ]; then daemonoptions=-e ; fi
if [ -n "$DEVICE" ] && [ "$MIPS" = "NO" ]
then
[ -n "$daemonoptions" ] && daemonoptions="$daemonoptions "
daemonoptions="$daemonoptions-d $DEVICE"
fi
# Is this a MIPSEL box?
if [ "$MIPS" = "YES" ]
then
if [ -e /proc/linkstation ]
then
# Determine if console ttyS0 is in-use
CONSOLE=`cat /proc/linkstation | grep CONSOLE | awk -F "=" '{print $2}'`
fi
fi
if [ "$CONSOLE" = "ON" ]
then
echo "[avr_evtd]: Not started services as console in-use"
logger -t $tag -p $facility 'Not started avr_evtd as kernel still has console'
else
echo "Start services: avr_evtd"
/sbin/start-stop-daemon --start --quiet --exec $DAEMON -- $daemonoptions
logger -t $tag -p $facility 'Started daemon avr_evtd'
fi
}
stop()
{
echo "Stop services: avr_evtd"
/sbin/start-stop-daemon --stop --quiet --exec $DAEMON
logger -t $tag -p $facility 'Stopped daemon avr_evtd'
}
# Check request
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
*)
echo "Usage: $DAEMON {start|stop|restart}" >&2
;;
esac
exit 0
|