diff options
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 |