diff options
author | Galen Guyer <galen@galenguyer.com> | 2022-08-16 13:14:56 -0400 |
---|---|---|
committer | Galen Guyer <galen@galenguyer.com> | 2022-08-16 13:14:56 -0400 |
commit | 36fbe057d2235cbc12c3e7e85d88486d02be6c12 (patch) | |
tree | 3eb368cb6041a3793078b10915c19b82da425df2 /modules/10-ssh/install.sh | |
parent | fe808a0b8bc5acdd715ae3903c83a9d2d1e43aa2 (diff) |
add ssh module
Diffstat (limited to 'modules/10-ssh/install.sh')
-rw-r--r-- | modules/10-ssh/install.sh | 34 |
1 files changed, 34 insertions, 0 deletions
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" +} |