summaryrefslogtreecommitdiff
path: root/scripts/install
diff options
context:
space:
mode:
authorhydrajump <wave@hydrajump.com>2014-04-28 21:34:50 +0200
committerhydrajump <wave@hydrajump.com>2014-04-28 21:34:50 +0200
commitb1c49eca75ad30d17596f3062f33542c4139817f (patch)
tree27867a539353c90b4b9cde385d14fb4805039047 /scripts/install
parentc02405850b592c99d00697b69115cd112b9592ee (diff)
downloadvyatta-cfg-system-b1c49eca75ad30d17596f3062f33542c4139817f.tar.gz
vyatta-cfg-system-b1c49eca75ad30d17596f3062f33542c4139817f.zip
Add support for installing a new image on the Amazon AMI
- Check if installing on AWS EC2 platform via instance metadata. - Configure GRUB correctly, so that boot messages are available via instance's console. - Add init.d script to fetch user's EC2 public key during boot.
Diffstat (limited to 'scripts/install')
-rwxr-xr-xscripts/install/install-image-existing57
1 files changed, 42 insertions, 15 deletions
diff --git a/scripts/install/install-image-existing b/scripts/install/install-image-existing
index 52d129f0..b172b6f6 100755
--- a/scripts/install/install-image-existing
+++ b/scripts/install/install-image-existing
@@ -36,6 +36,21 @@ get_grub_index () {
fi
}
+# Check if installing on AWS EC2 AMI
+is_amazon_ec2_ami () {
+ ami_id_url=http://169.254.169.254/latest/meta-data/ami-id
+
+ ami_id=$(/usr/bin/curl --silent "$ami_id_url")
+ if [ -n "$ami_id" ]; then
+ echo "Installing on VyOS AMI"
+
+ # Create a temporary file to provide conditional
+ # check for init.d config in
+ # /debian/vyatta-cfg-system.postinst.in L215
+ touch ${INST_ROOT}${VYATTA_CFG_DIR}/.aws
+ fi
+}
+
if [ `whoami` != 'root' ] ; then
failure_exit 'This script must be run with root privileges.'
fi
@@ -242,21 +257,33 @@ fi
DEF_GRUB=${INST_ROOT}${vyatta_sysconfdir}/grub/default-union-grub-entry
if [ -e "$DEF_GRUB" ]; then
echo "Setting up grub configuration..."
- new_index=$(get_grub_index)
-
- def_grub_vers=/tmp/def_grub.$$
- cp $DEF_GRUB $def_grub_vers
- sed -i "s/menuentry \"VyOS.*(/menuentry \"VyOS $NEWNAME (/" $def_grub_vers
- sed -i "s/menuentry \"Lost password change.*(/menuentry \"Lost password change $NEWNAME (/" $def_grub_vers
- sed -i "sX/boot/[A-Za-z0-9\.\-]*X/boot/${NEWNAME}Xg" $def_grub_vers
-
- old_grub_cfg=$BOOT_DIR/grub/grub.cfg
- new_grub_cfg=/tmp/grub.cfg.$$
- sed -n '/^menuentry/q;p' $old_grub_cfg >$new_grub_cfg
- cat $def_grub_vers >> $new_grub_cfg
- sed -n '/^menuentry/,${p}' $old_grub_cfg >>$new_grub_cfg
- sed -i "s/^set default=[0-9]\+$/set default=$new_index/" $new_grub_cfg
- mv $new_grub_cfg $old_grub_cfg
+
+ if is_amazon_ec2_ami; then
+ sed -i '/menuentry/ i\
+ menuentry '"VyOS AMI (HVM) $NEWNAME"' { \
+ linux /boot/'$NEWNAME'/vmlinuz boot=live quiet vyatta-union=/boot/'$NEWNAME' console=ttyS0 \
+ initrd /boot/'$NEWNAME'/initrd.img \
+ } \
+
+ ' $BOOT_DIR/grub/grub.cfg
+
+ else
+ new_index=$(get_grub_index)
+
+ def_grub_vers=/tmp/def_grub.$$
+ cp $DEF_GRUB $def_grub_vers
+ sed -i "s/menuentry \"VyOS.*(/menuentry \"VyOS $NEWNAME (/" $def_grub_vers
+ sed -i "s/menuentry \"Lost password change.*(/menuentry \"Lost password change $NEWNAME (/" $def_grub_vers
+ sed -i "sX/boot/[A-Za-z0-9\.\-]*X/boot/${NEWNAME}Xg" $def_grub_vers
+
+ old_grub_cfg=$BOOT_DIR/grub/grub.cfg
+ new_grub_cfg=/tmp/grub.cfg.$$
+ sed -n '/^menuentry/q;p' $old_grub_cfg >$new_grub_cfg
+ cat $def_grub_vers >> $new_grub_cfg
+ sed -n '/^menuentry/,${p}' $old_grub_cfg >>$new_grub_cfg
+ sed -i "s/^set default=[0-9]\+$/set default=$new_index/" $new_grub_cfg
+ mv $new_grub_cfg $old_grub_cfg
+ fi
# Update the default image symlink used by Xen
if [ -L $BOOT_DIR/%%default_image ]; then