dot

packages and services management
Log | Files | Refs | README

commit 8294d46c22f0de2838a98482a70ef2b5d1abe51c
parent 725e2f5b2830a3f9b6ef652973c9aeb42747d89c
Author: Josuah Demangeon <mail@josuah.net>
Date:   Tue, 20 Feb 2018 03:28:25 +0100

qemu: more reliable pgrep instead of display-oriented ps

Diffstat:
Mbin/qemu | 33+++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/bin/qemu b/bin/qemu @@ -25,27 +25,24 @@ case "$1" in exec nohup qemu-system-x86_64 \ -m 500M \ - -device e1000,netdev=net0 \ - -netdev user,id=net0,hostfwd=tcp::$port-:22 \ - -display none \ + -device "e1000,netdev=net0" \ + -netdev "user,id=net0,hostfwd=tcp::$port-:22" \ + -display "none" \ "$HOME/var/qemu/$2" \ 1>> "$HOME/log/qemu/$2" & ;; +(list) + (pgrep -lf qemu-system- || pgrep -la qemu-system-) 2> /dev/null | + sed -rn 's/.*qemu-system-.*::([0-9]+).*[/]([^/]+)$/\1 \2/p' + ;; (*) - echo 'usage: qemu start <name.img>' 1>&2 - echo ' qemu new <ref.img> <new.img>' 1>&2 - - echo 'store:' 1>&2 - ls "$HOME/lib/qemu" | sed 's/^/ /' 1>&2 - - echo 'created:' 1>&2 - ls "$HOME/var/qemu" | sed 's/^/ /' 1>&2 - - echo 'running:' 1>&2 - { - ps -ax || ps - } 2> /dev/null | sed -rn ' - s/.*qemu-system-.*::([0-9]+).*[/](.+)$/ \1 \2/p - ' 1>&2 + echo "usage: qemu [start <name.img> | new <ref.img> <new.img> | list]" + echo "" + echo "store:" + ls "$HOME/lib/qemu" | sed 's/^/ /' + echo "created:" + ls "$HOME/var/qemu" | sed 's/^/ /' + echo "running:" + exec "$0" list | sed 's/^/ /' ;; esac