#!/usr/bin/env bash set -e CONFIG_SUFFIX=".conf.yaml" DOTBOT_DIR="dotbot" DOTBOT_BIN="bin/dotbot" BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROFILES_FILE="${BASEDIR}/.profiles" cd "${BASEDIR}" git submodule update --init --recursive "${DOTBOT_DIR}" load_config() { config="$1" if [ -f "${config}" ]; then "${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${config}" else echo "Skipping nonexistent file: ${config}" fi } OS_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')" if [ -f "${PROFILES_FILE}" ]; then mapfile -t profiles < "${PROFILES_FILE}" else profiles=("${@}") fi for conf in default "${OS_NAME}" "${profiles[@]}"; do load_config "${conf}${CONFIG_SUFFIX}" done printf "%s\n" "${profiles[@]}" > "${PROFILES_FILE}"