Compare commits

...

7 commits

Author SHA1 Message Date
Hippolyte Chauvin
21643ed7f8 qemush : alias pour ls 2023-11-29 14:42:47 +01:00
Hippolyte Chauvin
c09ea3ec38 qemush : suppression de la fonction exec_as 2023-11-29 14:41:10 +01:00
Hippolyte Chauvin
48790fec0d qemush : ajout de la variable images 2023-11-29 14:39:09 +01:00
Hippolyte Chauvin
9bdc1eef3d qemush : modification de la fonction rm 2023-11-29 14:36:57 +01:00
Hippolyte Chauvin
f24e2a6568 qemush : utilisation de la variable bin 2023-11-29 14:34:25 +01:00
Hippolyte Chauvin
85e31307ec qemush : fonction add -> edit, ouverture d'un editor à la place 2023-11-29 14:33:20 +01:00
Hippolyte Chauvin
fd8cb0c2c6 qemush : fonction list -> ls 2023-11-29 14:30:12 +01:00

View file

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