SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
SOURCE :=  $(SRC_DIR)/config
TARGET :=  ~/.ssh/config
JPATRICK_KEY := ~/.ssh/git.jpatrick.io

include ../lib/shared.mk

install: | init update

init:
	$(info => Setting up ssh)
	$(mk_link) $(SOURCE) $(TARGET)
	$(MAKE) -C $(SRC_DIR) init_jpatrick_key

update:

remove:
	$(info => Remvoing ssh)
	$(rm_link) $(TARGET)
	$(report) warn "NOTE: All prior keys still remain."

init_jpatrick_key:
ifeq ($(shell [ ! -e $(JPATRIC_KEY) ] $(return_val_truthy) ), true)
	$(report) info "Setting up key for jpatrick.io"
	ssh-keygen -t ed25519 -C "`hostname`: `date`" -f $(JPATRICK_KEY)  -N "" \
		; report info "jpatrick.io key created"
else
	$(report) warn "Key for jpatrick.io already created"
endif