-
Notifications
You must be signed in to change notification settings - Fork 78
/
sdc-configure.sh
executable file
·101 lines (83 loc) · 3.77 KB
/
sdc-configure.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
#!/usr/bin/env bash
#
# Copyright contributors to the StreamSets project
# StreamSets Inc., an IBM Company 2024
#
# 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.
#
set -e
set -x
# Check if SDC dist already exists, if not create its artifact of things.
if [ ! -d "${SDC_DIST}" ]; then
# Download and extract SDC.
for f in /tmp/*.tgz; do
[ -e "$f" ] && mv "$f" /tmp/sdc.tgz || curl -o /tmp/sdc.tgz -L "${SDC_URL}"
break
done
mkdir "${SDC_DIST}"
tar xzf /tmp/sdc.tgz --strip-components 1 -C "${SDC_DIST}"
rm -rf /tmp/sdc.tgz
# Move configuration to /etc/sdc
mv "${SDC_DIST}/etc" "${SDC_CONF}"
fi;
# SDC-11575 -- support for arbitrary userIds as per OpenShift
# We use Apache Hadoop code in file system related stagelibs to lookup the
# current user name, which fails when run in OpenShift.
# It fails because containers in OpenShift run as an ephemeral uid for
# security purposes, and that uid does not show up in /etc/passwd.
groupadd --system --gid ${SDC_GID} ${SDC_USER} && \
adduser --system --uid ${SDC_UID} --gid ${SDC_GID} ${SDC_USER}
usermod -aG root ${SDC_USER} && \
chgrp -R 0 "${SDC_DIST}" "${SDC_CONF}" && \
chmod -R g=u "${SDC_DIST}" "${SDC_CONF}" && \
# setgid bit on conf dir to preserve group on sed -i
chmod g+s "${SDC_CONF}" && \
chmod g=u /etc/passwd
# Update /etc/sudoers to include SDC user.
echo "${SDC_USER} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Add logging to stdout to make logs visible through `docker logs`.
if [ -f "${SDC_CONF}/sdc-log4j.properties" ]; then
sed -i 's|INFO, streamsets|INFO, streamsets,stdout|' "${SDC_CONF}/sdc-log4j.properties"
elif [ -f "${SDC_CONF}/sdc-log4j2.properties" ]; then
sed -i 's|rootLogger.appenderRef.streamsets.ref = streamsets|rootLogger.appenderRef.streamsets.ref = streamsets\nrootLogger.appenderRef.stdout.ref = stdout|' "${SDC_CONF}/sdc-log4j2.properties"
fi
# Workaround to address SDC-8005.
if [ -d "${SDC_DIST}/user-libs" ]; then
cp -R "${SDC_DIST}/user-libs" "${USER_LIBRARIES_DIR}"
fi
# Create necessary directories.
mkdir -p /mnt \
"${SDC_DATA}" \
"${SDC_LOG}" \
"${SDC_RESOURCES}" \
"${USER_LIBRARIES_DIR}"
chgrp -R 0 "${SDC_RESOURCES}" "${USER_LIBRARIES_DIR}" "${SDC_LOG}" "${SDC_DATA}" && \
chmod -R g=u "${SDC_RESOURCES}" "${USER_LIBRARIES_DIR}" "${SDC_LOG}" "${SDC_DATA}"
# Update sdc-security.policy to include the custom stage library directory.
cat >> "${SDC_CONF}/sdc-security.policy" << EOF
// custom stage library directory
grant codebase "file:///opt/streamsets-datacollector-user-libs/-" {
permission java.security.AllPermission;
};
EOF
# Use short option -s as long option --status is not supported on alpine linux.
sed -i 's|--status|-s|' "${SDC_DIST}/libexec/_stagelibs"
# Set distribution channel variable
sed -i '/^export SDC_DISTRIBUTION_CHANNEL=*/d' "${SDC_DIST}/libexec/sdcd-env.sh"
sed -i '/^export SDC_DISTRIBUTION_CHANNEL=*/d' "${SDC_DIST}/libexec/sdc-env.sh"
echo -e "\nexport SDC_DISTRIBUTION_CHANNEL=docker" >> ${SDC_DIST}/libexec/sdc-env.sh
echo -e "\nexport SDC_DISTRIBUTION_CHANNEL=docker" >> ${SDC_DIST}/libexec/sdcd-env.sh
# Needed for OpenShift deployment
sed -i 's/http.realm.file.permission.check=true/http.realm.file.permission.check=false/' ${SDC_CONF}/sdc.properties
# Create VERSION file
echo "${SDC_VERSION}" > "${SDC_DIST}/VERSION"