diff options
| author | Marc Vertes <mvertes@free.fr> | 2021-03-18 16:28:30 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2021-03-18 16:28:30 +0100 |
| commit | d86227be78743b71c713a7ce6267cfcea73f6582 (patch) | |
| tree | d9267b86bcf19f4657f265a88635c03eb3253d7d /bin/vm | |
| parent | 556754fb516ff84965a510d0205f3c1d6cf64505 (diff) | |
update
Diffstat (limited to 'bin/vm')
| -rwxr-xr-x | bin/vm | 29 |
1 files changed, 21 insertions, 8 deletions
@@ -1,12 +1,12 @@ #!/bin/sh -# vm is a tool to manage and operate virtual machines. +# vm is a command line tool to manage and operate virtual machines. vm_version='vm-0.1' # TODO: # - DONE: fetch, build and install vftool in .vm/vftool -# - setup a config file per VM +# - DONE: setup a config file per VM # - creation of hdd image # - script install from CDROM iso: # - setup system, including static IP address @@ -61,7 +61,7 @@ iso_url = https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-vi iso = $(notdir $(iso_url)) isoinfo ?= /opt/homebrew/bin/isoinfo -all: initrd vmlinux +all: initrd vmlinux config initrd: $(iso) $(isoinfo) isoinfo -i $(iso) -J -x /boot/initramfs-virt > $@ @@ -69,9 +69,11 @@ initrd: $(iso) $(isoinfo) vmlinux: $(iso) $(isoinfo) isoinfo -i $(iso) -J -x /boot/vmlinuz-virt | gunzip > $@ +config: $(iso) + @echo "iso=$(iso)" >config + $(iso): curl -LO $(iso_url) || { rm -f $@; false; } - ln -sf $(iso) iso $(isoinfo): brew install cdrtools @@ -79,7 +81,7 @@ $(isoinfo): init_alpine() { mkdir -p "$dir/alpine-iso" && cd "$dir/alpine-iso" || die 'init alpine failed' - [ -f 'Makefile' ] || echo "$alpine_makefile" > Makefile + [ -f 'Makefile' ] || printf "%s" "$alpine_makefile" > Makefile make -s all } @@ -129,10 +131,21 @@ start() { } start_vm() ( - trap 'rm -f vftool.pid' EXIT [ -f vftool.log ] && cat vftool.log >> vftool.log.old - "$dir/vftool" -k vmlinux -i initrd -c iso >vftool.log 2>&1 & sleep 1 - exec 1>>vftool.log 2>&1 + exec 1>vftool.log 2>&1 + . config || die "vm: could not source $PWD/config" + trap 'rm -f vftool.pid' EXIT + + "$dir/vftool" \ + -k vmlinux \ + -i initrd \ + ${iso+-c "$iso"} \ + ${hdd+-d "$hdd"} \ + ${cpu+-p "$cpu"} \ + ${ram+-m "$ram"} \ + ${arg+-m "$arg"} \ + >>vftool.log 2>&1 & sleep 1 + echo "$!" >vftool.pid screen -S "${PWD##*/}" -d -m "$(grep -om 1 '\/dev\/tty.*' vftool.log)" wait |
