-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.sh
More file actions
executable file
·82 lines (73 loc) · 2.06 KB
/
Copy pathlib.sh
File metadata and controls
executable file
·82 lines (73 loc) · 2.06 KB
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
#!/bin/bash
#
# Copyright (C) 2014 Salzburg Research.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
BUILD_DIR='target'
MARMOTTA_URL='http://localhost:8080'
STANBOL_URL='http://localhost:8081'
PROXY_URL='http://localhost:8181'
CURL_OPTS="${CURL_OPTS:-"-sfS"}"
function init() {
set +x
export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512m"
mvn -q clean install -DskipTests
mkdir -p $BUILD_DIR
rm -f $BUILD_DIR/*.pid
rm -f $BUILD_DIR/*.log
}
function log() {
local c n
if [ "$1" == "-n" ]; then
n="-n"
shift
fi
case "$2" in
error) c="0;31" ;;
info) c="0;32" ;;
warn) c="1;35" ;;
debug) c="0;34" ;;
*) c="1;37" ;; #white
esac
echo $n -e "\e[0${c}m\033[1m${1}\e[00m"
}
url_encode() {
python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])" "$1"
}
config() {
local KEY DATA
KEY="$1"
shift
if [ $# -eq 0 ]; then
curl $CURL_OPTS -X GET "${MARMOTTA_URL}/config/data/$(url_encode "$KEY")"
else
DATA="$(printf ',"%s"' "$@")"
DATA="[${DATA:1}]"
curl $CURL_OPTS -X POST -H "Content-Type: application/json" -d "$DATA" "${MARMOTTA_URL}/config/data/$(url_encode "$KEY")" \
|| { err=$?; log "Setting config $KEY failed: ($err)" error && return $err; }
log "successfully set $KEY = $DATA" debug
fi
}
function exec() {
local CMD NAME DIR
CMD=$1
NAME=$2
DIR=$3
N=$(grep -o "/" <<< "$DIR" | wc -l)
BACK_DIR=`echo $(for i in $(seq 1 $N); do printf "../"; done)`
cd $DIR
echo $CMD
$CMD >$BACK_DIR$BUILD_DIR/$NAME.log 2>$BACK_PATH$BUILD_DIR/$NAME.log & echo $! > $BACK_DIR$BUILD_DIR/$NAME.pid
cd $BACK_DIR
}