#!/bin/bash

set -x

export LC_ALL=C

if [ -z "$1" ]; then
        echo "ERROR: Need a ISO file to work with."
        echo "Syntax: $0 huge_file.iso"
        exit 1
fi

if ! echo $1 | grep -q '\.iso$'; then
    echo "ERROR: Need a ISO file"
    exit 1
fi

filename=$(echo $1 | sed -e 's/\.iso$//g')

echo "Will split $1 into 2GB chunks..."
split --verbose -b 2G ${1} ${1}.

echo "Will construct a ${filename}.sha256sum file..."
sha256sum ${filename}*iso* > ${filename}.sha256sum