forked from FRosner/docker-zeppelin
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstart-zeppelin.sh
More file actions
executable file
·106 lines (87 loc) · 3.75 KB
/
Copy pathstart-zeppelin.sh
File metadata and controls
executable file
·106 lines (87 loc) · 3.75 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
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
#!/bin/bash
#
# Initialise Zeppelin @ runtime.
# Note: Some vars are not enclosed in quotes (") because you get number format exceptions.
#
set -xe
sleep 20
id -u "$ZEPPELIN_PROCESS_USER_NAME" && echo 'id found' || echo 'id not found there is like to be a problem with LDAP'
getent group "$ZEPPELIN_PROCESS_GROUP_NAME" && echo 'group id found' || echo 'group id not found there is like to be a problem with LDAP'
date
cd /usr/local/zeppelin || exit
echo "Filling Zeppelin configuration templates"
function replace_env_config_if_not_exists {
local conf_name=$1
local envs_to_replace=$2
if [ ! -r conf/"$conf_name" ]; then
echo "$conf_name does not exist, creating it"
envsubst $envs_to_replace < conf.templates/"$conf_name".template > conf/"$conf_name"
else
echo "$conf_name already exists, not overwriting"
fi
}
function replace_env_config {
local conf_name=$1
local envs_to_replace=$2
echo "creating $conf_name"
envsubst $envs_to_replace < conf.templates/"$conf_name".template > conf/"$conf_name"
}
replace_env_config_if_not_exists interpreter.json
replace_env_config zeppelin-env.sh
replace_env_config zeppelin-site.xml
replace_env_config interpreter-list
replace_env_config log4j.properties
replace_env_config hive-site.xml
# Allow for multi-user or single-user setup
if [ -z "$ZEPPELIN_USER_TYPE" ]; then
echo "Environment variable ZEPPELIN_USER_TYPE required, but not set, exiting ..."
exit
else
if [ "multiuser" == "$ZEPPELIN_USER_TYPE" ]; then
echo "creating shiro.ini (multi-user)"
cat conf.templates/shiro.ini.remoteuserauth.template > conf/shiro.ini
else
echo "creating shiro.ini (single-user)"
replace_env_config shiro.ini '$ZEPPELIN_PASSWORD'
fi
fi
date
if [ -z "$ZEPPELIN_PROCESS_GROUP_NAME" ]; then
echo "Environment variable ZEPPELIN_PROCESS_GROUP_NAME required, but not set, exiting ..."
exit 1
elif [ -z "$ZEPPELIN_PROCESS_GROUP_ID" ]; then
echo "Environment variable ZEPPELIN_PROCESS_GROUP_ID required, but not set, exiting ..."
exit 1
elif getent group "$ZEPPELIN_PROCESS_GROUP_NAME"; then
echo "Group $ZEPPELIN_PROCESS_GROUP_NAME already exists"
else
echo "Group $ZEPPELIN_PROCESS_GROUP_NAME could not be found trhough SSSD"
exit 1
# else
# echo "Group $ZEPPELIN_PROCESS_GROUP_NAME does not exist, creating it with gid=$ZEPPELIN_PROCESS_GROUP_ID"
# addgroup --force-badname -gid $ZEPPELIN_PROCESS_GROUP_ID "$ZEPPELIN_PROCESS_GROUP_NAME"
fi
if [ -z "$ZEPPELIN_PROCESS_USER_NAME" ]; then
echo "Environment variable ZEPPELIN_PROCESS_USER_NAME required, but not set, exiting ..."
exit 1
elif [ -z "$ZEPPELIN_PROCESS_USER_ID" ]; then
echo "Environment variable ZEPPELIN_PROCESS_USER_ID required, but not set, exiting ..."
exit 1
elif id -u "$ZEPPELIN_PROCESS_USER_NAME" 2>/dev/null; then
echo "User $ZEPPELIN_PROCESS_USER_NAME already exists"
else
echo "Group $ZEPPELIN_PROCESS_USER_NAME could not be found trhough SSSD"
exit 1
# else
# echo "User $ZEPPELIN_PROCESS_USER_NAME does not exist, creating it with uid=$ZEPPELIN_PROCESS_USER_ID"
# adduser --force-badname "$ZEPPELIN_PROCESS_USER_NAME" --uid $ZEPPELIN_PROCESS_USER_ID --gecos "" --ingroup "$ZEPPELIN_PROCESS_GROUP_NAME" --disabled-login --disabled-password
fi
mkdir -p /home/"$ZEPPELIN_PROCESS_USER_NAME" || echo 'Problem creating user home folder' && echo 'User folder has been created'
chown -R "$ZEPPELIN_PROCESS_USER_NAME" ../zeppelin
chgrp -R "$ZEPPELIN_PROCESS_GROUP_NAME" ../zeppelin
chown -R "$ZEPPELIN_PROCESS_USER_NAME" /hive
chgrp -R "$ZEPPELIN_PROCESS_GROUP_NAME" /hive
chown -R "$ZEPPELIN_PROCESS_USER_NAME" /home/"$ZEPPELIN_PROCESS_USER_NAME"
chgrp -R "$ZEPPELIN_PROCESS_GROUP_NAME" /home/"$ZEPPELIN_PROCESS_USER_NAME"
date
exec sudo -u "$ZEPPELIN_PROCESS_USER_NAME" -g "$ZEPPELIN_PROCESS_GROUP_NAME" -E -H env "PATH=$PATH" bin/zeppelin.sh