From 1fb899c968d1ed2bf1408eb045d35ca7cb10ad03 Mon Sep 17 00:00:00 2001
From: Dennis Eisold <de@itstall.de>
Date: Fri, 1 Mar 2019 21:24:46 +0100
Subject: [PATCH] Update install.sh

---
 install.sh | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/install.sh b/install.sh
index 17ce54c..c1098c4 100644
--- a/install.sh
+++ b/install.sh
@@ -1,16 +1,37 @@
-apt install -y etckeeper git
+#!/bin/bash
+if (($# == 1))
+then
+        echo "$1"
+        Token=$1
+else
+        echo 'usage: install.sh YourAccessToken'
+        exit
+fi
+
+Gitlab_Host="https://www.gitrepo.de"
+Gitlab_Repo="https://www.gitrepo.de/opensource/etckeeper_install/raw/master"
+key_pub=$(<~/.ssh/id_rsa.pub)
+hostname=`hostname -f`
+
+curl --data-urlencode "key=$key_pub" --data-urlencode "title=$hostname" $Gitlab_Host/api/v4/user/keys?private_token=$Token
+
+apt install -y etckeeper git wget
+
 ssh-keyscan ssh.gitrepo.de >> ~/.ssh/known_hosts
+
 echo "VCS=\"git\"
 AVOID_SPECIAL_FILE_WARNING=1
 PUSH_REMOTE=\"origin\"" > /etc/etckeeper/etckeeper.conf
+
 cd /etc
 git init
 git config --global user.name "roadit_ectkeeper"
 git config --global user.email "ectkeeper@roadit.de"
 git config --global core.editor "nano"
 git config --global push.default simple
-git remote add origin git@ssh.gitrepo.de:roadit/etckeeper/`hostname -f`.git
+git remote add origin git@ssh.gitrepo.de:roadit/etckeeper/$hostname.git
 etckeeper commit "initial commit"
-wget https://www.gitrepo.de/opensource/etckeeper_install/raw/master/logout_trap.sh -O /usr/local/share/logout_trap.sh
+
+wget $Gitlab_Repo/logout_trap.sh -O /usr/local/share/logout_trap.sh
 chmod +x /usr/local/share/logout_trap.sh
 echo "/usr/local/share/logout_trap.sh" >> ~/.profile
-- 
GitLab