@ -1,7 +1,7 @@
#!/bin/bash
export EC2_HOME="/usr/share/ec2/ec2-api-tools"
export JAVA_HOME="$(dirname $(dirname $(readlink /etc/alternatives/java)))"
export JAVA_HOME="$(dirname " $(dirname " $(readlink /etc/alternatives/java)" )" )"
export PATH="$PATH:${EC2_HOME}/bin"
export TZ="UTC"
@ -110,7 +110,7 @@ copy_ami() {
return 1
fi
local ami_id_copy="$(awk '/^IMAGE/ {print $2}' $logfile)"
local ami_id_copy="$(awk '/^IMAGE/ {print $2}' " $logfile" )"
if [ -z "$ami_id_copy" ] ; then
echo "Error retrieving AMI ID $ami_id for region ${target_region}:"
@ -172,7 +172,7 @@ remove_ami() {
CMDLINE_OPTS=ami-name:,base-ami:,copy-to-all-regions,elastic-ip:,help,instance-type:,keep-ami-snapshot,ngcp-release:,public,region:,remove-existing-ami,skip-reboot
_opt_temp=$(getopt --name $0 -o +bch --long $CMDLINE_OPTS -- "$@")
_opt_temp=$(getopt --name " $0" -o +bch --long $CMDLINE_OPTS -- "$@")
if [ $? -ne 0 ]; then
echo "Try '$0 --help' for more information." >& 2
exit 1
@ -256,8 +256,8 @@ fi
check4progs(){
local RC=''
for arg in $* ; do
which $arg >/dev/null 2>&1 || RC="$arg"
for arg in "$@" ; do
which " $arg" >/dev/null 2>&1 || RC="$arg"
done
if [ -n "$RC" ] ; then
echo "$RC not found/executable" >&2
@ -322,6 +322,13 @@ cat > "$USER_DATA_FILE" << EOF
wget -O /tmp/ngcp-installer.deb http://deb.sipwise.com/spce/ngcp-installer-${NGCP_RELEASE}.deb
dpkg -i /tmp/ngcp-installer.deb
if [ -d /run/systemd/system ] ; then
echo "Switching from systemd to sysvinit (pre-reboot)"
apt-get install --yes sysvinit-core
echo "Rebooting now to switch from systemd to sysvinit"
reboot
fi
# workaround for mr4.2.1
export HOME=/root/
@ -357,12 +364,12 @@ if [ -n "$ELASTIC_IP" ] ; then
ec2-associate-address --region "${AWS_REGION}" "${ELASTIC_IP}" -i "${INSTANCE_ID}"
fi
STATUS="$(ec2-describe-instances --region ${AWS_REGION} --filter instance-id=$INSTANCE_ID | awk '/INSTANCE/ {print $6}')"
STATUS="$(ec2-describe-instances --region ${AWS_REGION} --filter instance-id=" $INSTANCE_ID" | awk '/INSTANCE/ {print $6}')"
echo "Starting instance ID $INSTANCE_ID for ngcp version $NGCP_VERSION"
retry=120 # up to 10 minutes
while [ "$STATUS" != "running" ] && [ $retry -ne 0 ] ; do
STATUS="$(ec2-describe-instances --region ${AWS_REGION} --filter instance-id=$INSTANCE_ID | awk '/INSTANCE/ {print $6}')"
STATUS="$(ec2-describe-instances --region ${AWS_REGION} --filter instance-id=" $INSTANCE_ID" | awk '/INSTANCE/ {print $6}')"
retry=$((retry - 1))
echo "Instance ID $INSTANCE_ID not running yet, checking again in 5 seconds ($retry retries left)."
sleep 5
@ -373,7 +380,7 @@ if [ "$STATUS" != "running" ] ; then
bailout 1
fi
HOSTNAME="$(ec2-describe-instances --region ${AWS_REGION} --filter instance-id=$INSTANCE_ID | awk '/INSTANCE/ {print $4}')"
HOSTNAME="$(ec2-describe-instances --region ${AWS_REGION} --filter instance-id=" $INSTANCE_ID" | awk '/INSTANCE/ {print $4}')"
retry=360 # up to 30 minutes
FINISHED_NGCP_CE_INSTALLATION=false
@ -408,7 +415,7 @@ else
retry=120 # up to 10 minutes
STATUS=""
while [ "$STATUS" != "running" ] && [ $retry -ne 0 ] ; do
STATUS="$(ec2-describe-instances --region ${AWS_REGION} --filter instance-id=$INSTANCE_ID | awk '/^INSTANCE/ {print $6}')"
STATUS="$(ec2-describe-instances --region ${AWS_REGION} --filter instance-id=" $INSTANCE_ID" | awk '/^INSTANCE/ {print $6}')"
retry=$((retry - 1))
echo "Instance ID not yet running (status: ${STATUS}), checking again in 5 seconds ($retry retries left)."
sleep 5
@ -420,7 +427,7 @@ else
fi
# we probably have a new hostname after reboot
HOSTNAME="$(ec2-describe-instances --region ${AWS_REGION} --filter instance-id=$INSTANCE_ID | awk '/INSTANCE/ {print $4}')"
HOSTNAME="$(ec2-describe-instances --region ${AWS_REGION} --filter instance-id=" $INSTANCE_ID" | awk '/INSTANCE/ {print $4}')"
# now check for available ssh connection and nginx listening on port 1443
retry=120 # up to 10 minutes
@ -455,7 +462,7 @@ ec2-create-image --region "$AWS_REGION" \
--description "$AMI_DESCRIPTION" \
"$INSTANCE_ID" >"$LOGFILE_AMI"
AMI_ID="$(awk '/^IMAGE/ {print $2}' $LOGFILE_AMI)"
AMI_ID="$(awk '/^IMAGE/ {print $2}' " $LOGFILE_AMI" )"
retry=120 # up to 10 minutes
STATUS=""