+
+if [ "$1" == "apply" ]; then
+ if [[ ! -f "$TASKFILE" ]]; then
+ echo "$TASKFILE is missing. Run 'dot setup'"
+ exit 1
+ fi
+ $ANSIBLE $TASKFILE
+fi
+
+if [ "$1" == "install" ]; then
+ if [ ! -n "$2" ]; then
+ echo "Can install: (.sh scripts in $INSTALLS)"
+ cd $INSTALLS
+ ls -p | grep -v / | grep .sh
+ exit 1
+ fi
+ if [[ ! -f "$INSTALLS/$2.sh" ]]; then
+ echo "No such install script $INSTALLS/$2.sh"
+ echo "Run dot install with no params to list scripts."
+ exit 1
+ fi
+
+mkdir -p $DOT
+read -d '' RUN_INSTALL << EOF
+ - name: check $2
+ stat:
+ path: "$DOT/$2.installed"
+ register: $2_installed
+ - name: install $2
+ ansible.builtin.shell: |
+ "$INSTALLS/$2.sh"
+ touch "$DOT/$2.installed"
+ when: not $2_installed.stat.exists
+ - name: verify $2 is installed
+ ansible.builtin.debug:
+ msg: "$2 is installed."
+ when: $2_installed.stat.exists
+EOF
+ echo " $RUN_INSTALL" >> $TASKFILE
+ echo "Run 'dot apply' to run the install"
+fi