forked from gvacaliuc/hadoop-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·43 lines (33 loc) · 1.26 KB
/
bootstrap.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
#!/bin/bash
# if the hadoop prefix isn't set, set it
: ${HADOOP_PREFIX:=/usr/local/hadoop}
. $HADOOP_PREFIX/etc/hadoop/hadoop-env.sh
if [[ $(find /tmp -maxdepth 1 -type f -path *.pid | wc -l) -gt 0 ]]; then
rm /tmp/*.pid
fi
# installing libraries if any - (resource urls added comma separated to the ACP system variable)
cd $HADOOP_PREFIX/share/hadoop/common ; for cp in ${ACP//,/ }; do echo == $cp; curl -LO $cp ; done; cd -
# since you can't fix the hostname of a container in docker,
# we end up having to set it when we launch the container...
sed s/HOSTNAME/$HOSTNAME/ \
$HADOOP_COMMON_HOME/etc/hadoop/core-site.xml.template > \
$HADOOP_COMMON_HOME/etc/hadoop/core-site.xml
sed s/HOSTNAME/$HOSTNAME/ \
$HADOOP_COMMON_HOME/etc/hadoop/slaves.template > \
$HADOOP_COMMON_HOME/etc/hadoop/slaves
# crudely start our ssh daemon
SSH_PORT=2122
/usr/sbin/sshd -p $SSH_PORT -D &
$HADOOP_PREFIX/sbin/start-dfs.sh
if ! $HADOOP_PREFIX/bin/hadoop fs -ls > /dev/null 2>&1 ; then
echo "Making /user/root/ on the hadoop filesystem..."
$HADOOP_PREFIX/bin/hadoop fs -mkdir -p /user/root
fi
# crude approximation for daemon
if [[ $1 == "-d" ]]; then
while true; do sleep 1000; done
fi
# give them some bash!
if [[ $1 == "-bash" ]]; then
/bin/bash
fi