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
|
. /opt/accessgate_agent/config.txt
|
||||||
|
|
||||||
if [ $user == "accessgatemultiuser"]
|
if [ "$user" = "accessgatemultiuser" ]
|
||||||
then
|
then
|
||||||
tmp_file=/opt/accessgate_agent/tmp_user.txt
|
tmp_file=/opt/accessgate_agent/tmp_user.txt
|
||||||
old_file=/opt/accessgate_agent/old_user.txt
|
old_file=/opt/accessgate_agent/old_user.txt
|
||||||
|
|
@ -11,27 +11,28 @@ then
|
||||||
[[ -f filename ]] || touch $old_file
|
[[ -f filename ]] || touch $old_file
|
||||||
cmp --silent $old_file $tmp_file || isDifferent=true
|
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)
|
for x in $(head $tmp_file)
|
||||||
do
|
do
|
||||||
|
|
||||||
userPath=$x
|
mkdir -p /home/$x/.ssh
|
||||||
echo $x
|
curl -o /home/$x/.ssh/authorized_keys -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server/key/$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
|
done
|
||||||
|
mv $tmp_file $old_file
|
||||||
else
|
else
|
||||||
if [ $user != "root" ]
|
if [ $user != "root" ]
|
||||||
then
|
then
|
||||||
userPath=home/$x
|
userPath=home/$x
|
||||||
fi
|
fi
|
||||||
mkdir -p $userPath/.ssh
|
mkdir -p /$user
|
||||||
curl -o $userPath/.ssh -X GET -H 'Content-Type: application/json' -d '{"secret": "'$secret'"}' $url/endpoint/update/$server/allKeys
|
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
|
fi
|
||||||
|
|
||||||
mv $tmp_file $old_file
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue