]>
us-delaporte.pagekite.me Git - dotfiles.git/blob - bin/dot
aa633ec68a98515150969734c87925fabe8fb605
3 ANSIBLE
="$ENVS/ansible/bin/ansible-playbook"
5 dot - a (mostly) one script dotfiles manager
7 Copyright 2026 Edward Delaporte V
8 Licensed under AGPLv3 and later.
11 install ansible CLI to $ANSIBLE
14 updates ~/dot.HOSTNAME.yaml
15 to include a symlink from ~/dotfiles/files/FILE to ~/.FILE
18 check setup against ~/backup/dot.HOSTNAME.yaml
21 apply config in ~/backup/dot.HOSTNAME.yaml
24 setup - more information on setup
25 all - additional features
28 read -d '' SETUP_HELP
<< EOF
31 1. Install this file on your path
32 2. Clone your (or my) 'dotfiles' repository to ~/dotfiles
33 3. Run 'dot help' to get started.
38 read -d '' EXTRA_HELP
<< EOF
41 updates ~/dot.HOSTNAME.yaml
42 to run ~/dotfiles/SCRIPT.sh if it has not yet been run
43 creates ~/dot/SCRIPT.installed after SCRIPT has been run
48 if [ ! -n "$1" ] || [ "$1" == "help" ]; then
51 if [ "$1" == "help" ] && [ "$2" == "all" ]; then
57 if [ "$1" == "help" ] && [ "$2" == "setup" ]; then
65 TASKFILE
="$HOME/backup/dot.$HOSTNAME.yaml"
66 LINKFILES
="$HOME/dotfiles/files"
67 INSTALLS
="$HOME/dotfiles/install"
70 read -d '' EMPTY_TASKFILE
<< EOF
72 - name: Set up dotfiles on $HOSTNAME
78 - name: Check on $TASKFILE
83 if [[ ! -f "$TASKFILE" ]]; then
84 echo "Creating empty $TASKFILE"
85 mkdir -p "$HOME/backup"
86 echo "$EMPTY_TASKFILE" >> $TASKFILE
89 if [ "$1" == "setup" ]; then
90 if [[ ! -f "$ANSIBLE" ]]; then
92 echo "Setting up Ansible in ~/envs/ansible"
93 cd $HOME/envs
; python3
-m venv ansible
94 $HOME/envs
/ansible
/bin
/pip
install ansible jinja2
96 if [[ -f "$ANSIBLE" ]]; then
97 echo "[ ok ]: Ansible setup at $ANSIBLE"
99 if [[ -f "$TASKFILE" ]]; then
100 echo "[ ok ]: dot config at $TASKFILE"
104 if [ "$1" == "reset" ]; then
105 read -n1 -p "Reset $TASKFILE? [y,N]" input
106 if [[ ! $input == "Y" && ! $input == "y" ]]; then
107 echo "Aborted by user"
110 echo "$EMPTY_TASKFILE" > $TASKFILE
115 if [ "$1" == "check" ]; then
116 $ANSIBLE $TASKFILE --check --diff
119 if [ "$1" == "link" ]; then
120 if [ ! -n "$2" ]; then
121 echo "Can symlink: (from $LINKFILES)"
127 read -d '' LINK_THIS_FILE
<< EOF
130 ansible.builtin.file:
136 if [[ "$2" == *"."* ]];then
137 # File already contains a dot
138 read -d '' LINK_THIS_FILE
<< EOF
141 ansible.builtin.file:
150 echo " $LINK_THIS_FILE" >> $TASKFILE
151 echo "$2 added to symlinks in $TASKFILE"
152 echo "Run 'dot apply' to create all configured symlinks"
156 if [ "$1" == "apply" ]; then
157 if [[ ! -f "$TASKFILE" ]]; then
158 echo "$TASKFILE is missing. Run 'dot setup'"
164 if [ "$1" == "install" ]; then
165 if [ ! -n "$2" ]; then
166 echo "Can install: (.sh scripts in $INSTALLS)"
168 ls -p | grep -v / | grep .sh
171 if [[ ! -f "$INSTALLS/$2.sh" ]]; then
172 echo "No such install script $INSTALLS/$2.sh"
173 echo "Run dot install with no params to list scripts."
178 read -d '' RUN_INSTALL
<< EOF
181 path: "$DOT/$2.installed"
182 register: $2_installed
184 ansible.builtin.shell: |
186 touch "$DOT/$2.installed"
187 when: not $2_installed.stat.exists
188 - name: verify $2 is installed
189 ansible.builtin.debug:
190 msg: "$2 is installed."
191 when: $2_installed.stat.exists
193 echo " $RUN_INSTALL" >> $TASKFILE
194 echo "Run 'dot apply' to run the install"