fatal() { echo >&2 "FATAL:" "$@"; exit 1; }
error() { echo >&2 "ERROR:" "$@"; }
warning() { echo >&2 "WARNING:" "$@"; }
[ -d .git ] || fatal "You should run this from the repo root"
cd lammps || fatal "Can't find lammps submodule. No action taken."
[ -f .git ] || fatal "Not 100% sure this is the lammps submodule. No action taken."
cp .git ../lammps.git || fatal "Failed to protect submodule .git. No action taken."
{
[ -d src/MAKE ] && rm -rf src lib &&
[ -f .git ] && git reset --hard &&
mv ../lammps.git .git &&
true
} || fatal "An unknown error occurred at a bad time! You'll just have to work this one out!"