From cd4d4616dbf02c199b613fd8276cc16dda804c90 Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Sun, 16 May 2021 20:27:54 -0400 Subject: [PATCH] basic system imaging --- dotfiles-old/scripts/grammy/image.sh | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 dotfiles-old/scripts/grammy/image.sh diff --git a/dotfiles-old/scripts/grammy/image.sh b/dotfiles-old/scripts/grammy/image.sh new file mode 100755 index 0000000..a0db885 --- /dev/null +++ b/dotfiles-old/scripts/grammy/image.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +set -e + +argv0="$0" +argv1="$1" +argv2="$2" + +FILE_NAME="image.img.gz" +COMPACT="gzip -c" +EXTRACT="gzip -cd" + +usage() { + printf "Usage: $argv0 {save,deploy} [device] + +Examples: + $argv0 save /dev/sda1 # images installation at /dev/sda1 + $argv0 deploy /dev/sda # deploys saved image to /dev/sda + +In-program constants (edit this script to change them): + \$FILE_NAME - where to save/read the image + \$COMPACT - command to compact the image (such as \"gzip -c\" to + compress with gzip) + \$EXTRACT - command to extract the image (such as \"gzip -cd\" to + extract gzip)\n" + exit 1 +} + +[ -n "$argv2" ] || usage + +set -x + +case "$argv1" in +(save) $COMPACT <"$argv2" >"$FILE_NAME" ;; +(deploy) $EXTRACT <"$FILE_NAME" >"$argv2" ;; +esac + +exit 0