Update update.sh

scripts
Valentin 2023-09-14 22:21:40 +02:00 committed by GitHub
parent edd010865d
commit d28aa5aeff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 5 deletions

View File

@ -1,11 +1,37 @@
#! /bin/bash #! /bin/bash
. /opt/accessgate/config.txt . /opt/accessgate_agent/config.txt
if [ $user != "root" ] if [ $user == "accessgatemultiuser"]
then 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 fi
mkdir -p /$user/.ssh/ mv $tmp_file $old_file
curl -o /$user/.ssh/authorized_keys -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server