-
Notifications
You must be signed in to change notification settings - Fork 122
/
ora.sh
executable file
·139 lines (120 loc) · 4.66 KB
/
ora.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
function _mkAndCheckDir {
mkdir -p "$1"
if [ $? -ne 0 ]
then
echo "creating the directory \"$1\" failed - exit 12"
exit 12
fi
}
function _export {
exportpath="$1"
case "$2" in
'') gzip='n' ;;
'gzip') gzip='y' ;;
*) echo "expected 'gzip' as 2nd param or nothing. Got: $2. Exit 12"
exit 12 ;;
esac
if [ -e "$exportpath" ] && [ ! -z "$(ls -A $exportpath)" ]
then
echo "target directory \"$exportpath\" exists and is not empty - exit 12"
exit 12
fi
echo "creating the target directory \"$exportpath\""
_mkAndCheckDir "$exportpath"
exportpath=$(cd "$exportpath"; pwd)
serverVersion=$(java -cp OpenRobertaServer/target/resources/\* de.fhg.iais.roberta.main.Administration version)
echo "server version: ${serverVersion}"
echo "copying all jars"
_mkAndCheckDir "${exportpath}/lib"
cp OpenRobertaServer/target/resources/*.jar "$exportpath/lib"
echo 'copying the staticResources'
cp -r OpenRobertaServer/staticResources ${exportpath}/staticResources
case "$gzip" in
'n') echo 'staticResources are NOT gzip-ped. This increases load times when the internet connection is slow. Use for debug only.' ;;
'y') numberGzFiles=$(find ${exportpath}/staticResources -type f | egrep '\.gz$' | wc -l)
if [[ $numberGzFiles != 0 ]]
then
echo "\n$numberGzFiles gz-files found. This should NOT happen. Please CHECK staticResources in the Git repository\n"
fi
find ${exportpath}/staticResources -type f \
| grep -Ev '\.(png|gif|mp3|gz|jpg|jpeg|wav|ogg)$' \
| tr '\12' '\0' | tr '\a' '\0' \
| xargs -n1 -0 gzip -9 -k -v -f
;;
esac
echo 'script for starting the server is copied (.sh and .bat)'
cp admin.sh admin-help.txt admin.bat ${exportpath}
chmod ugo+rx admin.sh admin.bat
}
# ---------------------------------------- begin of the script ----------------------------------------------------
if [ ! -d OpenRobertaServer ]
then
echo 'please start this script from the root of the Git working tree - exit 12'
exit 12
fi
# the following settings fit for 'export' and 'start-from-git'
DB_PARENTDIR=./OpenRobertaServer/db-embedded
DB_NAME=openroberta-db
JAVA_LIB_DIR='OpenRobertaServer/target/resources' # created by mvn install ...
ADMIN_DIR='./admin'
CC_RESOURCE_DIR='../ora-cc-rsc'
QUIET='no'
XMX=''
RDBG=''
while true
do
case "$1" in
-dbParentdir) DB_PARENTDIR=$2
shift; shift ;;
-dbName) DB_NAME=$2
shift; shift ;;
-java-lib-dir) JAVA_LIB_DIR=$2
shift; shift ;;
-admin-dir) ADMIN_DIR=$2
shift; shift ;;
-oraccrsc) CC_RESOURCE_DIR=$2
shift; shift ;;
-Xmx*) XMX=$1
shift ;;
-rdbg) RDBG='-agentlib:jdwp=transport=dt_socket,server=y,address=0.0.0.0:2000,suspend=y'
shift ;;
-q) QUIET='yes'
shift ;;
*) break ;;
esac
done
DB_URI="jdbc:hsqldb:hsql://localhost/$DB_NAME"
ADMIN_CLASS='de.fhg.iais.roberta.main.Administration'
cmd="$1"
shift
case "$cmd" in
''|help|-h|-help|--help) cat ora-help.txt ;;
export) _export $* ;;
start-from-git) if [[ ! -d $DB_PARENTDIR ]]; then
echo "No database found. An empty database will be created."
java -cp ${JAVA_LIB_DIR}/\* de.fhg.iais.roberta.main.Administration create-empty-db jdbc:hsqldb:file:$DB_PARENTDIR/$DB_NAME
fi
java $RDBG -cp ${JAVA_LIB_DIR}/\* de.fhg.iais.roberta.main.ServerStarter \
-d database.mode=embedded \
-d database.parentdir=$DB_PARENTDIR \
-d database.name=$DB_NAME \
-d server.staticresources.dir=OpenRobertaServer/staticResources \
-d robot.crosscompiler.resourcebase="$CC_RESOURCE_DIR" \
$* ;;
check-xss) # unused
exit 12
databaseurl="jdbc:hsqldb:file:$DB_PARENTDIR/$DB_NAME"
java -cp ${JAVA_LIB_DIR}/\* "$ADMIN_CLASS" check-xss "$databaseurl" ;;
renameRobot) # unused
exit 12
databaseurl="jdbc:hsqldb:file:$DB_PARENTDIR/$DB_NAME"
java -cp ${JAVA_LIB_DIR}/\* "$ADMIN_CLASS" rename "$databaseurl" $2 $3;;
configurationCleanUp) #unused
exit 12
databaseurl="jdbc:hsqldb:file:$DB_PARENTDIR/$DB_NAME"
java -cp ${JAVA_LIB_DIR}/\* "$ADMIN_CLASS" configuration-clean-up "$databaseurl" ;;
*) echo "invalid command: $cmd - exit 1"
exit 1 ;;
esac
exit 0