nix-config/bin/dotfiles

39 lines
833 B
Text
Raw Normal View History

2022-03-30 23:41:06 +01:00
#!/bin/bash
set -e
2022-03-30 23:58:01 +01:00
CONFIG_DIR="$HOME/.config/dotfiles"
2022-03-30 23:41:06 +01:00
DOTFILES_DIR="$HOME/.dotfiles"
2022-04-26 14:43:21 +01:00
PATH="${PATH}:${HOME}/.local/bin"
2022-03-30 23:41:06 +01:00
clone_or_update_dotfiles() {
if ! [[ -d "$DOTFILES_DIR" ]]; then
git clone "https://github.com/opdavies/dotfiles.git" "$DOTFILES_DIR"
else
git -C "$DOTFILES_DIR" pull
fi
2022-03-30 23:41:06 +01:00
}
2022-03-30 23:58:01 +01:00
create_config_dir() {
mkdir -p "${CONFIG_DIR}"
}
2022-03-30 23:41:06 +01:00
install_dependencies() {
ansible-galaxy install -r "${DOTFILES_DIR}/requirements.yml"
}
2022-04-26 14:43:21 +01:00
install_ansible() {
sudo apt-get -yqq update
sudo apt-get -yqq install python3-pip
pip install ansible --user
}
2022-03-30 23:41:06 +01:00
run_playbook() {
ansible-playbook --diff --extra-vars "@${CONFIG_DIR}/values.yaml" --vault-password-file=${CONFIG_DIR}/vault-password.txt "${DOTFILES_DIR}/main.yaml" "${@}"
2022-03-30 23:41:06 +01:00
}
clone_or_update_dotfiles
2022-04-26 14:43:21 +01:00
install_ansible
2022-03-30 23:41:06 +01:00
install_dependencies
run_playbook "${@}"