-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.sh
46 lines (38 loc) · 853 Bytes
/
common.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
#!/bin/sh
if [ "${0}" != "-bash" ]; then
SCRIPT_NAME=`basename $0`
fi
CORES_HOME=$HOME/cores
SOLR_URL=http://localhost:8983/solr
if [ -e $HOME/.nutch-config ]; then
. $HOME/.nutch-config
fi
initialize() {
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
check_crawldb $1 $2
check_nutch $1 $3
}
check_params() {
if [ "${1}" = "" ]; then
echo "You must provide the core name (ex: ${SCRIPT_NAME} core_name)"
exit 1
fi
}
check_crawldb() {
if [ ! -e "${2}" ]; then
echo "The core named ${1} doesn't exist (${2})"
exit 1
fi
}
check_nutch() {
if [ ! -e "${2}/bin/nutch" ]; then
echo "Nutch installation doesn't exist for core ${1}"
exit 1
fi
}
check_status() {
RET_CODE=$?
if [ $RET_CODE -ne 0 ]; then
exit $RET_CODE
fi
}