Compare commits
4 commits
d515a0bb23
...
0a2de050dd
Author | SHA1 | Date | |
---|---|---|---|
0a2de050dd | |||
d214fed810 | |||
7fbc153a2b | |||
12eeb64347 |
1 changed files with 8 additions and 7 deletions
15
bin/qemush
15
bin/qemush
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# version=0.2.0
|
# version=0.3.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} active - (default behaviour) list active VMs
|
${name} running - (default behaviour) list running VMs
|
||||||
${name} start <VM name> - start a VM
|
${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} 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_watch() {
|
public_attach() {
|
||||||
QEMUSH_NAME="$1"
|
QEMUSH_NAME="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public_watch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# List running virtual machines
|
# List running virtual machines
|
||||||
public_active() {
|
public_running() {
|
||||||
cd || return
|
cd || return
|
||||||
echo "Running machines:"
|
echo "Running machines:"
|
||||||
set -- $ls -t sockets "$@"
|
set -- $ls -t sockets "$@"
|
||||||
|
@ -140,7 +140,8 @@ 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
|
||||||
exec bash -i
|
set -- 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
|
||||||
|
@ -182,7 +183,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_active
|
public_running
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue