From 36fbe057d2235cbc12c3e7e85d88486d02be6c12 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Tue, 16 Aug 2022 13:14:56 -0400 Subject: add ssh module --- modules/10-ssh/install.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 modules/10-ssh/install.sh (limited to 'modules/10-ssh/install.sh') diff --git a/modules/10-ssh/install.sh b/modules/10-ssh/install.sh new file mode 100644 index 0000000..8fb3145 --- /dev/null +++ b/modules/10-ssh/install.sh @@ -0,0 +1,34 @@ +_script="$(realpath ${BASH_SOURCE[0]})" +_scriptname="$(basename $_script)" +_scriptdir="$(dirname $_script)" +_modulename="$(basename $_scriptdir)" +DOT_MODULE_NAME="ssh" + +function preinstall() { + if ! [[ -x "$(command -v ssh)" ]]; then + PACKAGES+=("openssh") + fi + if ! [[ -x "$(command -v git-crypt)" ]]; then + PACKAGES+=("git-crypt") + fi +} + +function install() { + git-crypt unlock + + if [[ "$?" -ne "0" ]]; then + log error "error decrypting ssh files, bailing before we break anthing" + return + fi + + # backup old file if it exists and we haven't backed it up before + if [[ -d "$HOME/.ssh" ]] && ! [[ -d "$HOME/.ssh.bak" ]] && ! [[ -f "$_scriptdir/.firstrun" ]]; then + log verbose "making backup" + cp -r "$HOME/.ssh" "$HOME/.ssh.bak" + touch "$_scriptdir/.firstrun" + fi + + log info "linking ~/.ssh" + rm -rf "$HOME/.ssh" + ln -sf "$_scriptdir/ssh" "$HOME/.ssh" +} -- cgit v1.2.3