]>
us-delaporte.pagekite.me Git - dotfiles.git/blob - bin/dot
a08b732ddf7402cf0e7f177a6237a83f73366332
3 ANSIBLE
="$ENVS/ansible/bin/ansible-playbook"
5 dot - a (mostly) one script dotfiles manager
7 1. Install this file on your path
8 2. Clone your (or my) 'dotfiles' repository to ~/dotfiles
9 3. Run 'dot help' to get started.
11 Copyright 2026 Edward Delaporte V
12 Licensed under AGPLv3 and later.
15 install ansible CLI to $ANSIBLE
18 updates ~/dot.HOSTNAME.yaml
19 to include a symlink from ~/dotfiles/files/FILE to ~/.FILE
22 updates ~/dot.HOSTNAME.yaml
23 to run ~/dotfiles/SCRIPT.sh if it has not yet been run
24 creates ~/dot/SCRIPT.installed after SCRIPT has been run
27 check setup against ~/dot.HOSTNAME.yaml
30 apply config in ~/dot.HOSTNAME.yaml
33 if [ ! -n "$1" ] || [ "$1" == "help" ]; then
38 TASKFILE
="$HOME/backup/dot.$HOSTNAME.yaml"
39 LINKFILES
="$HOME/dotfiles/files"
40 INSTALLS
="$HOME/dotfiles/install"
43 read -d '' EMPTY_TASKFILE
<< EOF
45 - name: Set up dotfiles on $HOSTNAME
51 - name: Check on $TASKFILE
56 if [[ ! -f "$TASKFILE" ]]; then
57 echo "Creating empty $TASKFILE"
58 mkdir -p "$HOME/backup"
59 echo "$EMPTY_TASKFILE" >> $TASKFILE
62 if [ "$1" == "setup" ]; then
63 if [[ ! -f "$ANSIBLE" ]]; then
65 echo "Setting up Ansible in ~/envs/ansible"
66 cd $HOME/envs
; python3
-m venv ansible
67 $HOME/envs
/ansible
/bin
/pip
install ansible jinja2
69 if [[ -f "$ANSIBLE" ]]; then
70 echo "[ ok ]: Ansible setup at $ANSIBLE"
72 if [[ -f "$TASKFILE" ]]; then
73 echo "[ ok ]: dot config at $TASKFILE"
77 if [ "$1" == "reset" ]; then
78 read -n1 -p "Reset $TASKFILE? [y,N]" input
79 if [[ ! $input == "Y" && ! $input == "y" ]]; then
80 echo "Aborted by user"
83 echo "$EMPTY_TASKFILE" > $TASKFILE
88 if [ "$1" == "check" ]; then
89 $ANSIBLE $TASKFILE --check --diff
92 if [ "$1" == "link" ]; then
93 if [ ! -n "$2" ]; then
94 echo "Can symlink: (from $LINKFILES)"
100 read -d '' LINK_THIS_FILE
<< EOF
103 ansible.builtin.file:
109 if [[ "$2" == *"."* ]];then
110 # File already contains a dot
111 read -d '' LINK_THIS_FILE
<< EOF
114 ansible.builtin.file:
123 echo " $LINK_THIS_FILE" >> $TASKFILE
124 echo "$2 added to symlinks in $TASKFILE"
125 echo "Run 'dot apply' to create all configured symlinks"
129 if [ "$1" == "apply" ]; then
130 if [[ ! -f "$TASKFILE" ]]; then
131 echo "$TASKFILE is missing. Run 'dot setup'"
137 if [ "$1" == "install" ]; then
138 if [ ! -n "$2" ]; then
139 echo "Can install: (.sh scripts in $INSTALLS)"
141 ls -p | grep -v / | grep .sh
144 if [[ ! -f "$INSTALLS/$2.sh" ]]; then
145 echo "No such install script $INSTALLS/$2.sh"
146 echo "Run dot install with no params to list scripts."
151 read -d '' RUN_INSTALL
<< EOF
154 path: "$DOT/$2.installed"
155 register: $2_installed
157 ansible.builtin.shell: |
159 touch "$DOT/$2.installed"
160 when: not $2_installed.stat.exists
161 - name: verify $2 is installed
162 ansible.builtin.debug:
163 msg: "$2 is installed."
164 when: $2_installed.stat.exists
166 echo " $RUN_INSTALL" >> $TASKFILE
167 echo "Run 'dot apply' to run the install"