]>
apps.delaporte.us Git - dotfiles.git/blob - bin/dot
2 # dot - a (mostly) one script dotfiles manager
4 # Copyright 2026 Edward Delaporte V
5 # Licensed under AGPLv3 and later.
8 # symlinks - any file in $HOME/dotfiles/files may be symlinked
11 # install the necessary tools to $HOME/envs/dot
14 # updates ~/dot.HOSTNAME.yaml
15 # to include a symlink from ~/dotfiles/files/FILE to ~/.FILE
18 # check setup against ~/dot.HOSTNAME.yaml
21 # apply config in ~/dot.HOSTNAME.yaml
26 ANSIBLE
="$ENVS/ansible/bin/ansible-playbook"
27 TASKFILE
="$HOME/dot.$HOSTNAME.yaml"
28 LINKFILES
="$HOME/dotfiles/files"
29 INSTALLS
="$HOME/dotfiles/install"
31 read -d '' EMPTY_TASKFILE
<< EOF
33 - name: Set up dotfiles on $HOSTNAME
39 - name: Check on $TASKFILE
45 if [ "$1" == "setup" ]; then
46 if [[ ! -f "$ANSIBLE" ]]; then
48 echo "Setting up Ansible in ~/envs/ansible"
49 cd $HOME/envs
; python3
-m venv ansible
50 $HOME/envs
/ansible
/bin
/pip
install ansible jinja2
52 if [[ -f "$ANSIBLE" ]]; then
53 echo "[ ok ]: Ansible setup at $ANSIBLE"
55 if [[ ! -f "$TASKFILE" ]]; then
56 echo "Creating $TASKFILE"
57 echo "$EMPTY_TASKFILE" >> $TASKFILE
59 if [[ -f "$TASKFILE" ]]; then
60 echo "[ ok ]: dot config at $TASKFILE"
64 if [ "$1" == "reset" ]; then
65 read -n1 -p "Reset $TASKFILE? [y,N]" input
66 if [[ ! $input == "Y" && ! $input == "y" ]]; then
67 echo "Aborted by user"
70 echo "$EMPTY_TASKFILE" > $TASKFILE
75 if [ "$1" == "check" ]; then
76 $ANSIBLE $TASKFILE --check --diff
79 if [ "$1" == "link" ]; then
80 if [ ! -n "$2" ]; then
87 read -d '' LINK_THIS_FILE
<< EOF
96 echo " $LINK_THIS_FILE" >> $TASKFILE
97 echo "$2 added to symlinks in $TASKFILE"
98 echo "Run 'dot apply' to create all configured symlinks"
102 if [ "$1" == "apply" ]; then
103 if [[ ! -f "$TASKFILE" ]]; then
104 echo "$TASKFILE is missing. Run 'dot setup'"
110 if [ "$1" == "install" ]; then
111 if [ ! -n "$2" ]; then