Refactor makefile for ssh.

This commit is contained in:
James Patrick 2019-06-14 21:49:18 -04:00
parent de228e5011
commit 3fac31bddb
1 changed files with 11 additions and 5 deletions

View File

@ -1,6 +1,7 @@
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
@ -9,11 +10,7 @@ install: | init update
init:
$(info => Setting up ssh)
$(mk_link) $(SOURCE) $(TARGET)
[ ! -e ~/.ssh/git.jpatrick.io ] \
&& echo "No key for git.jpatrick.io. Generating" \
&& ( ssh-keygen -t ed25519 -C "`hostname`: `date`" -f ~/.ssh/git.jpatrick.io -N "" \
; $(report) "Key generation" ) \
; true
$(MAKE) -C $(SRC_DIR) init_jpatrick_key
update:
@ -21,3 +18,12 @@ 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) info "Key for jpatrick.io already created"
endif