aboutsummaryrefslogtreecommitdiffstats
path: root/ssh
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-05-06 09:53:43 +0200
committerMattias Andrée <maandree@kth.se>2024-05-06 09:53:43 +0200
commit16c57bb791a1fc76b8b00894e29c050681809402 (patch)
tree5627d8bf0ed3767956caf89d28eabb6155ff8879 /ssh
parentm (diff)
downloaddotfiles-16c57bb791a1fc76b8b00894e29c050681809402.tar.gz
dotfiles-16c57bb791a1fc76b8b00894e29c050681809402.tar.bz2
dotfiles-16c57bb791a1fc76b8b00894e29c050681809402.tar.xz
...
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--ssh/.gitignore2
-rw-r--r--ssh/Makefile32
2 files changed, 27 insertions, 7 deletions
diff --git a/ssh/.gitignore b/ssh/.gitignore
index 9942bb7..b5f26f6 100644
--- a/ssh/.gitignore
+++ b/ssh/.gitignore
@@ -1 +1,3 @@
.ssh-config
+.*.cache
+.*.prev
diff --git a/ssh/Makefile b/ssh/Makefile
index b16f051..e7bf102 100644
--- a/ssh/Makefile
+++ b/ssh/Makefile
@@ -1,29 +1,47 @@
.POSIX:
+DYNAMIC_ADDRESSES != \
+ for f in ../.secrets/ssh/hostfetch/* ../.work/ssh/hostfetch/* hostfetch/*; do \
+ test ! -x "$$f" || printf '%s\n' "$$f"; \
+ done | sort -u | sed 's|^.*/\([^/]*[^/~]\)$$|\1|'
+
install:
-rm -f -- .ssh-config
test ! -e .ssh-config && test ! -L .ssh-config
printf '# %s\n' 'THIS FILE IS GENERATED from ~/.dotfiles/ssh/Makefile' \
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' > .ssh-config
- printf '\n\n' >> .ssh-config
+ chmod -- 600 .ssh-config
if test -f config; then \
- cat config >> .ssh-config; \
+ ../cat-with-head -- config >> .ssh-config; \
fi
set config.d/* && if test -f "$$1"; then \
- ../cat-nonbackups -- "$$@" >> .ssh-config; \
+ ../cat-nonbackups-with-head -- "$$@" >> .ssh-config; \
fi
if test -f ../.secrets/ssh/config; then \
- cat ../.secrets/ssh/config >> .ssh-config; \
+ ../cat-with-head -- ../.secrets/ssh/config >> .ssh-config; \
fi
set ../.secrets/ssh/config.d/* && if test -f "$$1"; then \
- ../cat-nonbackups "$$@" >> .ssh-config; \
+ ../cat-nonbackups-with-head -- "$$@" >> .ssh-config; \
fi
if test -f ../.work/ssh/config; then \
- cat ../.work/ssh/config >> .ssh-config; \
+ ../cat-with-head -- ../.work/ssh/config >> .ssh-config; \
fi
set ../.work/ssh/config.d/* && if test -f "$$1"; then \
- ../cat-nonbackups "$$@" >> .ssh-config; \
+ ../cat-nonbackups-with-head -- "$$@" >> .ssh-config; \
fi
+ set -e; \
+ for name in $(DYNAMIC_ADDRESSES); do \
+ if test -x "../.secrets/ssh/hostfetch/$$name"; then \
+ addr="$$("../.secrets/ssh/hostfetch/$$name")"; \
+ elif test -x "../.work/ssh/hostfetch/$$name"; then \
+ addr="$$("../.work/ssh/hostfetch/$$name")"; \
+ else \
+ addr="$$("hostfetch/$$name")"; \
+ fi; \
+ test -n "$$addr"; \
+ sed "s/%$${name}%/$${addr}/g" -- "$$@" < .ssh-config > .ssh-config~; \
+ mv -- .ssh-config~ .ssh-config; \
+ done
mkdir -p -- ~/.ssh
test ! -e ~/.ssh/config || test -L ~/.ssh/config
test ! -e ~/.ssh/config || test -f ~/.ssh/config