diff options
author | sinanmohd <sinan@firemail.cc> | 2023-03-23 09:10:00 +0530 |
---|---|---|
committer | sinanmohd <sinan@firemail.cc> | 2023-03-23 09:24:22 +0530 |
commit | 9fecc3a6ee80c9ea2758947e72894b2ece54d894 (patch) | |
tree | 1f7e89c55c19a9ead8054d03a9aeaefc1a24682d /.local/bin | |
parent | fe5e56eb25c247deef07bb650c50bdc6cccc8687 (diff) |
fix : livevm: wrong path to create qcow2 img, get rid of die, dont cat to grep
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/livevm | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/.local/bin/livevm b/.local/bin/livevm index 638386b..79f7ed6 100755 --- a/.local/bin/livevm +++ b/.local/bin/livevm @@ -2,16 +2,15 @@ data_dir="${XDG_DATA_HOME:-${HOME}/.local/share}/vm" storage="${data_dir}/livevm.qcow2" - # allocate half of available memory and cores to vm -mem="$(($(cat /proc/meminfo | grep MemAvailable | grep -o '[0-9]*')/2))" +mem="$(($(grep MemAvailable /proc/meminfo | grep -o '[0-9]*')/2))" cores="$(($(nproc)/2))" cmd="qemu-system-x86_64 -boot menu=on -enable-kvm -device intel-hda -device hda-duplex -m ${mem}k -cpu host -smp $cores -drive file=$storage" [ ! -d "${data_dir}" ] && mkdir -p "${data_dir}" [ ! -f "$storage" ] && - qemu-img create -f qcow2 livevm.img 30G + qemu-img create -f qcow2 "$storage" 30G while getopts "wehc:d:" f do @@ -45,10 +44,11 @@ do -c [cdrom] -d [drive] EOF + exit ;; ?) - echo "usage: ${0##*/} [ -weh ] [ -c cdrom ] [ -d drive ]" + printf "%s\n" "usage: ${0##*/} [ -weh ] [ -c cdrom ] [ -d drive ]" 1>&2 exit 1 ;; esac |