fixing minor error in spark post-install script

This change fixes an error with variable substitution in the 20-spark
post install script. The here document firstboot script is using a
substitution for the removal command that was instead substituting the
name of the element script.

This change also adds some minor improvements to reduce repeated code
and make the script more streamlined for future improvement.

Change-Id: I5164cd759fd36c9ad1f910b7801a69cef6873d75
Closes-Bug: 1468131
This commit is contained in:
Michael McCune 2015-06-23 17:23:02 -04:00
parent 14927bb99e
commit c596c81082

View File

@ -10,12 +10,16 @@ set -o pipefail
# Unfortunately the Ubuntu user does not exists when DIB is creating the image
# and we need to execute this code the first time the VM boots.
sed -i -e 's,^exit 0$,[ -f /opt/spark/firstboot.sh ] \&\& sh /opt/spark/firstboot.sh; exit 0,' /etc/rc.local
firstboot_script_name="/opt/spark/firstboot.sh"
cat >> /opt/spark/firstboot.sh <<EOF
sed -i -e "s,^exit 0$,[ -f $firstboot_script_name ] \&\& sh $firstboot_script_name; exit 0," /etc/rc.local
user_and_group_names="ubuntu:ubuntu"
cat >> $firstboot_script_name <<EOF
#!/bin/sh
chown -R ubuntu:ubuntu /opt/spark
chown -R ubuntu:ubuntu /etc/hadoop
rm $0
chown -R $user_and_group_names /opt/spark
chown -R $user_and_group_names /etc/hadoop
rm $firstboot_script_name
EOF