#!/usr/bin/env bash # # Set up a fresh host. # Test login from another session before you exit! # set -Eeuo pipefail trap 'ec=$?; echo 1>&2 "INTERNAL ERROR: ec=$ec line=$LINENO cmd=$BASH_COMMAND"; exit $ec;' ERR gh='https://github.com' mkdir -p "$HOME/.home/" && cd "$HOME/.home/" git clone -or "$gh/dot-home/dot-home.git" \ || (cd dot-home/ && git pull --rebase) git clone -or "$gh/0cjs/dot-home-cjs1.git" cjs1 \ || (cd cjs1 && git pull --rebase) dot-home/bin/dot-home-setup # If successful so far, we can move old versions of pre-existing files # to ~/OLD/ if that's not already done. cd "$HOME" mkdir -p OLD/ [[ -e OLD/authorized_keys ]] || cp .ssh/authorized_keys OLD/ for old in .bashrc .profile .ssh/known_hosts; do backup="OLD/$(basename "$old")" [[ -e "$backup" ]] || mv "$old" "$backup" done ~/.local/bin/dot-home-setup echo '*** Activate with: source ~/.bashrc'