chore: moves ssh key into secrets
Signed-off-by: Menno van Leeuwen <menno@vleeuwen.me>
This commit is contained in:
@@ -8,11 +8,18 @@ source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
printfe "%s\n" "cyan" "Fetching password from 1Password..."
|
||||
echo -en '\r'
|
||||
|
||||
output=$(op item get "SSH Config Secrets" --fields password)
|
||||
# if WSL alias op to op.exe
|
||||
if [[ $(uname -a) == *"microsoft-standard-WSL2"* ]]; then
|
||||
alias op="op.exe"
|
||||
else
|
||||
alias op="op"
|
||||
fi
|
||||
|
||||
output=$(op item get "Dotfiles 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."
|
||||
printfe "%s\n" "red" "Password not found in 1Password, add a login item with the name 'Dotfiles Secrets' and give it a password."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@@ -72,11 +72,18 @@ ensure_symlink() {
|
||||
desired_chmod=$(shyaml get-value "config.symlinks.$1.chmod" < "$HOME/dotfiles/config/config.yaml" 2>/dev/null)
|
||||
|
||||
if [ -n "$desired_chmod" ]; then
|
||||
# Check if the current source file has the correct chmod
|
||||
current_chmod=$(stat -c %a "$source") # Check permissions of source file, since that's what chmod affects.
|
||||
# Resolve the target if it is a symlink
|
||||
resolved_target=$(readlink -f "$target")
|
||||
|
||||
# If readlink fails, fall back to the original target
|
||||
if [ -z "$resolved_target" ]; then
|
||||
resolved_target="$target"
|
||||
fi
|
||||
|
||||
current_chmod=$(stat -c %a "$resolved_target")
|
||||
if [ "$current_chmod" != "$desired_chmod" ]; then
|
||||
printfe "%s\n" "yellow" " - Changing chmod of $source to $desired_chmod"
|
||||
chmod "$desired_chmod" "$source"
|
||||
printfe "%s\n" "yellow" " - Changing chmod of $resolved_target to $desired_chmod"
|
||||
chmod "$desired_chmod" "$resolved_target"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
Reference in New Issue
Block a user