-
Notifications
You must be signed in to change notification settings - Fork 1
/
includes
executable file
·93 lines (68 loc) · 1.42 KB
/
includes
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
#
# Library of functions, that may or may not be handy...
#
# Return 'true' if the user is indeed an appie admin
# (can write to APP_BASE dir),
# else return 'false'.
# TODO: use 'groups'
isAppAdmin() {
if [ -w "$APP_BASE" ]; then
echo "true"
return
fi
echo "false"
}
# Can user write to this target?
#
isWritable() {
if [ -w $1 ]; then
echo "true"
return
fi
echo "false"
}
# Check whether group given already exists in /etc/group
#
groupExists() {
GROUP=$1
if cat /etc/group | awk -F : '{ print $1 }' | grep -q $GROUP; then
echo "true"
return
fi
echo "false"
}
find_available_ports() {
APP=$1
USR=$2
PORTS=$3
PORTS=${PORTS:=$PORT_ALLOC}
APP_PORT_BASE=""
APP_PORT_LAST=""
if [ ! -e $PORT_DB ]; then
touch $PORT_DB
APP_PORT_BASE=$PORT_BASE
else
APP_PORT_BASE=`tail -1 $PORT_DB | awk '{print $1}'`
fi
echo `expr $APP_PORT_BASE + $PORTS` "($PORTS)" $APP $USR >> $PORT_DB
APP_PORT_LAST=`expr $APP_PORT_BASE + $PORTS - 1`
}
listModules() {
MODULES=""
for mod in `ls $APPIE_BASE/modules`; do
if [ -e "$APPIE_BASE/modules/$mod/main" ]; then
MODULES="$MODULES $mod"
fi
done
echo $MODULES
}
listCommands() {
MODULE=$1
COMMANDS=""
for cmd in `ls $APPIE_BASE/modules/$MODULE`; do
if [ -x "$APPIE_BASE/modules/$MODULE/$cmd" ]; then
COMMANDS="$COMMANDS $cmd"
fi
done
echo $COMMANDS
}