-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-delegate.sh
55 lines (48 loc) · 1.4 KB
/
run-delegate.sh
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
#!/bin/bash
TARGET=znews-ss
DEBUG=""
while getopts :d opt; do
case $opt in
d)
DEBUG="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=1044"
;;
esac
done
shift $((OPTIND-1))
if [[ "$#" == 1 ]]; then
TARGET=$1
else
echo "Warning: target not passed as a parameter, using $TARGET as default"
fi
# Check if rainbow.properties exists.
TARGET_DIR="targets/$TARGET"
if [ ! -d "$TARGET_DIR" ]; then
echo "Error: target directory $TARGET_DIR" does not exist.
exit 1
fi
RB_PROPS="$TARGET_DIR/rainbow.properties"
if [ ! -f "$RB_PROPS" ]; then
echo "Note: rainbow.properties file not found in $RB_PROPS."
echo "Note: searching for one in $TARGET_DIR"
FOUND=""
for F in `cd "$TARGET_DIR" && ls`; do
if [[ (-f "$TARGET_DIR/$F") && \
("$F" =~ ^rainbow-(.+)\.properties$) ]]; then
ADDRESS=${BASH_REMATCH[1]}
COUNT=$(/sbin/ifconfig | egrep "inet addr:$ADDRESS" | wc -l)
if [ "$COUNT" == "1" -a -n "$FOUND" ]; then
echo "Multiple candidates found for rainbow.properties."
exit 1
elif [ "$COUNT" == "1" ]; then
FOUND="$F"
fi
fi
done
if [ -z "$FOUND" ]; then
echo "Error: rainbow.properties file not found ($RB_PROPS)"
exit 1
fi
echo "Note: using $FOUND as rainbow.properties."
(cd "$TARGET_DIR" && ln -s "$FOUND" rainbow.properties)
fi
java -classpath ".:lib/*" -XX:+HeapDumpOnOutOfMemoryError $DEBUG -Drainbow.target=$TARGET org.sa.rainbow.core.RainbowDelegate