#!/usr/bin/env bash # Bootstrap this machine. Picks the host layer by hostname; refuses rather than # guessing if there isn't one, because a silent fallback to "base only" looks # like success and leaves half the machine unconfigured. set -euo pipefail BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DOTBOT_DIR="dotbot" DOTBOT_BIN="bin/dotbot" HOST="${DOTFILES_HOST:-$(hostname | tr '[:upper:]' '[:lower:]')}" HOSTCONF="meta/hosts/${HOST}.conf.yaml" cd "${BASEDIR}" if [[ ! -f "${HOSTCONF}" ]]; then echo "install: no host config for '${HOST}'." >&2 echo " expected ${HOSTCONF}" >&2 echo " known hosts: $(ls meta/hosts/ | sed 's/\.conf\.yaml//' | tr '\n' ' ')" >&2 echo " for a new machine, copy the closest one and edit." >&2 exit 1 fi git submodule update --init --recursive "${DOTBOT_DIR}" echo "==> base" "${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c meta/base.conf.yaml "${@}" echo "==> host: ${HOST}" "${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${HOSTCONF}" "${@}" if [[ ! -r "${HOME}/.secrets.zsh" ]]; then echo echo "note: ~/.secrets.zsh does not exist yet." echo " cp common/zsh/secrets.zsh.example ~/.secrets.zsh && chmod 600 ~/.secrets.zsh" fi if [[ -d "hosts/${HOST}/sbin" ]] && [[ -n "$(ls -A "hosts/${HOST}/sbin" 2>/dev/null)" ]]; then echo echo "note: this host has system scripts needing root:" echo " sudo install -m755 hosts/${HOST}/sbin/* /usr/local/bin/" fi