./priv/roles/Common.sh in stacco-0.1.68 vs ./priv/roles/Common.sh in stacco-0.1.70

- old
+ new

@@ -1,18 +1,26 @@ -die(){ - echo "error: $1" >&2 - exit 1 +step() { + _CFINIT_STEP="$1"; shift + echo -e "==> step: \033[33m${_CFINIT_STEP}\033[0m" >&2 } +step_done() { + echo -e "--> \033[32m${_CFINIT_STEP}\033[0m: ok" >&2 +} set -e +die(){ + echo "--> \033[31merror during ${_CFINIT_STEP}\033[0m: $1" >&2 + exit 1 +} + export HOME=/root cd "$HOME" stop rsyslog -echo "configuring hostname from cloudformation and aws metadata service" +step "configuring hostname from cloudformation and aws metadata service" configured_hostname="${CFN_INSTANCE_HOSTNAME}" configured_hostname_short=$(echo "${configured_hostname}" | cut -d'.' -f 1) private_hostname=$(curl -sL http://169.254.169.254/latest/meta-data/local-hostname) private_hostname_short=$(echo "${private_hostname}" | cut -d'.' -f 1) private_ipv4=$(curl -fsL http://169.254.169.254/latest/meta-data/local-ipv4) @@ -32,11 +40,15 @@ if [ -n "${public_hostname}" ]; then cat >>/etc/hosts <<EOF 127.0.2.1 ${public_hostname} ${public_hostname_short} EOF fi +step_done + +step "setting up remote logging" + rm -f /etc/rsyslog.d/21-cloudinit.conf cat >/etc/rsyslog.d/91-receive-container-logs.conf <<EOF module(load="imfile") module(load="imtcp" MaxSessions="500") @@ -61,23 +73,27 @@ chown -R root:syslog /var/log/upstart start rsyslog +step_done + provision_volume() { device="$1"; shift mntpt="$1"; shift + step "provisioning btrfs on ${mntpt} using ${device}" mkfs.btrfs "${device}" 2>/dev/null || : mount "${device}" /mnt 2>/dev/null || : btrfs filesystem resize max /mnt 2>/dev/null || : umount /mnt 2>/dev/null || : mkdir -p "${mntpt}" mount -t btrfs -o "rw,noatime,space_cache" "${device}" "${mntpt}" + step_done } if [ -b "/dev/xvdc" ]; then provision_volume "/dev/xvdc" "/var/lib/docker" fi @@ -85,20 +101,22 @@ if [ -b "/dev/xvdd" ]; then provision_volume "/dev/xvdd" "/var/lib/docker/vfs/dir" fi if ! hash docker; then - echo "installing docker..." + step "installing docker..." echo 'deb http://get.docker.io/ubuntu docker main' > /etc/apt/sources.list.d/docker.list apt-key adv --keyserver 'hkp://pgp.mit.edu:80' --recv-keys '36A1D7869245C8950F966E92D8576A8BA88D21E9' apt-get update apt-get install -qy lxc-docker gpasswd -a ubuntu docker + step_done fi -echo "logging into ${DOCKER_REGISTRY_URL}..." +step "logging into ${DOCKER_REGISTRY_URL}" cat >"$HOME/.dockercfg" <<EOF {"${DOCKER_REGISTRY_URL}": { "auth": "${DOCKER_REGISTRY_AUTH}", "email": "${DOCKER_REGISTRY_EMAIL}" }} EOF +step_done