diff options
author | Mark Longair <mhl@pobox.com> | 2012-09-26 14:48:08 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2012-09-26 14:52:50 +0100 |
commit | 312c3b14fd1683973baca6dcf6b4f95e888064ab (patch) | |
tree | ec1522139ee35e73a82a871dabb1e9551a1cdbf1 | |
parent | 4a9004283ce98a7c2fea615aa5968ea7ced921d4 (diff) |
Add a script to write the EC2 hostname into general.yml
This is useful when added to /etc/rc.local of our FixMyStreet
AMI, so that when a new EC2 instance is brought up, the
correct hostname is set in BASE_URL and EMAIL_DOMAIN.
-rwxr-xr-x | bin/ec2-rewrite-conf | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/ec2-rewrite-conf b/bin/ec2-rewrite-conf new file mode 100755 index 000000000..0163ef511 --- /dev/null +++ b/bin/ec2-rewrite-conf @@ -0,0 +1,20 @@ +#!/bin/sh + +# This is a helper script for writing the current EC2 hostname into +# the FixMyStreet configuration file. Its intended usage is for lines +# like these to be added to /etc/rc.local: +# +# su -l -c /home/fms/fixmystreet/bin/ec2-rewrite-conf fms +# /etc/init.d/apache2 restart + +set -e + +BIN_DIR=$(dirname $(readlink -f $0)) +CONF_DIR=$BIN_DIR/../conf + +HOST=`curl -s http://169.254.169.254/latest/meta-data/public-hostname` + +sed -i -r \ + -e "s,^( *BASE_URL:).*,\\1 'http://$HOST'," \ + -e "s,^( *EMAIL_DOMAIN:).*,\\1 '$HOST'," \ + $CONF_DIR/general.yml |