/
cascas
executable file
·61 lines (54 loc) · 2.08 KB
/
cascas
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
# Sets the CaSCAS Version
export CASCAS_VERSION=0.0.1
# Sets the environment to developer environment if not already set
if [ -z "${CASCAS_ENV}" ]; then
export CASCAS_ENV=develop
fi
# Sets the project directory if it isn't defined
if [ -z "${CASCAS_PROJECT_DIR}" ]; then
export CASCAS_PROJECT_DIR="."
fi
# Checks if cascas config directory exists and set appropriately
if [ "${CASCAS_ENV}" == "develop" ]; then
export CASCAS_CONFIG_DIR="${CASCAS_PROJECT_DIR}/config"
elif [ "${CASCAS_ENV}" == "release" ]; then
if [ -d "${HOME}/.CaSCAS" ]; then
export CASCAS_CONFIG_DIR="${HOME}/.cascas"
else
export CASCAS_CONFIG_DIR="/etc/cascas"
fi
else
export CASCAS_CONFIG_DIR="/etc/cascas"
fi
if [ ! -d "${CASCAS_CONFIG_DIR}" ]; then
mkdir "${CASCAS_CONFIG_DIR}"
fi
export CASCAS_CONFIG_INI="${CASCAS_CONFIG_DIR}/cascas.ini"
# Sets the logging directory where all log files will be saved if it isn't defined
if [ -z "${CASCAS_LOGGING_DIR}" ]; then
export CASCAS_LOGGING_DIR="${CASCAS_PROJECT_DIR}/log"
fi
if [ ! -d "${CASCAS_LOGGING_DIR}" ]; then
mkdir "${CASCAS_LOGGING_DIR}"
fi
# Sets the working directory where all working files will be saved if it isn't defined
if [ -z "${CASCAS_WORKING_DIR}" ]; then
export CASCAS_WORKING_DIR="${CASCAS_PROJECT_DIR}/working"
fi
if [ ! -d "${CASCAS_WORKING_DIR}" ]; then
mkdir "${CASCAS_WORKING_DIR}"
fi
# parameters to scala run
export CASCAS_JAR="${CASCAS_PROJECT_DIR}/target/CaSCAS-${CASCAS_VERSION}.jar"
export CASCAS_MAIN="org.cascas_project.cascas.App"
export CASCAS_LOGGING_FILE="${CASCAS_LOGGING_DIR}/cascas_"$(date +"%Y%m%d_%H%M%S")".log"
# Run CaSCAS
if [ "$CASCAS_ENV" == "develop" ]; then
echo "CaSCAS running with $CASCAS_ENV environment settings."
echo "Logging to file $CASCAS_LOGGING_FILE and to screen."
scala -classpath "${CASCAS_JAR}" ${CASCAS_MAIN} "$@" 2>&1 | tee "${CASCAS_LOGGING_FILE}"
else
echo "CaSCAS running with $CASCAS_ENV environment settings."
echo "Logging to file $CASCAS_LOGGING_FILE."
scala -classpath "${CASCAS_JAR}" ${CASCAS_MAIN} "$@" 2>"${CASCAS_LOGGING_FILE}"
fi