boxes: Fix output logging

This commit is contained in:
Fabio Rehm 2014-03-09 20:20:37 -03:00
parent d0939622a5
commit 2c934d4ec4
5 changed files with 17 additions and 16 deletions

View file

@ -16,10 +16,10 @@ if [ -f ${WORKING_DIR}/rootfs.tar.gz ]; then
fi
log "Compressing container's rootfs"
pushd $(dirname ${ROOTFS}) &>${LOG}
pushd $(dirname ${ROOTFS}) &>>${LOG}
tar --numeric-owner --anchored --exclude=./rootfs/dev/log -czf \
${WORKING_DIR}/rootfs.tar.gz ./rootfs/*
popd &>${LOG}
popd &>>${LOG}
# Prepare package contents
log 'Preparing box package contents'

View file

@ -6,17 +6,17 @@ export ERROR_COLOR='\033[31;01m'
export WARN_COLOR='\033[33;01m'
log() {
echo " [${RELEASE}] ${1}" >${LOG}
echo " [${RELEASE}] ${1}" >>${LOG}
echo " [${RELEASE}] ${1}" >&2
}
warn() {
echo "==> [${RELEASE}] [WARN] ${1}" >${LOG}
echo "==> [${RELEASE}] [WARN] ${1}" >>${LOG}
echo -e "${WARN_COLOR}==> [${RELEASE}] ${1}${NO_COLOR}"
}
info() {
echo "==> [${RELEASE}] [INFO] ${1}" >${LOG}
echo "==> [${RELEASE}] [INFO] ${1}" >>${LOG}
echo -e "${OK_COLOR}==> [${RELEASE}] ${1}${NO_COLOR}"
}

View file

@ -1,28 +1,23 @@
#!/bin/bash
mkdir -p $(dirname $LOG)
rm -f ${LOG}
touch ${LOG}
chmod +rw ${LOG}
utils.lxc.attach() {
cmd="$@"
log "Running [${cmd}] inside '${CONTAINER}' container..."
(lxc-attach -n ${CONTAINER} -- $cmd) &> ${LOG}
(lxc-attach -n ${CONTAINER} -- $cmd) &>> ${LOG}
}
utils.lxc.start() {
lxc-start -d -n ${CONTAINER} &>${LOG} || true
lxc-start -d -n ${CONTAINER} &>>${LOG} || true
}
utils.lxc.stop() {
lxc-stop -n ${CONTAINER} &>${LOG} || true
lxc-stop -n ${CONTAINER} &>>${LOG} || true
}
utils.lxc.destroy() {
lxc-destroy -n ${CONTAINER} &>${LOG}
lxc-destroy -n ${CONTAINER} &>>${LOG}
}
utils.lxc.create() {
lxc-create -n ${CONTAINER} "$@" &>${LOG}
lxc-create -n ${CONTAINER} "$@" &>>${LOG}
}

View file

@ -52,7 +52,7 @@ if [ $PUPPET = 1 ]; then
warn "Puppet can't be installed on Ubuntu Trusty 14.04, skipping"
else
log "Installing Puppet"
wget http://apt.puppetlabs.com/puppetlabs-release-stable.deb -O "${ROOTFS}/tmp/puppetlabs-release-stable.deb" &>${LOG}
wget http://apt.puppetlabs.com/puppetlabs-release-stable.deb -O "${ROOTFS}/tmp/puppetlabs-release-stable.deb" &>>${LOG}
utils.lxc.attach dpkg -i "/tmp/puppetlabs-release-stable.deb"
utils.lxc.attach apt-get update
utils.lxc.attach apt-get install puppet -y --force-yes

View file

@ -18,6 +18,12 @@ export WORKING_DIR="/tmp/${CONTAINER}"
export NOW=$(date -u)
export LOG=$(readlink -f .)/log/${CONTAINER}.log
mkdir -p $(dirname $LOG)
echo '############################################' > ${LOG}
echo "# Beginning build at $(date)" >> ${LOG}
touch ${LOG}
chmod +rw ${LOG}
if [ -f ${PACKAGE} ]; then
warn "The box '${PACKAGE}' already exists, skipping..."
echo