From ba3547d7709014979936ae5ac2dee5ed07265125 Mon Sep 17 00:00:00 2001 From: Ahurac Date: Mon, 22 Jan 2024 23:42:11 +0100 Subject: [PATCH] =?UTF-8?q?qemush=20:=20suppression=20variables=20qui=20co?= =?UTF-8?q?ntenaient=20les=20r=C3=A9pertoires=20des=20homedirs=20de=20qemu?= =?UTF-8?q?sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/qemush | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/bin/qemush b/bin/qemush index 75bd8f7..b9d2851 100755 --- a/bin/qemush +++ b/bin/qemush @@ -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