summaryrefslogtreecommitdiff
path: root/modules/10-ssh/install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'modules/10-ssh/install.sh')
-rw-r--r--modules/10-ssh/install.sh34
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"
+}