]>
apps.delaporte.us Git - dotfiles.git/blob - bin/dot
c3e4a6aa10f9fa5c7c9e3d16c529605a27dcafba
3 dot - a (mostly) one script dotfiles manager
5 Copyright 2026 Edward Delaporte V
6 Licensed under AGPLv3 and later.
9 install the necessary tools to $HOME/envs/dot
12 updates ~/dot.HOSTNAME.yaml
13 to include a symlink from ~/dotfiles/files/FILE to ~/.FILE
16 check setup against ~/dot.HOSTNAME.yaml
19 apply config in ~/dot.HOSTNAME.yaml
22 if [ ! -n "$1" ] || [ "$1" == "help" ]; then
28 ANSIBLE
="$ENVS/ansible/bin/ansible-playbook"
29 TASKFILE
="$HOME/dot.$HOSTNAME.yaml"
30 LINKFILES
="$HOME/dotfiles/files"
31 INSTALLS
="$HOME/dotfiles/install"
34 read -d '' EMPTY_TASKFILE
<< EOF
36 - name: Set up dotfiles on $HOSTNAME
42 - name: Check on $TASKFILE
48 if [ "$1" == "setup" ]; then
49 if [[ ! -f "$ANSIBLE" ]]; then
51 echo "Setting up Ansible in ~/envs/ansible"
52 cd $HOME/envs
; python3
-m venv ansible
53 $HOME/envs
/ansible
/bin
/pip
install ansible jinja2
55 if [[ -f "$ANSIBLE" ]]; then
56 echo "[ ok ]: Ansible setup at $ANSIBLE"
58 if [[ ! -f "$TASKFILE" ]]; then
59 echo "Creating $TASKFILE"
60 echo "$EMPTY_TASKFILE" >> $TASKFILE
62 if [[ -f "$TASKFILE" ]]; then
63 echo "[ ok ]: dot config at $TASKFILE"
67 if [ "$1" == "reset" ]; then
68 read -n1 -p "Reset $TASKFILE? [y,N]" input
69 if [[ ! $input == "Y" && ! $input == "y" ]]; then
70 echo "Aborted by user"
73 echo "$EMPTY_TASKFILE" > $TASKFILE
78 if [ "$1" == "check" ]; then
79 $ANSIBLE $TASKFILE --check --diff
82 if [ "$1" == "link" ]; then
83 if [ ! -n "$2" ]; then
90 read -d '' LINK_THIS_FILE
<< EOF
99 echo " $LINK_THIS_FILE" >> $TASKFILE
100 echo "$2 added to symlinks in $TASKFILE"
101 echo "Run 'dot apply' to create all configured symlinks"
105 if [ "$1" == "apply" ]; then
106 if [[ ! -f "$TASKFILE" ]]; then
107 echo "$TASKFILE is missing. Run 'dot setup'"
113 if [ "$1" == "install" ]; then
114 if [ ! -n "$2" ]; then
120 if [[ ! -f "$INSTALLS/$2.sh" ]]; then
121 echo "No such install script $INSTALLS/$2.sh"
122 echo "Run dot install with no params to list scripts."
127 read -d '' RUN_INSTALL
<< EOF
130 path: "$DOT/$2.installed"
131 register: $2_installed
133 ansible.builtin.shell: |
135 touch "$DOT/$2.installed"
136 when: not $2_installed.stat.exists
137 - name: verify $2 is installed
138 ansible.builtin.debug:
139 msg: "$2 is installed."
140 when: $2_installed.stat.exists
142 echo " $RUN_INSTALL" >> $TASKFILE
143 echo "Run 'dot apply' to run the install"