Compare commits
7 commits
165ff284e2
...
21643ed7f8
Author | SHA1 | Date | |
---|---|---|---|
|
21643ed7f8 | ||
|
c09ea3ec38 | ||
|
48790fec0d | ||
|
9bdc1eef3d | ||
|
f24e2a6568 | ||
|
85e31307ec | ||
|
fd8cb0c2c6 |
1 changed files with 19 additions and 19 deletions
36
bin/qemush
36
bin/qemush
|
@ -1,18 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
exec_as() {
|
if [ "$(whoami)" != root ]; then
|
||||||
local user="$1"
|
exec sudo -u qemu "$0" "$@"
|
||||||
shift
|
|
||||||
|
|
||||||
if [ "$(whoami)" != "$user" ]; then
|
|
||||||
exec sudo -u "$user" "$0" "$@"
|
|
||||||
else
|
else
|
||||||
cd || return
|
cd || exit
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
exec_as qemu "$@" || exit
|
bin=bin
|
||||||
PATH="./bin:${PATH}"
|
images=images
|
||||||
|
|
||||||
|
PATH="./${bin}:${PATH}"
|
||||||
|
|
||||||
|
alias ls='ls --color=auto'
|
||||||
|
shopt -s expand_aliases
|
||||||
|
|
||||||
perror() {
|
perror() {
|
||||||
>&2 printf '\033[1;31mERROR:\033[0m \033[1m%s\033[0m\n' "$*"
|
>&2 printf '\033[1;31mERROR:\033[0m \033[1m%s\033[0m\n' "$*"
|
||||||
|
@ -26,7 +26,7 @@ ${name}: usage:
|
||||||
${name} active - (default behaviour) list active VMs
|
${name} active - (default behaviour) list active VMs
|
||||||
${name} start <VM name> - start a VM
|
${name} start <VM name> - start a VM
|
||||||
${name} watch <VM name> - attach VM screen session
|
${name} watch <VM name> - attach VM screen session
|
||||||
${name} list - list available VMs
|
${name} ls - list available VMs
|
||||||
${name} add <VM name> <template> - add launch script based on template
|
${name} add <VM name> <template> - add launch script based on template
|
||||||
${name} rm <VM name> - delete launch script
|
${name} rm <VM name> - delete launch script
|
||||||
${name} diskls - list available disk images
|
${name} diskls - list available disk images
|
||||||
|
@ -58,13 +58,13 @@ public_active() {
|
||||||
screen -ls
|
screen -ls
|
||||||
}
|
}
|
||||||
|
|
||||||
public_list() {
|
public_ls() {
|
||||||
echo "Available machines:"
|
echo "Available machines:"
|
||||||
ls --color=auto bin
|
ls "$bin"
|
||||||
}
|
}
|
||||||
|
|
||||||
diskpath() {
|
diskpath() {
|
||||||
printf 'images/%s.qcow2' "$1"
|
printf "%s.qcow2" "${images}/${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
public_diskadd() {
|
public_diskadd() {
|
||||||
|
@ -77,15 +77,15 @@ public_diskrm() {
|
||||||
|
|
||||||
public_diskls() {
|
public_diskls() {
|
||||||
echo "Available disks:"
|
echo "Available disks:"
|
||||||
ls --color=auto images
|
ls "$images"
|
||||||
}
|
}
|
||||||
|
|
||||||
public_add() {
|
public_edit() {
|
||||||
ln -vs "$2" "bin/${1}"
|
"$EDITOR" "${bin}/${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
public_rm() {
|
public_rm() {
|
||||||
unlink "bin/${1}"
|
rm -vi -- "${bin}/${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
public_shell() {
|
public_shell() {
|
||||||
|
|
Loading…
Reference in a new issue