qemush : suppression variables qui contenaient les répertoires des homedirs de qemush

This commit is contained in:
Ahurac 2024-01-22 23:42:11 +01:00
parent 8e5346a7f2
commit ba3547d770

View file

@ -15,13 +15,8 @@ exec_as() {
# Exec the script as qemu
exec_as qemu "$@"
# Directories used in the program
bin="${HOME}/launchers"
images="${HOME}/disks"
sockets="${HOME}/sockets"
# Environment
PATH="${bin}:${HOME}/bin:${PATH}"
PATH="${HOME}/launchers:${HOME}/bin:${PATH}"
EDITOR="${EDITOR:-nvim}"
export QEMUSH_NAME
@ -93,13 +88,13 @@ public_watch() {
# List running virtual machines
public_active() {
echo "Running machines:"
exec ls -t "$sockets"
exec ls -t sockets
}
# List available virtual machines entrypoints
public_ls() {
echo "Available machines:"
exec ls "$bin"
exec ls launchers
}
# Create a copy-on-write disk for a virtual machine
@ -121,19 +116,20 @@ public_diskrm() {
# List available disks
public_diskls() {
echo "Available disks:"
exec ls "$images"
exec ls disks
}
# Edit a virtual machine entrypoint with a text editor
public_edit() {
local file="${bin}/${1}"
local file="launchers/${1}"
"$EDITOR" "$file"
[ -f "$file" ] && exec chmod u+x "$file"
}
# Delete a virtual machine entrypoint
public_rm() {
exec rm -vi -- "${bin}/${1}"
exec rm -vi -- "launchers/${1}"
}
# Invoke bash as qemu user in its home directory
@ -154,9 +150,15 @@ public_add() {
set -e
local name
name="${2:-$(basename "$1")}"
cp -v -i -- "$1" "${bin}/${2}"
chmod 740 "${bin}/${name}"
if [ -n "$2" ]; then
name="$2"
else
name=$(basename "$1")
fi
name="${HOME}/launchers/${name}"
cp -vi -- "$1" "$name"
chmod 740 "$name"
set +e
trap - EXIT