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])')
|
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
|
# 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
|
# Loop through the keys and remove them from gitea to be replaced by the new one
|
||||||
if [ ! -z "$IDS" ]; then
|
if [ ! -z "$IDS" ]; then
|
||||||
for ID in IDS; do
|
for ID in $IDS; do
|
||||||
|
echo "Deleting key with ID $ID"
|
||||||
curl -X DELETE \
|
curl -X DELETE \
|
||||||
-s \
|
-s \
|
||||||
-H "Accept: application/json" \
|
-H "Accept: application/json" \
|
||||||
@@ -46,15 +47,16 @@ if [[ $KEY_EXISTS != true ]]; then
|
|||||||
--url "$KEYS_URL/$ID"
|
--url "$KEYS_URL/$ID"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Save the new key in gitea
|
|
||||||
curl -X POST \
|
# Save the new key in gitea
|
||||||
|
curl -X POST \
|
||||||
-s \
|
-s \
|
||||||
-H "Accept: application/json" \
|
-H "Accept: application/json" \
|
||||||
-H "Content-Type:application/json" \
|
-H "Content-Type:application/json" \
|
||||||
--data "$(generate_post_data)" \
|
--data "$(generate_post_data)" \
|
||||||
--url "$KEYS_URL"
|
--url "$KEYS_URL"
|
||||||
fi
|
|
||||||
|
|
||||||
HTTP_REPLACE="s/https:\/\/labs\.scarif\.space\//git@labs.scarif.space:/"
|
HTTP_REPLACE="s/https:\/\/labs\.scarif\.space\//git@labs.scarif.space:/"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user