Compare commits

..

No commits in common. "21643ed7f86b2a448c09c214b7470f48f63674a3" and "165ff284e2d94cf822e87c0007a5b3ff3cdf05d7" have entirely different histories.

View file

@ -1,18 +1,18 @@
#!/bin/bash #!/bin/bash
if [ "$(whoami)" != root ]; then exec_as() {
exec sudo -u qemu "$0" "$@" local user="$1"
else shift
cd || exit
fi
bin=bin if [ "$(whoami)" != "$user" ]; then
images=images exec sudo -u "$user" "$0" "$@"
else
cd || return
fi
}
PATH="./${bin}:${PATH}" exec_as qemu "$@" || exit
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} ls - list available VMs ${name} list - 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_ls() { public_list() {
echo "Available machines:" echo "Available machines:"
ls "$bin" ls --color=auto bin
} }
diskpath() { diskpath() {
printf "%s.qcow2" "${images}/${1}" printf 'images/%s.qcow2' "$1"
} }
public_diskadd() { public_diskadd() {
@ -77,15 +77,15 @@ public_diskrm() {
public_diskls() { public_diskls() {
echo "Available disks:" echo "Available disks:"
ls "$images" ls --color=auto images
} }
public_edit() { public_add() {
"$EDITOR" "${bin}/${1}" ln -vs "$2" "bin/${1}"
} }
public_rm() { public_rm() {
rm -vi -- "${bin}/${1}" unlink "bin/${1}"
} }
public_shell() { public_shell() {