-
Notifications
You must be signed in to change notification settings - Fork 1
/
appie
executable file
·112 lines (85 loc) · 1.85 KB
/
appie
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
#!/bin/bash
MOD=`echo $1 | awk -F ':' '{print $1}'`
CMD=`echo $1 | awk -F ':' '{print $2}'`
CMD=${CMD:-main}
LIB_DIR=/usr/lib/appie
USAGE="
Usage: appie help|version|<module>[:<command>] <options>
module Module id
command command id (defaults to 'main')
options module/command specific options
type 'appie <module>[:<command>] help' for per command help
type 'appie modules' for available modules, and 'appie commands
<module>' for available commands per module.
"
if [ -z "$MOD" ]; then
echo "$USAGE"
exit 1
fi
DIR=`dirname $0`
if [ "$MOD" = "help" ]; then
echo "$USAGE"
exit 1
fi
if [ "$MOD" = "version" ]; then
cat $LIB_DIR/VERSION
exit 1
fi
if [ "$MOD" = "commands" ]; then
echo ""
if [ -e $LIB_DIR/modules/$2/DESCR ]; then
cat $LIB_DIR/modules/$2/DESCR
echo
else
echo "No description available"
echo
fi
echo ""
exit 1
fi
# Shift module:command parameter off the arguments stack
#
shift
export APPIE=$0
export APPIE_BASE=$LIB_DIR
export MOD_BASE=$LIB_DIR/modules/$MOD
# Load global config
#
. /etc/appie.conf
# Load includes
#
source $LIB_DIR/includes
if [ "$MOD" = "modules" ]; then
echo "Available modules:"
for mod in `listModules`; do
echo "* $mod"
if [ -e $LIB_DIR/modules/$mod/DESCR ]; then
cat $LIB_DIR/modules/$mod/DESCR
echo
else
echo "No description available"
echo
fi
done
echo ""
exit 1
fi
# Just to make sure, reload profile
#
if [ -e $HOME/$PROFILE_ID ]; then
. $HOME/$PROFILE_ID
fi
# Load module config if available
#
if [ -e $LIB_DIR/modules/$MOD/$MOD.conf ]; then
. $LIB_DIR/modules/$MOD/$MOD.conf
fi
# Last arrangements...
#
umask 0002
# Execute command, and let's see what happens...
#
$LIB_DIR/modules/$MOD/$CMD $*
# Return result of last command
#
exit $?