From d28aa5aeff226d3dab2e9f805a03397aedcf2fcf Mon Sep 17 00:00:00 2001 From: Valentin <43043885+itsmrval@users.noreply.github.com> Date: Thu, 14 Sep 2023 22:21:40 +0200 Subject: [PATCH] Update update.sh --- update.sh | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/update.sh b/update.sh index 8f46d2e..04da579 100644 --- a/update.sh +++ b/update.sh @@ -1,11 +1,37 @@ #! /bin/bash -. /opt/accessgate/config.txt +. /opt/accessgate_agent/config.txt -if [ $user != "root" ] +if [ $user == "accessgatemultiuser"] then -user="home/$user" + tmp_file=/opt/accessgate_agent/tmp_user.txt + old_file=/opt/accessgate_agent/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 + + for x in $(head $tmp_file) + do + + 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 + +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 + fi -mkdir -p /$user/.ssh/ -curl -o /$user/.ssh/authorized_keys -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server +mv $tmp_file $old_file