mirror of
https://github.com/marcogll/omarchy_setup.git
synced 2026-01-13 13:25:16 +00:00
Para mejorar la compatibilidad y el rendimiento de la aceleración de video en hardware Intel Iris Xe, se han añadido los siguientes paquetes: - `libva-intel-driver`: Driver legacy para mayor compatibilidad con aplicaciones más antiguas. - `onevpl-intel-gpu`: Librería de la nueva generación oneVPL para el procesamiento de video moderno. Esto asegura una cobertura de códecs más completa.
129 lines
4.5 KiB
Bash
Executable File
129 lines
4.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# ===============================================================
|
|
# ssh-keyring.sh - Sincronizar claves SSH con GNOME Keyring
|
|
# ===============================================================
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "${SCRIPT_DIR}/common.sh"
|
|
|
|
_derive_fingerprint() {
|
|
local key_path="$1"
|
|
local pub_path="${key_path}.pub"
|
|
local fingerprint=""
|
|
|
|
if [[ -f "$pub_path" ]]; then
|
|
fingerprint="$(ssh-keygen -lf "$pub_path" 2>/dev/null | awk '{print $2}')"
|
|
else
|
|
fingerprint="$(ssh-keygen -lf <(ssh-keygen -y -f "$key_path" 2>/dev/null) 2>/dev/null | awk '{print $2}')"
|
|
fi
|
|
echo "$fingerprint"
|
|
}
|
|
|
|
sync_ssh_keyring() {
|
|
log_step "Sincronizar claves SSH con GNOME Keyring"
|
|
|
|
if ! command_exists gnome-keyring-daemon; then
|
|
log_error "gnome-keyring-daemon no está instalado. Ejecuta primero el módulo de aplicaciones."
|
|
return 1
|
|
fi
|
|
|
|
if ! command_exists ssh-add; then
|
|
log_error "ssh-add no está disponible (openssh). Instala el módulo de aplicaciones antes."
|
|
return 1
|
|
fi
|
|
|
|
mkdir -p "${HOME}/.config/environment.d"
|
|
cat <<'EOF' > "${HOME}/.config/environment.d/10-gnome-keyring.conf"
|
|
SSH_AUTH_SOCK=/run/user/$UID/keyring/ssh
|
|
EOF
|
|
|
|
# No intentamos iniciar el daemon. Después de un reinicio de sesión, ya debería estar activo.
|
|
log_info "Buscando el socket del agente de GNOME Keyring..."
|
|
|
|
# Obtenemos el UID del usuario dueño del directorio HOME. Este método es más fiable.
|
|
local target_uid
|
|
target_uid=$(stat -c '%u' "$HOME")
|
|
|
|
local keyring_socket="/run/user/${target_uid}/keyring/ssh"
|
|
|
|
if [[ ! -S "$keyring_socket" ]]; then
|
|
log_error "No se encontró el socket de GNOME Keyring en la ruta esperada: ${keyring_socket}"
|
|
log_warning "Esto usualmente significa que el servicio no se ha iniciado correctamente con tu sesión de escritorio."
|
|
log_info "Asegúrate de haber cerrado y vuelto a abrir tu sesión después de instalar el módulo de aplicaciones."
|
|
return 1
|
|
fi
|
|
|
|
log_success "Socket de GNOME Keyring encontrado en: ${keyring_socket}"
|
|
export SSH_AUTH_SOCK="$keyring_socket"
|
|
|
|
local ssh_dir="${HOME}/.ssh"
|
|
if [[ ! -d "$ssh_dir" ]]; then
|
|
log_warning "No existe el directorio ${ssh_dir}. No hay claves para agregar."
|
|
return 0
|
|
fi
|
|
|
|
mapfile -t ssh_private_keys < <(
|
|
find "$ssh_dir" -maxdepth 1 -type f -perm -u=r \
|
|
! -name "*.pub" \
|
|
! -name "*-cert.pub" \
|
|
! -name "known_hosts" \
|
|
! -name "known_hosts.*" \
|
|
! -name "authorized_keys" \
|
|
! -name "config" \
|
|
! -name "*.old" \
|
|
! -name "agent" \
|
|
! -name "*.bak" \
|
|
2>/dev/null | sort
|
|
)
|
|
if [[ ${#ssh_private_keys[@]} -eq 0 ]]; then
|
|
log_warning "No se encontraron claves privadas SSH en ${ssh_dir}."
|
|
return 0
|
|
fi
|
|
|
|
local existing_fingerprints=""
|
|
if output=$(SSH_AUTH_SOCK="$SSH_AUTH_SOCK" ssh-add -l 2>/dev/null); then
|
|
existing_fingerprints="$(awk '{print $2}' <<<"$output")"
|
|
else
|
|
existing_fingerprints=""
|
|
fi
|
|
|
|
local added=0
|
|
for key_path in "${ssh_private_keys[@]}"; do
|
|
local fingerprint
|
|
fingerprint="$(_derive_fingerprint "$key_path")"
|
|
if [[ -z "$fingerprint" ]] && ! ssh-keygen -y -f "$key_path" >/dev/null 2>&1; then
|
|
log_warning "El archivo $(basename "$key_path") no parece una clave privada válida. Se omite."
|
|
continue
|
|
fi
|
|
|
|
if [[ -n "$fingerprint" ]] && grep -Fq "$fingerprint" <<<"$existing_fingerprints"; then
|
|
log_info "Clave $(basename "$key_path") ya está registrada en el keyring."
|
|
continue
|
|
fi
|
|
|
|
log_info "Añadiendo clave $(basename "$key_path") al keyring..."
|
|
if SSH_AUTH_SOCK="$SSH_AUTH_SOCK" ssh-add "$key_path"; then
|
|
log_success "Clave $(basename "$key_path") añadida correctamente."
|
|
added=$((added + 1))
|
|
if [[ -n "$fingerprint" ]]; then
|
|
existing_fingerprints+=$'\n'"$fingerprint"
|
|
fi
|
|
else
|
|
log_warning "No se pudo añadir la clave $(basename "$key_path")."
|
|
fi
|
|
done
|
|
|
|
if [[ $added -gt 0 ]]; then
|
|
log_success "Claves SSH sincronizadas con GNOME Keyring."
|
|
else
|
|
log_info "No se añadieron nuevas claves SSH."
|
|
fi
|
|
|
|
log_info "Para verificar, ejecuta: ssh-add -l"
|
|
return 0
|
|
}
|
|
|
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
sync_ssh_keyring "$@"
|
|
fi
|