chore: make Prettier
[webi-installers/.git] / ssh-pubkey / install.sh
index 044e1e11667b243cad6bd9f71581346028cd2e4f..6f2ef5e11bad41c9497ae2183da7df13ba1c077e 100644 (file)
@@ -1,25 +1,20 @@
 #!/bin/bash
-
 set -e
 set -u
 
-mkdir -p "$HOME/.ssh/"
+function __install_ssh_pubkey() {
+    my_cmd="ssh-pubkey"
+
+    rm -f "$HOME/.local/bin/${my_cmd}"
+
+    webi_download \
+        "$WEBI_HOST/packages/${my_cmd}/${my_cmd}.sh" \
+        "$HOME/.local/bin/${my_cmd}"
 
-if [ ! -f "$HOME/.ssh/id_rsa" ]; then
-    ssh-keygen -b 2048 -t rsa -f "$HOME/.ssh/id_rsa" -q -N ""
-    echo ""
-fi
+    chmod a+x "$HOME/.local/bin/${my_cmd}"
 
-if [ ! -f "$HOME/.ssh/id_rsa.pub" ]; then
-    ssh-keygen -y -f "$HOME/.ssh/id_rsa" > "$HOME/.ssh/id_rsa.pub"
-    echo ""
-fi
+    # run the command
+    "$HOME/.local/bin/${my_cmd}"
+}
 
-# TODO use the comment (if any) for the name of the file
-echo ""
-echo "~/Downloads/id_rsa.$(whoami).pub":
-echo ""
-rm -f "$HOME/Downloads/id_rsa.$(whoami).pub":
-cp -r "$HOME/.ssh/id_rsa.pub" "$HOME/Downloads/id_rsa.$(whoami).pub"
-cat "$HOME/Downloads/id_rsa.$(whoami).pub"
-echo ""
+__install_ssh_pubkey