Fixed ssh command more

This commit is contained in:
2021-05-01 13:42:00 +01:00
parent acc88fdf81
commit a09d00d7f7

View File

@@ -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,16 +47,17 @@ if [[ $KEY_EXISTS != true ]]; then
--url "$KEYS_URL/$ID" --url "$KEYS_URL/$ID"
done done
fi fi
# Save the new key in gitea
curl -X POST \
-s \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
--data "$(generate_post_data)" \
--url "$KEYS_URL"
fi fi
# Save the new key in gitea
curl -X POST \
-s \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
--data "$(generate_post_data)" \
--url "$KEYS_URL"
HTTP_REPLACE="s/https:\/\/labs\.scarif\.space\//git@labs.scarif.space:/" HTTP_REPLACE="s/https:\/\/labs\.scarif\.space\//git@labs.scarif.space:/"
for dir in $(ls "$HOME/.local/src"); do for dir in $(ls "$HOME/.local/src"); do