39 lines
762 B
Bash
Executable File
39 lines
762 B
Bash
Executable File
#!/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
|