From 37341c087b72228b901039771f0128c61f65edb8 Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Tue, 19 Jan 2021 00:24:57 +0000 Subject: [PATCH] added portable install option for native --- Agent/Kickstart_template | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/Agent/Kickstart_template b/Agent/Kickstart_template index d089274..910492a 100644 --- a/Agent/Kickstart_template +++ b/Agent/Kickstart_template @@ -18,15 +18,35 @@ while true; do - read -p "Do you wana use docker or native agent (D/N)" dn + read -p "Do you want to use docker or native agent (D/N)" dn case $dn in [Nn]* ) #Native install Methode mkdir /opt/ShellHub wget {{scheme}}://{{host}}/agent-amd64 -O /opt/ShellHub/agent chmod +x /opt/ShellHub/agent + echo "systemctl stop ShellHubAgent; mv /opt/ShellHub/agent /opt/ShellHub/agent.bck; wget {{scheme}}://{{host}}/agent-amd64 -O /opt/ShellHub/agent; systemctl stop ShellHubAgent" > /opt/ShellHub/UpdateAgent.sh + while true; do + read -p "Do you want to use portable or Service install (P/S)" dn + case $dn in + [Pp]* ) + echo "export SHELLHUB_PRIVATE_KEY=/opt/ShellHub/shellhubAgent.key" >>/opt/ShellHub/RunAgent.sh + echo "export SHELLHUB_TENANT_ID={{tenant_id}}" >>/opt/ShellHub/RunAgent.sh + echo "export SHELLHUB_SERVER_ADDRESS={{scheme}}://{{host}}" >>/opt/ShellHub/RunAgent.sh + {% if keepalive_interval ~= '' and keepalive_interval ~= nil then %} + echo "export SHELLHUB_KEEPALIVE_INTERVAL={{keepalive_interval}}" >>/opt/ShellHub/RunAgent.sh + {% end %} + {% if preferred_hostname ~= '' and preferred_hostname ~= nil then %} + echo "export SHELLHUB_PREFERRED_HOSTNAME={{preferred_hostname}}" >>/opt/ShellHub/RunAgent.sh + {% end %} + echo "/opt/ShellHub/agent" >>/opt/ShellHub/RunAgent.sh + exit;; + [Ss]* ) + break;; - echo "" >>/etc/systemd/system/ShellHubAgent.service + * ) echo "Please answer D(ocker) or N(ative).";; + esac + done echo "[Unit]" >>/etc/systemd/system/ShellHubAgent.service echo "Description=ShellHub Api" >>/etc/systemd/system/ShellHubAgent.service echo "Wants=network-online.target" >>/etc/systemd/system/ShellHubAgent.service @@ -35,13 +55,11 @@ while true; do echo "Environment=SHELLHUB_PRIVATE_KEY=/opt/ShellHub/shellhubAgent.key" >>/etc/systemd/system/ShellHubAgent.service echo "Environment=SHELLHUB_TENANT_ID={{tenant_id}}" >>/etc/systemd/system/ShellHubAgent.service echo "Environment=SHELLHUB_SERVER_ADDRESS={{scheme}}://{{host}}" >>/etc/systemd/system/ShellHubAgent.service - - {% if keepalive_interval ~= '' and keepalive_interval ~= nil then %} - echo "Environment=SHELLHUB_KEEPALIVE_INTERVAL={{keepalive_interval}}" >>/etc/systemd/system/ShellHubAgent.service + echo "Environment=SHELLHUB_KEEPALIVE_INTERVAL={{keepalive_interval}}" >>/etc/systemd/system/ShellHubAgent.service {% end %} {% if preferred_hostname ~= '' and preferred_hostname ~= nil then %} - echo "Environment=SHELLHUB_PREFERRED_HOSTNAME={{preferred_hostname}}" >>/etc/systemd/system/ShellHubAgent.service + echo "Environment=SHELLHUB_PREFERRED_HOSTNAME={{preferred_hostname}}" >>/etc/systemd/system/ShellHubAgent.service {% end %} echo "ExecStart=/opt/ShellHub/agent" >>/etc/systemd/system/ShellHubAgent.service