From edd010865daab0d8a3a64ecb6f06e9737eee5e85 Mon Sep 17 00:00:00 2001 From: Valentin <43043885+itsmrval@users.noreply.github.com> Date: Thu, 14 Sep 2023 22:20:46 +0200 Subject: [PATCH] fail.. --- agent.sh | 83 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/agent.sh b/agent.sh index 4ad3584..cf3fa60 100644 --- a/agent.sh +++ b/agent.sh @@ -1,44 +1,67 @@ -#! /bin/bash +#!/bin/bash + +url=$1 +server=$2 +secret=$3 +user=$4 +rootpath="/opt/accessgate" +updateScriptUrl=https://raw.githubusercontent.com/itsmrval/accessgate/scripts/update.sh -. config.txt +i=0 +while [ $i -ne 100 ] +do + i=$(($i+1)) + echo "" +done -if [ $user == "accessgatemultiuser"] +printf " ___ ______ __ \n" +printf " / | _____________ __________/ ____/___ _/ /____ \n" +printf " / /| |/ ___/ ___/ _ \/ ___/ ___/ / __/ __ \`/ __/ _ \ \n" +printf " / ___ / /__/ /__/ __(__ |__ ) /_/ / /_/ / /_/ __/ \n" +printf "/_/ |_\___/\___/\___/____/____/\____/\__,_/\__/\___/ \n\n\n\n" + +echo -ne "[INFO] Checking agent directory.. " + +if [ -d "$rootpath" ] then - tmp_file=tmp_user.txt - old_file=old_user.txt - isDifferent=false - curl -o $tmp_file -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server/users - [[ -f filename ]] || touch $old_file - cmp --silent $old_file $tmp_file || isDifferent=true + rm -rf $rootpath +fi +mkdir -p $rootpath +echo -ne "✓\n" - for x in $(head $tmp_file) - do +echo -ne "[INFO] Testing parameters.. " - userPath=$x - echo $x - if [ $x != "root" ] - then - userPath=home/$x - fi - mkdir -p $userPath/.ssh - curl -o $userPath/.ssh -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server/key/$x - done +secretRequest=$(curl -s -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server) +if [ "$secretRequest" = "invalid request" ] +then + echo -ne "✗\n" + echo '[ERROR] Please verify your configuration' + exit else - if [ $user != "root" ] - then - userPath=home/$x - fi - mkdir -p $userPath/.ssh - curl -o $userPath/.ssh -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server/allKeys - + echo -ne "✓\n" fi +echo -ne "[INFO] Creating agent directory.. " +touch $rootpath/config.txt +truncate -s 0 $rootpath/config.txt +tee -a $rootpath/config.txt > /dev/null <