diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32689d7..ba61f5d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,13 +10,13 @@ jobs: - uses: actions/checkout@v2.3.4 - name: Prepare id: prepare - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Install dependencies run: | export DEBIAN_FRONTEND=noninteractive sudo add-apt-repository ppa:canonical-server/server-backports \ && sudo apt-get update \ - && sudo apt-get -y install qemu-utils qemu-system-x86 + && sudo apt-get -y install qemu-utils qemu-system-x86 p7zip-full wget make curl unzip - name: Install pinned iPXE roms run: wget -O/tmp/roms.zip "$IPXE_ROMS" && sudo unzip -o /tmp/roms.zip -d /usr/lib/ipxe/qemu - name: Build image @@ -43,3 +43,13 @@ jobs: asset_path: ./alpine.qcow2 asset_name: alpine.qcow2 asset_content_type: application/octet-stream + - name: Upload snapshot + id: upload_snapshot + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./snapshot.7z + asset_name: snapshot.7z + asset_content_type: application/octet-stream diff --git a/.gitignore b/.gitignore index b511ae1..efdd32c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.qcow2 +*.7z diff --git a/Makefile b/Makefile index ffca325..741553f 100644 --- a/Makefile +++ b/Makefile @@ -3,4 +3,4 @@ alpine.qcow2: setup.sh .PHONY: clean clean: - rm -f alpine.qcow2 + rm -f alpine.qcow2 snapshot.7z diff --git a/README.md b/README.md index 0971048..011325d 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,4 @@ In this file, we will go over the structure and organization of this repo, and g The sudo on that last command isn't needed if your user has the proper permissions. (e.g. is part of the kvm group) - To test your newly-built image, copy alpine.qcow2 from this directory to Server/alpine.qcow2 in an existing Flashpoint installation. Options can be adjusted in Data/services.json if needed. + To test your newly-built image, copy alpine.qcow2 and snapshot.7z from this directory to the Server/ folder in an existing Flashpoint installation. Options can be adjusted in Data/services.json if needed. diff --git a/snapshot.sh b/snapshot.sh index f352009..40bd5c2 100755 --- a/snapshot.sh +++ b/snapshot.sh @@ -9,5 +9,11 @@ while ! curl -sI 'http://127.0.0.1:22500/' >/dev/null; do done echo 'apache is ready .. snapshot in 10 seconds' && sleep 10 -echo 'savevm quick' | nc -q1 -w5 127.0.0.1 4445 >/dev/null -kill -TERM "$pid" +echo 'migrate "exec:7z a -si -mx=9 -mfb=64 snapshot.7z"' | nc -q1 -w5 127.0.0.1 4445 >/dev/null +while pgrep -c 7z >/dev/null; do + echo 'Compressing snapshot... sleeping for 10 seconds' && sleep 10 +done +# Give an extra 10s of wiggle room. +sleep 10 +echo 'quit' | nc -q1 -w5 127.0.0.1 4445 >/dev/null +sleep 5