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