vagrant-lxc-base-boxes/common/utils.sh

34 lines
624 B
Bash
Raw Normal View History

2014-03-25 03:26:19 +00:00
#!/bin/bash
utils.lxc.attach() {
cmd="$@"
log "Running [${cmd}] inside '${CONTAINER}' container..."
2018-04-15 21:01:03 +00:00
lxc-attach -n ${CONTAINER} -- $cmd
2014-03-25 03:26:19 +00:00
}
utils.lxc.pipetofile() {
2018-04-15 21:01:03 +00:00
lxc-attach -n ${CONTAINER} -- /bin/bash -c "tee $1 > /dev/null"
}
utils.lxc.runscript() {
log "Running $1 inside '${CONTAINER}'..."
cat $1 | utils.lxc.pipetofile /script.sh
utils.lxc.attach /bin/bash /script.sh
}
2014-03-25 03:26:19 +00:00
utils.lxc.start() {
2018-04-15 21:01:03 +00:00
lxc-start -d -n ${CONTAINER} || true
2014-03-25 03:26:19 +00:00
}
utils.lxc.stop() {
2018-04-15 21:01:03 +00:00
lxc-stop -n ${CONTAINER} || true
2014-03-25 03:26:19 +00:00
}
utils.lxc.destroy() {
2018-04-15 21:01:03 +00:00
lxc-destroy -n ${CONTAINER}
2014-03-25 03:26:19 +00:00
}
utils.lxc.create() {
2018-04-15 21:01:03 +00:00
lxc-create -n ${CONTAINER} "$@"
2014-03-25 03:26:19 +00:00
}