vagrant-lxc-base-boxes/common/utils.sh
Virgil Dupras bc8b070565 Unprivileged box creation: first step
I've been hacking my way through building vagrant boxes in unprivileged
containers. It works. Barely but it works. I can end up with a
functional vagrant box with `make stretch`.

The only place where I need `sudo` is when we tar up the root fs because
it doesn't belong to the same UID.
2018-04-14 23:30:48 -04:00

34 lines
710 B
Bash

#!/bin/bash
utils.lxc.attach() {
cmd="$@"
log "Running [${cmd}] inside '${CONTAINER}' container..."
(lxc-attach -n ${CONTAINER} -- $cmd) &>> ${LOG}
}
utils.lxc.pipetofile() {
log "Sending piped content inside '${CONTAINER}' at $1 ..."
lxc-attach -n ${CONTAINER} -- /bin/bash -c "tee $1 > /dev/null" &>> ${LOG}
}
utils.lxc.runscript() {
cat $1 | utils.lxc.pipetofile /script.sh
utils.lxc.attach /bin/bash /script.sh
}
utils.lxc.start() {
lxc-start -d -n ${CONTAINER} &>> ${LOG} || true
}
utils.lxc.stop() {
lxc-stop -n ${CONTAINER} &>> ${LOG} || true
}
utils.lxc.destroy() {
lxc-destroy -n ${CONTAINER} &>> ${LOG}
}
utils.lxc.create() {
lxc-create -n ${CONTAINER} "$@" &>> ${LOG}
}