Fixed ssh command more
This commit is contained in:
@@ -32,13 +32,14 @@ KEYS=$(curl -X GET -s --url "$KEYS_URL")
|
||||
|
||||
KEY_EXISTS=$(echo $KEYS | jq --arg TITLE "$TITLE" 'map(.title)|contains([$TITLE])')
|
||||
|
||||
if [[ $KEY_EXISTS != true ]]; then
|
||||
if [[ $KEY_EXISTS == true ]]; then
|
||||
# Extract the ids of the keys with the same title as this machine
|
||||
IDS=$(echo $KEYS | jq --arg TITLE "$TITLE" 'map(select(.title == $TITLE))[].id')
|
||||
IDS=$(echo "$KEYS" | jq --arg TITLE "$TITLE" 'map(select(.title == $TITLE))[].id')
|
||||
|
||||
# Loop through the keys and remove them from gitea to be replaced by the new one
|
||||
if [ ! -z "$IDS" ]; then
|
||||
for ID in IDS; do
|
||||
for ID in $IDS; do
|
||||
echo "Deleting key with ID $ID"
|
||||
curl -X DELETE \
|
||||
-s \
|
||||
-H "Accept: application/json" \
|
||||
@@ -46,6 +47,8 @@ if [[ $KEY_EXISTS != true ]]; then
|
||||
--url "$KEYS_URL/$ID"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Save the new key in gitea
|
||||
curl -X POST \
|
||||
@@ -54,7 +57,6 @@ if [[ $KEY_EXISTS != true ]]; then
|
||||
-H "Content-Type:application/json" \
|
||||
--data "$(generate_post_data)" \
|
||||
--url "$KEYS_URL"
|
||||
fi
|
||||
|
||||
HTTP_REPLACE="s/https:\/\/labs\.scarif\.space\//git@labs.scarif.space:/"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user