mirror of https://github.com/itsmrval/accessGate
fix
parent
3525bf21b7
commit
8700c67a66
29
update.sh
29
update.sh
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
. /opt/accessgate_agent/config.txt
|
||||
|
||||
if [ $user == "accessgatemultiuser"]
|
||||
if [ "$user" = "accessgatemultiuser" ]
|
||||
then
|
||||
tmp_file=/opt/accessgate_agent/tmp_user.txt
|
||||
old_file=/opt/accessgate_agent/old_user.txt
|
||||
|
|
@ -11,27 +11,28 @@ then
|
|||
[[ -f filename ]] || touch $old_file
|
||||
cmp --silent $old_file $tmp_file || isDifferent=true
|
||||
|
||||
if [ isDifferent = "true" ]
|
||||
then
|
||||
for x in $(head $old_file)
|
||||
do
|
||||
rm /home/$x/.ssh/authorized_keys
|
||||
done
|
||||
fi
|
||||
|
||||
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
|
||||
mkdir -p /home/$x/.ssh
|
||||
curl -o /home/$x/.ssh/authorized_keys -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server/key/$x
|
||||
done
|
||||
|
||||
mv $tmp_file $old_file
|
||||
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
|
||||
mkdir -p /$user
|
||||
mkdir -p /$user/.ssh/
|
||||
curl -o /$user/.ssh/authorized_keys -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server/allKeys
|
||||
|
||||
fi
|
||||
|
||||
mv $tmp_file $old_file
|
||||
|
|
|
|||
Loading…
Reference in New Issue