./priv/roles/Common.sh in stacco-0.1.36 vs ./priv/roles/Common.sh in stacco-0.1.37
- old
+ new
@@ -4,35 +4,23 @@
if [ "${exit_code}" -eq 0 ]; then
echo "Stacco cloud-init handler finished"
cfn-signal -s true "${AWS_INSTANCE_WAIT_HANDLE}"
else
+ sleep 1000
echo "Stacco cloud-init handler aborted (${exit_code}: ${_exit_handler_reason})"
cfn-signal -e "${exit_code}" -r "${_exit_handler_reason}" "${AWS_INSTANCE_WAIT_HANDLE}"
fi
exit "${exit_code}"
}
trap _exit_handler EXIT
-
-die(){
- _exit_handler_reason="$1"
- echo "error: $1" >&2
- exit 1
-}
-
set -e
-
-
export HOME=/root
cd "$HOME"
-echo "ensuring internet connectivity..."
-curl -sL -I -o /dev/null --fail --show-error --retry 100 'http://bex-status.s3.amazonaws.com/status.json'
-echo "found an internet connection."
-
echo "configuring hostname from aws metadata service"
host_title="${AWS_STACK_NAME}-$(echo "${AWS_INSTANCE_LOGICAL_NAME}" | sed 's/LaunchConfiguration$//')"
private_hostname=$(curl -sL http://169.254.169.254/latest/meta-data/local-hostname)
short_private_hostname=$(echo "${private_hostname}" | cut -d'.' -f 1)
echo "${host_title}" > /etc/hostname
@@ -41,47 +29,28 @@
cat >>/etc/hosts <<EOF
127.0.0.1 localhost
127.0.1.1 ${private_hostname} ${host_title} ${short_private_hostname}
EOF
-echo "enabling mirroring for security apt sources"
-sed -i "s/security\.ubuntu\.com/${AWS_REGION}.ec2.archive.ubuntu.com/g" /etc/apt/sources.list
-echo "disablng kernel and initramfs updates"
-echo $(dpkg -l "*$(uname -r)*" | grep image | awk '{print $2}') hold | dpkg --set-selections
-sed -i 's/=yes/=no/g' /etc/initramfs-tools/update-initramfs.conf
-
-echo "adding vendor apt sources"
-apt-key adv --keyserver 'hkp://pgp.mit.edu:80' --recv-keys 'C43C79AD'
-echo "deb http://rep.logentries.com/ trusty main" > /etc/apt/sources.list.d/logentries.list
-
-echo "installing packages"
-apt-get clean
-apt-get update
-apt-get upgrade -qy
-apt-get install -qy python-setuptools python-pip python-setproctitle htop tree btrfs-tools xz-utils logentries bundler ruby-nokogiri
-pip install -q awscli
-gem install -q --no-rdoc --no-ri aws-sdk docker-utils
-
if [ -n "$LOGENTRIES_ACCOUNT_KEY" ]; then
+ le clean
+ rm -f /etc/default/logentries_not_to_be_run
+
echo "starting remote logging"
host_key=$(docker-utils get-host-uuid "${AWS_INSTANCE_LOGICAL_NAME}.${AWS_STACK_NAME}")
+
le init --account-key="${LOGENTRIES_ACCOUNT_KEY}" --agent-key="${host_key}"
le register --force --name="${host_title}" --hostname="${private_hostname}"
- apt-get install -qy logentries-daemon 2>/dev/null || :
+ service logentries start
- logs_to_follow="syslog messages dmesg auth.log boot.log daemon.log dpkg.log kern.log cron secure faillog cloud-init-output.log"
- for log_name in ${logs_to_follow}; do
+ logs_to_follow=(syslog messages dmesg auth.log boot.log daemon.log dpkg.log kern.log cron secure faillog cloud-init-output.log)
+ for log_name in "${logs_to_follow[@]}"; do
log_path="/var/log/${log_name}"
if [ -f "${log_path}" ]; then
log_name=$(basename "${log_path}" '.log')
- le follow --name="${log_name}" "${log_path}" 2>/dev/null 1>&2
+ le follow --name="${log_name}" "${log_path}"
fi
done
service logentries restart
fi
-
-echo "installing aws cfn-tools"
-easy_install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
-cfn-init --region="${AWS_REGION}" --stack="${AWS_STACK_NAME}" --resource="${AWS_INSTANCE_LOGICAL_NAME}" || die 'Failed to run cfn-init'
-