]> apps.delaporte.us Git - dotfiles.git/commitdiff
Add ability to ansible symlink
authorEdward Delaporte <edward@delaporte.us>
Mon, 6 Jul 2026 03:46:49 +0000 (22:46 -0500)
committerEdward Delaporte <edward@delaporte.us>
Mon, 6 Jul 2026 03:46:49 +0000 (22:46 -0500)
bin/dot

diff --git a/bin/dot b/bin/dot
index 4e21e72397c556d8b1a73fc9833242bc0f6edac9..45a7a393824a3186bb40c3216a71ebf0806e0fe9 100755 (executable)
--- a/bin/dot
+++ b/bin/dot
 # dot setup
 #              install the necessary tools to $HOME/envs/dot
 #
 # dot setup
 #              install the necessary tools to $HOME/envs/dot
 #
-# dot list
-#   list available roles
+# dot link FILE
+#   updates ~/dot.HOSTNAME.yaml
+#   to include a symlink from ~/dotfiles/files/FILE to ~/.FILE
 #
 # dot check
 #
 # dot check
-#   check setup vs expected
-#
-# dot add ROLE
-#   add ROLE to localhost
+#              check setup against ~/dot.HOSTNAME.yaml
 #
 # dot apply
 #
 # dot apply
-#              apply all added ROLES
+#              apply config in ~/dot.HOSTNAME.yaml
 
 # set -v
 
 ENVS="$HOME/envs"
 ANSIBLE="$ENVS/ansible/bin/ansible-playbook"
 TASKFILE="$HOME/dot.$HOSTNAME.yaml"
 
 # set -v
 
 ENVS="$HOME/envs"
 ANSIBLE="$ENVS/ansible/bin/ansible-playbook"
 TASKFILE="$HOME/dot.$HOSTNAME.yaml"
+LINKFILES="$HOME/dotfiles/files"
 
 read -d '' EMPTY_TASKFILE << EOF
 ---
 
 read -d '' EMPTY_TASKFILE << EOF
 ---
@@ -36,8 +35,9 @@ read -d '' EMPTY_TASKFILE << EOF
   connection: local
 
   tasks:
   connection: local
 
   tasks:
-               - name: Do nothing
-      ansible.builtin.shell: echo "Nothing to do."
+    - name: Check on $TASKFILE
+      ansible.builtin.stat:
+        path: $TASKFILE
 EOF
 
 
 EOF
 
 
@@ -67,6 +67,7 @@ if [ "$1" == "reset" ]; then
                exit 1
        fi
        echo "$EMPTY_TASKFILE" > $TASKFILE
                exit 1
        fi
        echo "$EMPTY_TASKFILE" > $TASKFILE
+       echo ""
 fi
 
 
 fi
 
 
@@ -74,34 +75,25 @@ if [ "$1" == "check" ]; then
        $ANSIBLE $TASKFILE --check --diff
 fi
 
        $ANSIBLE $TASKFILE --check --diff
 fi
 
-if [ "$1" == "list" ]; then
-  echo "May symlink:"
-       cd $HOME/dotfiles/files
-       ls -p | grep -v /
-fi
-
-
-
-
-
 if [ "$1" == "link" ]; then
        if [ ! -n "$2" ]; then
                echo "May symlink:"
 if [ "$1" == "link" ]; then
        if [ ! -n "$2" ]; then
                echo "May symlink:"
-               cd $HOME/dotfiles/files
+               cd $LINKFILES
                ls -p | grep -v /
                ls -p | grep -v /
+               exit 1
        fi
 
        fi
 
-read -d '' LINK_FILE << EOF
----
-  tasks:
-               - name: Create a symbolic link
-                       ansible.builtin.file:
-                               src: /file/to/link/to
-                               dest: /path/to/symlink
-                               owner: foo
-                               group: foo
-                               state: link
+read -d '' LINK_THIS_FILE << EOF
+
+    - name: Create a symbolic link
+      ansible.builtin.file:
+        src: "$LINKFILES/$2"
+        dest: "$HOME/.$2"
+        state: "link"
 EOF
 
 EOF
 
+       echo "    $LINK_THIS_FILE" >> $TASKFILE
+       echo "$2 added to symlinks in $TASKFILE"
+       echo "Run `dot apply` to create all configured symlinks"
 fi
 
 fi