Compare commits

..

4 commits

View file

@ -1,5 +1,5 @@
#!/bin/bash
# version=0.2.0
# version=0.3.0
# Function to re-exec the script as another user via sudo (only if needed)
exec_as() {
@ -38,9 +38,9 @@ public_help() {
exec cat << EOF
${name}: usage:
${name} active - (default behaviour) list active VMs
${name} running - (default behaviour) list running VMs
${name} start <VM name> - start a VM
${name} watch <VM name> - attach VM screen session
${name} attach <VM name> - attach to the VM monitor socket
${name} ls - list available VMs
${name} edit <VM name> - edit VM launching script
${name} rm <VM name> - delete launch script
@ -76,7 +76,7 @@ public_start() {
# Attach to a running virtual machine output, the latest opened if no
# argument is provided
public_watch() {
public_attach() {
QEMUSH_NAME="$1"
shift
@ -84,7 +84,7 @@ public_watch() {
}
# List running virtual machines
public_active() {
public_running() {
cd || return
echo "Running machines:"
set -- $ls -t sockets "$@"
@ -140,7 +140,8 @@ public_rm() {
# Invoke bash as qemu user in its home directory
public_shell() {
cd || return
exec bash -i
set -- bash -i "$@"
exec "$@"
}
# Output the content of an entrypoint, with coloration if on a virtual
@ -182,7 +183,7 @@ shift
# Defauts to `active` if no function is supplied; else checks for a public
# function named after the argument; else fails
if [ -z "$function" ]; then
public_active
public_running
elif declare -F | cut -d \ -f 3- | grep '^public_' | sed 's/^public_//' | grep -q "^${function}$"; then
"public_${function}" "$@"
else