Add some more to setup
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Setting up SSH"
|
||||
|
||||
# Extract the login details from enpass
|
||||
LABS=$(enpasscli -vault="$HOME/Documents/Enpass/Vaults/primary" -sort show "Scarif: Labs" 2>&1)
|
||||
LABSUN=$(echo "$LABS" | grep -Po "(?<=login: )\w+")
|
||||
@@ -28,7 +30,7 @@ CREDENTIALS="$LABSUN:$LABSPW" # The credentials to pass to the API
|
||||
KEYS_URL="https://$CREDENTIALS@labs.scarif.space/api/v1/user/keys"
|
||||
|
||||
# Get all the existing keys
|
||||
KEYS=$(curl -X GET -s --url "$KEYS_URL")
|
||||
KEYS=$(curl -X GET -s -S --url "$KEYS_URL")
|
||||
|
||||
KEY_EXISTS=$(echo $KEYS | jq --arg TITLE "$TITLE" 'map(.title)|contains([$TITLE])')
|
||||
|
||||
@@ -41,10 +43,10 @@ if [[ $KEY_EXISTS == true ]]; then
|
||||
for ID in $IDS; do
|
||||
echo "Deleting key with ID $ID"
|
||||
curl -X DELETE \
|
||||
-s \
|
||||
-s -S \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type:application/json" \
|
||||
--url "$KEYS_URL/$ID"
|
||||
--url "$KEYS_URL/$ID" > /dev/null
|
||||
done
|
||||
fi
|
||||
fi
|
||||
@@ -52,11 +54,11 @@ fi
|
||||
|
||||
# Save the new key in gitea
|
||||
curl -X POST \
|
||||
-s \
|
||||
-s -S \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type:application/json" \
|
||||
--data "$(generate_post_data)" \
|
||||
--url "$KEYS_URL"
|
||||
--url "$KEYS_URL" > /dev/null
|
||||
|
||||
HTTP_REPLACE="s/https:\/\/labs\.scarif\.space\//git@labs.scarif.space:/"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user