feat: Handle errors on password retrieval from 1Password in secrets.sh
This commit is contained in:
@@ -9,6 +9,13 @@ printfe "%s\n" "cyan" "Fetching password from 1Password..."
|
||||
echo -en '\r'
|
||||
|
||||
output=$(op item get "SSH Config Secrets" --fields password)
|
||||
|
||||
# Check if the password was found
|
||||
if [[ -z "$output" ]]; then
|
||||
printfe "%s\n" "red" "Password not found in 1Password, add a login item with the name 'SSH Config Secrets' and give it a password."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command=$(echo "$output" | grep -oP "(?<=use ').*(?=')")
|
||||
password=$(eval $command | grep -oP "(?<= password: ).*" | tr -d '\n')
|
||||
|
||||
@@ -38,4 +45,4 @@ elif [[ "$2" == "encrypt" ]]; then
|
||||
else
|
||||
printfe "%s\n" "red" "Invalid argument. Use 'decrypt' or 'encrypt'"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
Reference in New Issue
Block a user