-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathzeppelin.sh
executable file
·144 lines (125 loc) · 4.53 KB
/
zeppelin.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
140
141
142
143
144
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
# Run Zeppelin
#
# pre-requisites for checking that we're running in container
if [ -f /proc/self/cgroup ] && [ -n "$(command -v getent)" ]; then
# checks if we're running in container...
if awk -F: '/cpu/ && $3 ~ /^\/$/{ c=1 } END { exit c }' /proc/self/cgroup; then
# Check whether there is a passwd entry for the container UID
myuid="$(id -u)"
mygid="$(id -g)"
# turn off -e for getent because it will return error code in anonymous uid case
set +e
uidentry="$(getent passwd "$myuid")"
set -e
# If there is no passwd entry for the container UID, attempt to create one
if [ -z "$uidentry" ] ; then
if [ -w /etc/passwd ] ; then
echo "zeppelin:x:$myuid:$mygid:anonymous uid:$ZEPPELIN_HOME:/bin/false" >> /etc/passwd
else
echo "Container ENTRYPOINT failed to add passwd entry for anonymous UID"
fi
fi
fi
fi
function usage() {
echo "Usage: bin/zeppelin.sh [--config <conf-dir>] [--run <noteId>]"
}
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--config)
export ZEPPELIN_CONF_DIR="$2"
shift # past argument
shift # past value
;;
--run)
export ZEPPELIN_NOTEBOOK_RUN_ID="$2"
shift # past argument
shift # past value
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unsupported argument."
usage
exit 1
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
bin="$(dirname "${BASH_SOURCE-$0}")"
bin="$(cd "${bin}">/dev/null; pwd)"
. "${bin}/common.sh"
check_java_version
if [ "$1" == "--version" ] || [ "$1" == "-v" ]; then
getZeppelinVersion
fi
HOSTNAME=$(hostname)
ZEPPELIN_LOGFILE="${ZEPPELIN_LOG_DIR}/zeppelin-${ZEPPELIN_IDENT_STRING}-${HOSTNAME}.log"
ZEPPELIN_SERVER=org.apache.zeppelin.server.ZeppelinServer
JAVA_OPTS+=" -Dzeppelin.log.file=${ZEPPELIN_LOGFILE}"
# construct classpath
if [[ -d "${ZEPPELIN_HOME}/zeppelin-interpreter/target/classes" ]]; then
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/zeppelin-interpreter/target/classes"
fi
if [[ -d "${ZEPPELIN_HOME}/zeppelin-zengine/target/classes" ]]; then
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/zeppelin-zengine/target/classes"
fi
if [[ -d "${ZEPPELIN_HOME}/zeppelin-server/target/classes" ]]; then
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/zeppelin-server/target/classes"
fi
addJarInDir "${ZEPPELIN_HOME}"
addJarInDir "${ZEPPELIN_HOME}/lib"
addJarInDir "${ZEPPELIN_HOME}/lib/interpreter"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-interpreter/target/lib"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-zengine/target/lib"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-server/target/lib"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-web/target/lib"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-web-angular/target/lib"
ZEPPELIN_CLASSPATH="$CLASSPATH:$ZEPPELIN_CLASSPATH"
## Add hadoop jars when env USE_HADOOP is true
if [[ "${USE_HADOOP}" != "false" ]]; then
if [[ -z "${HADOOP_CONF_DIR}" ]]; then
echo "Please specify HADOOP_CONF_DIR if USE_HADOOP is true"
else
ZEPPELIN_CLASSPATH+=":${HADOOP_CONF_DIR}"
if [ -n "${HADOOP_HOME}" ]; then
ZEPPELIN_CLASSPATH+=":`${HADOOP_HOME}/bin/hadoop classpath`"
elif ! [ -x "$(command -v hadoop)" ]; then
echo 'hadoop command is not in PATH when HADOOP_CONF_DIR is specified.'
else
ZEPPELIN_CLASSPATH+=":`hadoop classpath`"
fi
fi
fi
if [[ ! -d "${ZEPPELIN_LOG_DIR}" ]]; then
echo "Log dir doesn't exist, create ${ZEPPELIN_LOG_DIR}"
mkdir -p "${ZEPPELIN_LOG_DIR}"
fi
if [[ ! -d "${ZEPPELIN_PID_DIR}" ]]; then
echo "Pid dir doesn't exist, create ${ZEPPELIN_PID_DIR}"
mkdir -p "${ZEPPELIN_PID_DIR}"
fi
exec $ZEPPELIN_RUNNER $JAVA_OPTS -cp $ZEPPELIN_CLASSPATH_OVERRIDES:${ZEPPELIN_CLASSPATH} $ZEPPELIN_SERVER "$@"