From 1b4993ea4b00aabff6895ad0d7339a60b970b947 Mon Sep 17 00:00:00 2001 From: "Mauro Rosero P." Date: Wed, 19 Mar 2025 17:41:54 -0500 Subject: [PATCH] [IMPROVED] Agregar mensajes i18n para ghadmin_install.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - A帽adir mensajes i18n con prefijo ghmsg_ para GitHub CLI installer - Implementar variables de mensajes localizados en todo el script - Mantener consistencia con el estilo de otros scripts 馃 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- bin/ghadmin_install.sh | 266 +++++++++++++++++++++++++++++++++++++++++ bin/msg/developers.es | 26 ++++ 2 files changed, 292 insertions(+) create mode 100755 bin/ghadmin_install.sh diff --git a/bin/ghadmin_install.sh b/bin/ghadmin_install.sh new file mode 100755 index 0000000..9939894 --- /dev/null +++ b/bin/ghadmin_install.sh @@ -0,0 +1,266 @@ +#!/bin/bash +# +# Script: ghadmin_install.sh +# Description: Script para instalar github manager CLI +# Created: 2025/03/19 11:57:08 +# Modified: 2025/03/19 11:57:08 +# [Author] Cortana Rosero One +# [Generated] Created by Claude Code (claude-3-7-sonnet-20250219) +# +# Derechos de Autor (C) [2025] [Mauro Rosero P. ] +# +# Este programa es software libre: usted puede redistribuirlo y/o modificarlo +# bajo los t茅rminos de la Licencia P煤blica Affero General de GNU tal como +# lo publica la Free Software Foundation, ya sea la versi贸n 3 de la licencia, +# o (a su elecci贸n) cualquier versi贸n posterior. +# +# Este programa se distribuye con la esperanza de que sea 煤til, +# pero SIN NINGUNA GARANT脥A; sin siquiera la garant铆a impl铆cita de +# COMERCIABILIDAD o IDONEIDAD PARA UN PROP脫SITO PARTICULAR. Consulte la +# Licencia P煤blica Affero General de GNU para obtener m谩s detalles. +# +# Deber铆a haber recibido una copia de la Licencia P煤blica Affero General +# junto con este programa. Si no la recibi贸, consulte . + +# Configuraci贸n inicial +# Usar DEVELOPER_DIR de base.lib +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +BIN_BASE="bin" +BIN_LIBS="lib" +BIN_MESG="msg" +BIN_CFGS="config" + +# Leer DEVSPATH desde el archivo de configuraci贸n o usar "devs" por defecto +if [ -f "$SCRIPT_DIR/config/devspath.dat" ]; then + DEVSPATH=$(cat "$SCRIPT_DIR/$BIN_CFGS/devspath.dat") +else + DEVSPATH="devs" +fi + +BIN_HOME="$HOME/$DEVSPATH" +VERSION=$(cat "$BIN_HOME/$BIN_BASE/$BIN_CFGS/version") + +# CHECK SHELL LANGUAGE +BIN_LANG=${LANG:0:2} + +# Importar bibliotecas necesarias +source "${BIN_HOME}/${BIN_BASE}/${BIN_LIBS}/base.lib" +source "${BIN_HOME}/${BIN_BASE}/${BIN_LIBS}/developers.lib" +source "${BIN_HOME}/${BIN_BASE}/${BIN_LIBS}/console.lib" + +# Cargar mensajes en el idioma del sistema o espa帽ol por defecto +load_messages "${BIN_HOME}/${BIN_BASE}" "${BIN_MESG}" "${BIN_LANG}" "head" +load_messages "${BIN_HOME}/${BIN_BASE}" "${BIN_MESG}" "${BIN_LANG}" "developers" +title="${head_000} ${head_002}" +apps_title="${ghmsg_000}" + +# Funci贸n para verificar si se est谩 ejecutando como root +check_root() { + if [ "$(id -u)" -ne 0 ]; then + echo "${ghmsg_001}" + echo "${ghmsg_002}" + + # Verificar si sudo est谩 disponible + if command -v sudo &> /dev/null; then + echo "${ghmsg_003}" + sudo "$0" "$@" + exit $? + elif command -v doas &> /dev/null; then + echo "${ghmsg_004}" + doas "$0" "$@" + exit $? + else + echo "${ghmsg_005}" + exit 1 + fi + fi +} + +# Funci贸n para detectar la distribuci贸n +detect_distro() { + if [ -f /etc/os-release ]; then + . /etc/os-release + DISTRO=$ID + elif type lsb_release >/dev/null 2>&1; then + DISTRO=$(lsb_release -si | tr '[:upper:]' '[:lower:]') + elif [ -f /etc/lsb-release ]; then + . /etc/lsb-release + DISTRO=$DISTRIB_ID + elif [ -f /etc/debian_version ]; then + DISTRO="debian" + else + DISTRO=$(uname -s) + fi + + echo "${ghmsg_006} $DISTRO" +} + +# Funci贸n para instalar GitHub CLI en sistemas basados en Debian/Ubuntu +install_gh_debian() { + echo "${ghmsg_007}" + + # A帽adir repositorio de GitHub CLI + type -p curl >/dev/null || apt update && apt install curl -y + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ + && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ + && apt update \ + && apt install gh -y + + if [ $? -eq 0 ]; then + echo "${ghmsg_008}" + else + echo "${ghmsg_009}" + exit 1 + fi +} + +# Funci贸n para instalar GitHub CLI en sistemas basados en Red Hat/Fedora +install_gh_redhat() { + echo "${ghmsg_010}" + + # A帽adir repositorio de GitHub CLI + dnf install -y dnf-plugins-core + dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo + dnf install -y gh + + if [ $? -eq 0 ]; then + echo "${ghmsg_008}" + else + echo "${ghmsg_009}" + exit 1 + fi +} + +# Funci贸n para instalar GitHub CLI en Arch Linux +install_gh_arch() { + echo "${ghmsg_011}" + + # Instalar GitHub CLI desde los repositorios oficiales + pacman -Sy --noconfirm gh + + if [ $? -eq 0 ]; then + echo "${ghmsg_008}" + else + echo "${ghmsg_009}" + exit 1 + fi +} + +# Funci贸n para instalar GitHub CLI en sistemas basados en SUSE +install_gh_suse() { + echo "${ghmsg_012}" + + # A帽adir repositorio de GitHub CLI + zypper addrepo --refresh https://cli.github.com/packages/rpm/gh-cli.repo + zypper install -y gh + + if [ $? -eq 0 ]; then + echo "${ghmsg_008}" + else + echo "${ghmsg_009}" + exit 1 + fi +} + +# Funci贸n para instalar GitHub CLI en macOS +install_gh_macos() { + echo "${ghmsg_013}" + + # Verificar si Homebrew est谩 instalado + if ! command -v brew &> /dev/null; then + echo "${ghmsg_014}" + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + fi + + # Instalar GitHub CLI + brew install gh + + if [ $? -eq 0 ]; then + echo "${ghmsg_008}" + else + echo "${ghmsg_009}" + exit 1 + fi +} + +# Funci贸n para verificar si gh est谩 instalado +check_gh() { + if command -v gh &> /dev/null; then + echo "${ghmsg_015}" + echo "${ghmsg_016}" + gh --version + read -p "${ghmsg_017} " REINSTALL + if [[ ! "$REINSTALL" =~ ^[Ss]$ ]]; then + echo "${ghmsg_018}" + exit 0 + fi + fi +} + +# Funci贸n principal +main() { + # Verificar si ya est谩 instalado + check_gh + + # Verificar privilegios de root (excepto en macOS) + if [ "$(uname -s)" != "Darwin" ]; then + check_root "$@" + fi + + # Detectar la distribuci贸n + detect_distro + + # Instalar seg煤n la distribuci贸n + case $DISTRO in + ubuntu|debian|linuxmint|pop|elementary) + install_gh_debian + ;; + fedora|rhel|centos|rocky|almalinux) + install_gh_redhat + ;; + arch|manjaro|endeavouros) + install_gh_arch + ;; + opensuse*|suse|sles) + install_gh_suse + ;; + darwin) + install_gh_macos + ;; + *) + echo "${ghmsg_019} $DISTRO" + echo "${ghmsg_020}" + exit 1 + ;; + esac + + # Verificar la instalaci贸n + if command -v gh &> /dev/null; then + echo "${ghmsg_008}" + gh --version + + # Sugerir autenticaci贸n + echo "" + echo "${ghmsg_021}" + echo "gh auth login" + echo "" + echo "${ghmsg_022}" + else + echo "${ghmsg_023}" + exit 1 + fi +} + +# Ejecutar funci贸n principal +main "$@" + +exit 0 +# Importar bibliotecas necesarias +source "${BIN_HOME}/${BIN_BASE}/${BIN_LIBS}/base.lib" + +# Cargar mensajes en el idioma del sistema o espa帽ol por defecto +load_messages "${BIN_HOME}/${BIN_BASE}" "${BIN_MESG}" "${BIN_LANG}" "head" + +# Variables globales +title="${head_000} ${head_002}" diff --git a/bin/msg/developers.es b/bin/msg/developers.es index 6f43a74..334d749 100644 --- a/bin/msg/developers.es +++ b/bin/msg/developers.es @@ -112,3 +112,29 @@ fgmsg_013="Cerrando sesi贸n de Forgejo..." fgmsg_014="No hay sesi贸n activa en Forgejo." fgmsg_015="Sesi贸n cerrada." +# Mensajes para ghadmin_install.sh +ghmsg_000="INSTALADOR DE GITHUB CLI" +ghmsg_001="Este script requiere privilegios de administrador." +ghmsg_002="Intentando escalar privilegios..." +ghmsg_003="Usando sudo para escalar privilegios..." +ghmsg_004="Usando doas para escalar privilegios..." +ghmsg_005="ERROR: No se encontr贸 sudo ni doas. Por favor ejecute este script como root." +ghmsg_006="Distribuci贸n detectada:" +ghmsg_007="Instalando GitHub CLI en sistema basado en Debian/Ubuntu..." +ghmsg_008="GitHub CLI instalado correctamente." +ghmsg_009="ERROR: No se pudo instalar GitHub CLI." +ghmsg_010="Instalando GitHub CLI en sistema basado en Red Hat/Fedora..." +ghmsg_011="Instalando GitHub CLI en Arch Linux..." +ghmsg_012="Instalando GitHub CLI en sistema basado en SUSE..." +ghmsg_013="Instalando GitHub CLI en macOS..." +ghmsg_014="Homebrew no est谩 instalado. Instalando Homebrew..." +ghmsg_015="GitHub CLI ya est谩 instalado." +ghmsg_016="Versi贸n actual:" +ghmsg_017="驴Desea reinstalar o actualizar? (s/n):" +ghmsg_018="Operaci贸n cancelada." +ghmsg_019="Distribuci贸n no soportada:" +ghmsg_020="Por favor, visite https://github.com/cli/cli#installation para instrucciones de instalaci贸n manual." +ghmsg_021="Para autenticarse con GitHub, ejecute:" +ghmsg_022="Para m谩s informaci贸n, visite: https://cli.github.com/manual/" +ghmsg_023="ERROR: La instalaci贸n de GitHub CLI fall贸." +