Compare commits

..

No commits in common. "0a2de050ddccd7ca109ba3c97df74aa0e40ac33f" and "d515a0bb232c9b04ad20a8d8b1b4ef5de60857f4" have entirely different histories.

View file

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