2020-03-19 19:55:20 +00:00
|
|
|
# -*- mode: makefile-gmake; -*-
|
2019-04-27 22:21:33 +00:00
|
|
|
SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
2020-03-19 19:55:20 +00:00
|
|
|
|
2019-12-11 05:53:01 +00:00
|
|
|
CONFIG_SRC := $(SRC_DIR)/config
|
|
|
|
CONFIG_TRGT := ~/.ssh/config
|
2020-03-09 17:30:45 +00:00
|
|
|
GIT_KEY := ~/.ssh/git.jpatrick.io
|
2019-04-27 22:21:33 +00:00
|
|
|
|
|
|
|
include ../lib/shared.mk
|
|
|
|
|
2021-11-28 21:33:24 +00:00
|
|
|
up: init
|
2020-03-09 17:30:45 +00:00
|
|
|
mkdir -p public_keys/`hostname`
|
|
|
|
cd ~/.ssh
|
|
|
|
$(report) header "Copying public keys"
|
|
|
|
for i in *.pub ; do
|
|
|
|
cp $$i public_keys/`hostname`/$$i
|
|
|
|
$(report) pass "Copied $$i"
|
2019-12-11 05:53:01 +00:00
|
|
|
done
|
2019-04-27 22:21:33 +00:00
|
|
|
|
2021-11-28 21:33:24 +00:00
|
|
|
down:
|
2020-03-09 17:30:45 +00:00
|
|
|
$(report) header "Removing ssh sym-links"
|
|
|
|
$(rm_link) $(CONFIG_TRGT)
|
|
|
|
$(report) warn "NOTE: All keys still remain."
|
2019-06-15 01:49:18 +00:00
|
|
|
|
2021-11-28 21:33:24 +00:00
|
|
|
init:
|
|
|
|
$(report) header "Setting up ssh"
|
|
|
|
$(mk_link) $(CONFIG_SRC) $(CONFIG_TRGT)
|
|
|
|
$(mk_link) $(SRC_DIR)/public_keys ~/.ssh/public_keys
|
|
|
|
$(mk_link) $(SRC_DIR)/config.d ~/.ssh/config.d
|
|
|
|
$(MAKE) -C $(SRC_DIR) init_git_key
|
|
|
|
|
2020-03-09 17:30:45 +00:00
|
|
|
init_git_key:
|
|
|
|
if [[ -e $(GIT_KEY) ]] ; then
|
|
|
|
$(report) debug "$(GIT_KEY) already installed."
|
|
|
|
else
|
|
|
|
$(report) info "Setting up key for git.jpatrick.io"
|
|
|
|
ssh-keygen -t ed25519 -C "`hostname`: `date`" -f $(GIT_KEY) -N "" \
|
|
|
|
; $(report) info "git.jpatrick.io key created"
|
|
|
|
fi
|