Compare commits

..

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

View file

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