blob: cfd6d374a168d1b91c044d98c353fa9930b4fa55 (
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
|
#!/bin/ash
if [ ! -x "/etc/default/rc.conf" ]; then
echo "ERROR: /etc/default/rc.conf missing!"
exit 1
fi
. /etc/default/rc.conf
if [ -x /etc/rc.conf ]; then
. /etc/rc.conf
fi
### Check if $1 is yes or no/notset
checkyesno() {
case $1 in
# "yes", "true", "on", or "1"
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
return 0
;;
# "no", "false", "off", or "0"
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
return 1
;;
esac
return 1
}
### Run command
rc_run_command() {
if [ "$2" != "" ]; then
_name=$2
eval _enable=\$${_name}_enable
if ! checkyesno "$_enable"; then
return 0
fi
fi
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
}
### Mount fs
mount_fs() {
if [ "$1" = "" -o "$2" = "" -o "$3" = "" ]; then
return;
fi
echo -n " $2"
if [ "$4" = "" ]; then
if ! ${mount_program} -t $3 $1 $2; then
echo -n "=failed"
return 1
fi
else
if ! ${mount_program} -t $3 -o $4 $1 $2; then
echo -n "=failed"
fi
fi
return 0
}
mkdir_fs() {
if [ "$1" = "" ]; then
return 1;
fi
if ! ${mkdir_program} $1 2>/dev/null; then
log_error "mkdir $1 failed"
return 1
fi
return 0
}
### Kill process based on pidfile
killpid() {
if [ ! -f "$1" ]; then
return 0
fi
read _pid < $1
${kill_program} ${_pid} > /dev/null 2>&1
}
## Log error
log_error() {
echo "$1" | logger -p error
}
|