Created
July 27, 2016 03:52
-
-
Save maemichi-monosense/89cae307c287ef9a42d8b94a23b1cf06 to your computer and use it in GitHub Desktop.
SSH/Config Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CP := cp -p | |
CONFIG_FILES := $(wildcard conf.d/*.conf) | |
SSH_DIR := $(HOME)/.ssh | |
define USAGE | |
Usage: | |
it make ~/.ssh/{config, keylist.txt} | |
usage show this | |
help same as usage | |
update git update | |
list list all conf.d/*.conf | |
config generate config from conf.d/*.conf | |
keylist show keylist from keylist.txt | |
deploy deploy config and keylist.txt to ~/.ssh/ | |
clean remove config | |
endef | |
export USAGE | |
# failsafe | |
.PHONY: help usage | |
help usage: | |
@echo "$$USAGE" | \ | |
column -t -s $$'\t' | |
.PHONY: it | |
it: config deploy clean; | |
.PHONY: list | |
list: $(CONFIG_FILES) | |
@echo $^ | \ | |
xargs -n 1 echo | |
.PHONY: update | |
update: | |
git fetch --prune | |
git pull origin master | |
config: $(CONFIG_FILES) | |
echo "# -*- ssh-config -*-" | \ | |
cat - $^ \ | |
> $@ | |
keylist: keylist.txt | |
grep -v '^#' $^ | |
.PHONY: deploy | |
deploy: config keylist.txt | |
$(CP) config $(SSH_DIR) | |
$(CP) keylist.txt $(SSH_DIR) | |
.PHONY: clean | |
clean: | |
# rm -f config | |
define SHQX | |
perl -p -i -e 's/^# \$sh\((.*)\)$/ join "\n", qx{$1} /e' $1 | |
endef | |
define STRIP | |
grep -E -v '^(# -\*-|//)' $1 | |
endef |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just use
Include
since OpenSSH 7.3