Merge "Firstboot script modifications"
This commit is contained in:
commit
bddbcb01d5
|
@ -1,34 +0,0 @@
|
|||
#!/bin/bash
|
||||
distro=$(lsb_release -is || :)
|
||||
case "$distro" in
|
||||
Ubuntu )
|
||||
mkdir /run/hadoop
|
||||
chown hadoop:hadoop /run/hadoop/
|
||||
mkdir -p /home/ubuntu/.ssh
|
||||
touch /home/ubuntu/.ssh/authorized_keys
|
||||
chown -R ubuntu:ubuntu /home/ubuntu
|
||||
;;
|
||||
Fedora )
|
||||
sleep 20
|
||||
rm /etc/resolv.conf
|
||||
service network restart
|
||||
if [ $(lsb_release -rs) = '19' ]; then
|
||||
chown -R fedora:fedora /etc/hadoop
|
||||
chown -R fedora:fedora /home/fedora
|
||||
else
|
||||
chown -R ec2-user:ec2-user /home/ec2-user
|
||||
chown -R ec2-user:ec2-user /etc/hadoop
|
||||
fi
|
||||
#TODO: configure iptables (https://bugs.launchpad.net/savanna/+bug/1195744)
|
||||
iptables -F
|
||||
;;
|
||||
* )
|
||||
echo "Unknown distro: $distro. Exiting."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Common
|
||||
chown root:root /mnt
|
||||
mkdir -p /var/run/hadoop ; chown hadoop:hadoop /var/run/hadoop
|
||||
mkdir -p /mnt/log/hadoop ; chown hadoop:hadoop /mnt/log/hadoop
|
|
@ -89,7 +89,18 @@ sed -i -e "s,export JAVA_HOME=.*,export JAVA_HOME=$JAVA_HOME," \
|
|||
-e "s,export HADOOP_SECURE_DN_LOG_DIR=.*,export HADOOP_SECURE_DN_LOG_DIR=/mnt/log/hadoop/hdfs," \
|
||||
/etc/hadoop/hadoop-env.sh
|
||||
|
||||
if [ "$distro" == "CentOS" ]; then
|
||||
install -D -g root -o root -m 0755 $(dirname $0)/firstboot /etc/first-boot.d/firstboot
|
||||
ln -s /etc/first-boot.d/firstboot /etc/rc3.d/S56firstboot
|
||||
echo "Applying firstboot script"
|
||||
|
||||
if [ "$distro" == "Ubuntu" ]; then
|
||||
# File '/etc/rc.local' may not exist
|
||||
if [ -f "/etc/rc.local" ]; then
|
||||
mv /etc/rc.local /etc/rc.local.old
|
||||
fi
|
||||
install -D -g root -o root -m 0755 $(dirname $0)/firstboot /etc/rc.local
|
||||
else
|
||||
# File '/etc/rc.d/rc.local' may not exist
|
||||
if [ -f "/etc/rc.d/rc.local" ]; then
|
||||
mv /etc/rc.d/rc.local /etc/rc.d/rc.local.old
|
||||
fi
|
||||
install -D -g root -o root -m 0755 $(dirname $0)/firstboot /etc/rc.d/rc.local
|
||||
fi
|
||||
|
|
|
@ -1,13 +1,60 @@
|
|||
#!/bin/bash
|
||||
|
||||
chown -R cloud-user:cloud-user /etc/hadoop
|
||||
chown -R cloud-user:cloud-user /home/cloud-user
|
||||
service iptables stop
|
||||
chkconfig iptables off
|
||||
distro=$(lsb_release -is || :)
|
||||
case "$distro" in
|
||||
Ubuntu )
|
||||
mkdir /run/hadoop
|
||||
chown hadoop:hadoop /run/hadoop/
|
||||
mkdir -p /home/ubuntu/.ssh
|
||||
touch /home/ubuntu/.ssh/authorized_keys
|
||||
chown -R ubuntu:ubuntu /home/ubuntu
|
||||
chown -R ubuntu:ubuntu /etc/hadoop
|
||||
;;
|
||||
Fedora )
|
||||
sleep 20
|
||||
rm /etc/resolv.conf
|
||||
service network restart
|
||||
if [ $(lsb_release -rs) = '19' ]; then
|
||||
user=fedora
|
||||
else
|
||||
user=ec2-user
|
||||
fi
|
||||
until [[ -n $(grep "$user:" /etc/passwd) && -n $(cat /etc/group | grep "$user:") ]];
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
chown -R $user:$user /etc/hadoop
|
||||
chown -R $user:$user /home/$user
|
||||
|
||||
#TODO: configure iptables (https://bugs.launchpad.net/savanna/+bug/1195744)
|
||||
iptables -F
|
||||
;;
|
||||
CentOS )
|
||||
chown -R cloud-user:cloud-user /etc/hadoop
|
||||
chown -R cloud-user:cloud-user /home/cloud-user
|
||||
service iptables stop
|
||||
chkconfig iptables off
|
||||
;;
|
||||
* )
|
||||
echo "Unknown distro: $distro. Exiting."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Common
|
||||
chown root:root /mnt
|
||||
mkdir -p /var/run/hadoop ; chown hadoop:hadoop /var/run/hadoop
|
||||
mkdir -p /mnt/log/hadoop ; chown hadoop:hadoop /mnt/log/hadoop
|
||||
|
||||
rm -f /etc/rc3.d/S56firstboot
|
||||
rm -f $0
|
||||
# Clean
|
||||
if [ "$distro" == "Ubuntu" ]; then
|
||||
if [ -f /etc/rc.local.old ]; then
|
||||
mv /etc/rc.local.old /etc/rc.local
|
||||
fi
|
||||
else
|
||||
if [ -f /etc/rc.d/rc.local.old ]; then
|
||||
mv /etc/rc.d/rc.local.old /etc/rc.d/rc.local
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue