2014-03-25 03:26:19 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
utils.lxc.attach() {
|
|
|
|
cmd="$@"
|
|
|
|
log "Running [${cmd}] inside '${CONTAINER}' container..."
|
2015-12-15 16:35:25 +00:00
|
|
|
(lxc-attach -n ${CONTAINER} -- $cmd) &>> ${LOG}
|
2014-03-25 03:26:19 +00:00
|
|
|
}
|
|
|
|
|
2018-04-15 03:30:48 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2014-03-25 03:26:19 +00:00
|
|
|
utils.lxc.start() {
|
2015-12-15 16:35:25 +00:00
|
|
|
lxc-start -d -n ${CONTAINER} &>> ${LOG} || true
|
2014-03-25 03:26:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
utils.lxc.stop() {
|
2015-12-15 16:35:25 +00:00
|
|
|
lxc-stop -n ${CONTAINER} &>> ${LOG} || true
|
2014-03-25 03:26:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
utils.lxc.destroy() {
|
2015-12-15 16:35:25 +00:00
|
|
|
lxc-destroy -n ${CONTAINER} &>> ${LOG}
|
2014-03-25 03:26:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
utils.lxc.create() {
|
2015-12-15 16:35:25 +00:00
|
|
|
lxc-create -n ${CONTAINER} "$@" &>> ${LOG}
|
2014-03-25 03:26:19 +00:00
|
|
|
}
|