blob: eecdc3ec23c7c9700f79dc0ceb4c9c1e7e4a86a0 (
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
|
#!/bin/sh
# Log to syslog and to stderr
LOG="mylog"
mylog() {
[ -n "$(which logger)" ] && logger -t $(basename ${0}) "${1}"
echo "${1}" >&2;
}
usage(){
${LOG} "Usage: $(basename $0) -r <reason activity|key|watchdog> -o <orgin startup|shutdown|running> -v <value>"
${LOG} " -C <ConfigDirectory> -c <CacheDirectory> -R <ResourceDirectory>"
${LOG} "$cmd_error"
exit 1
}
cmd_error=""
while getopts ":r:o:v:C:c:R:" opt; do
case "$opt" in
r) PARAM_REASON="$OPTARG";;
o) PARAM_ORGIN="$OPTARG";;
v) PARAM_VALUE="$OPTARG";;
C) PARAM_CONFIGDIRECTORY="$OPTARG";;
c) PARAM_CACHEDIRECTORY="$OPTARG";;
R) PARAM_RESOURCEDIRECTORY="$OPTARG";;
--) break;;
\?) cmd_error="$(gettext 'Error: Error parsing Commandline')"; break;;
esac
done
[ -n "$cmd_error" ] && usage
# could ovveride the directories for FHS
[ -r "${PARAM_CONFIGDIRECTORY}/directories.conf" ] && . "${PARAM_CONFIGDIRECTORY}/directories.conf"
[ -d "${PARAM_CONFIGDIRECTORY}/${PARAM_REASON}" ] || exit 0
UACTIVITY_CONFIGDIRECTORY="${PARAM_CONFIGDIRECTORY}"
UACTIVITY_CACHEDIRECTORY="${PARAM_CACHEDIRECTORY}"
UACTIVITY_RESOURCEDIRECTORY="${PARAM_RESOURCEDIRECTORY}"
export UACTIVITY_CONFIGDIRECTORY UACTIVITY_CACHEDIRECTORY UACTIVITY_RESOURCEDIRECTORY
UACTIVITY_ORGIN="${PARAM_ORGIN}"
export UACTIVITY_ORGIN
case "${PARAM_REASON}" in
activity)
commandline="${PARAM_ORGIN} ${PARAM_VALUE}"
UACTIVITY_ACTIVITY="${PARAM_VALUE}"
export UACTIVITY_ACTIVITY
;;
key)
if [ "${PARAM_VALUE}" != "_Setup" ]; then
commandline="${PARAM_ORGIN} ${PARAM_VALUE}"
UACTIVITY_KEY="${PARAM_VALUE}"
else
commandline="${PARAM_ORGIN} ''"
UACTIVITY_KEY=""
fi
export UACTIVITY_KEY
;;
watchdog)
commandline="${PARAM_ORGIN} ${PARAM_VALUE}"
UACTIVITY_ACTIVITY="${PARAM_VALUE}"
export UACTIVITY_ACTIVITY
;;
esac
hooks="$(find "${PARAM_CONFIGDIRECTORY}/${PARAM_REASON}" -maxdepth 1 -xtype f -name '[0-9][0-9]*' | sort)"
for hook in ${hooks}; do
if [ -x $hook ]; then
eval $hook $commandline "$PARAM_CONFIGDIRECTORY" "$PARAM_CACHEDIRECTORY" "$PARAM_RESOURCEDIRECTORY"
else
eval /bin/sh $hook $commandline "$PARAM_CONFIGDIRECTORY" "$PARAM_CACHEDIRECTORY" "$PARAM_RESOURCEDIRECTORY"
fi
[ $? -ne 0 ] && ${LOG} "error when executing ${hook}"
done
exit 0
|