From 6210bd07f31bfade668c8f0b86c58019e0f4fa29 Mon Sep 17 00:00:00 2001 From: Mauro Rosero P Date: Sat, 14 Dec 2024 16:20:43 -0500 Subject: [PATCH] =?UTF-8?q?[MODIFIED]=20Cambio=20para=20manejo=20de=20perf?= =?UTF-8?q?il=20de=20desarrollador=20-=20Se=20cambia=20la=20libreria=20gpg?= =?UTF-8?q?=20a=20developers=20-=20Se=20cambia=20el=20comando=20gpg=5Fback?= =?UTF-8?q?up.sh=20a=20profile=5Fbackup.sh=20-=20Se=20hacen=20mejoras=20a?= =?UTF-8?q?=20la=20documentaci=C3=B3n=20del=20sistema=20-=20El=20respaldo?= =?UTF-8?q?=20ahora=20incluye=20las=20carpetas=20.ssh,=20.gnugp=20y=20.git?= =?UTF-8?q?config=20del=20usuario=20-=20Otros=20cambios=20menores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 17 ++-- bin/lib/base.lib | 1 + bin/lib/bootstrap.lib | 3 +- bin/lib/console.lib | 1 + bin/lib/{gpg.lib => developers.lib} | 99 ++++++++++++++++++++---- bin/lib/sqlite.lib | 5 +- bin/msg/bootstrap.es | 4 +- bin/msg/container.es | 4 +- bin/msg/{gpg.es => developers.es} | 6 +- bin/msg/head.es | 4 +- bin/{gpg_backup.sh => profile_backup.sh} | 8 +- 11 files changed, 111 insertions(+), 41 deletions(-) rename bin/lib/{gpg.lib => developers.lib} (68%) rename bin/msg/{gpg.es => developers.es} (90%) rename bin/{gpg_backup.sh => profile_backup.sh} (95%) diff --git a/README.md b/README.md index 6f5a39b..ea0a723 100644 --- a/README.md +++ b/README.md @@ -45,26 +45,19 @@ Nota: En determinadas versiones, las actualizaciones a partir de los repositorio (pendiente) -### GESTIONANDO FIRMA GPG +### GESTIONANDO PERIFL DE DESARROLLADOR -#### Inicialización de configuración GPG +#### Configuración por defecto de comportamineto GPG -Como un requisito de nuestra plataforma, todos los desarrolladores deberán contar, por lo menos, con una clave GPG, que se utilizará para firmar o decifrar archivos, correos u otros. Esto se hará con el uso del comando gpg (previamente instalado con la ejecución de bin/boostrap.sh). - -En este paso estableceremos la configuración por defecto de GPG: +En la carpeta $HOME/devs/bin/config existe un archivo de configuración gpg.config que contiene los parámetros de comportamiento por defecto para GNUGP que son los recomendados para el uso de la plataforma. Si tienes alguno en uso, está función le sacará previamente una copia y aplicará el de la plataforma siguiendo los siguientes pasos: $ cd $HOME/devs $ bin/gpg_init.sh -#### Creación de clave GPG +#### Copia de básica del perfil del desarrollador -(pendiente) - -#### Copia de seguridad de claves GPG - -Para realizar una copia de seguridad de su configuración y claves GPG, haga lo siguiente: +Para realizar una copia de seguridad de sus configuraciones de desarrollador que involucran claves GPG, claves SSH, configuración GIT y otros, ejecute los siguientes comandos: $ cd $HOME/devs $ bin/gpg_backup.sh -Nota: Esto creará una carpeta por defecto $HOME/secure/backups donde se almacenaran los backups corresponidentes. Solo se requiere se hagan backups cuando se hagan cambios a las claves GPG. diff --git a/bin/lib/base.lib b/bin/lib/base.lib index ebaee1b..6a68dd0 100644 --- a/bin/lib/base.lib +++ b/bin/lib/base.lib @@ -1,6 +1,7 @@ #!/bin/bash # # Library: base.lib +# Description: Base Developers Library # Modified: 2024/11/30 15:27:00 # Derechos de Autor (C) [2024] [Mauro Rosero P. ] # diff --git a/bin/lib/bootstrap.lib b/bin/lib/bootstrap.lib index bf463be..d7e1cea 100755 --- a/bin/lib/bootstrap.lib +++ b/bin/lib/bootstrap.lib @@ -1,6 +1,7 @@ #!/bin/bash # -# Library: $HOME/devs/bin/lib/bootstrap.lib +# Library: bootstrap.lib +# Description: Bootstrap Developers Library # Modified: 2024/11/30 15:27:00 # Derechos de Autor (C) [2024] [Mauro Rosero P. ] # diff --git a/bin/lib/console.lib b/bin/lib/console.lib index d4b1c13..33ca0ca 100755 --- a/bin/lib/console.lib +++ b/bin/lib/console.lib @@ -1,6 +1,7 @@ #!/bin/bash # # Library: console.lib +# Description: Console Developers Library # Modified: 2024/12/04 12:27:00 # Derechos de Autor (C) [2024] [Mauro Rosero P. ] # diff --git a/bin/lib/gpg.lib b/bin/lib/developers.lib similarity index 68% rename from bin/lib/gpg.lib rename to bin/lib/developers.lib index 2ddb36d..d6d7d6d 100644 --- a/bin/lib/gpg.lib +++ b/bin/lib/developers.lib @@ -1,6 +1,7 @@ #!/bin/bash # -# Library: gpg.lib +# Library: developers.lib +# Description: Developers Tools Library # Modified: 2024/12/09 08:20:00 # Derechos de Autor (C) [2024] [Mauro Rosero P. ] # @@ -34,8 +35,8 @@ SQL_GPG_SUBKEYS="${DB_GPG_SUBKEYS}.sql" # Test library -function gpglib_test() { - echo "GPG Library loaded!" +function devslib_test() { + echo "Developers Library loaded!" exit 1 } @@ -88,7 +89,7 @@ function gpg_backup_token() { if [[ ! -e $archivo_token ]] then - local BACKUP_TOKEN=$(uuidgen) + local BACKUP_TOKEN=$(uuidgen | base64 ) echo "$BACKUP_TOKEN" > "$SECRET_FILE" chmod 600 "$SECRET_FILE" fi @@ -97,7 +98,7 @@ function gpg_backup_token() { } -# Local backup of gpp keys +# FULL EXTENDED GNUGP BACKUP function gpg_backup() { local DB_BACKUP=$1 @@ -109,7 +110,7 @@ function gpg_backup() { # Check if backup configuration file exists if [ ! -f $BIN_CONFIG/$GPG_BACKUP_CFG ] then - return 10 + return 10 fi local LOCAL_BACKUP=$HOME/$(cat < $BIN_CONFIG/$GPG_BACKUP_CFG) @@ -131,12 +132,12 @@ function gpg_backup() { gpg_backup_token "${LOCAL_BACKUP}/$GPGP_BACKUP_SECRET" # Get secret backup - ZPASSWORD=$(cat < "${LOCAL_BACKUP}/$GPGP_BACKUP_SECRET") + ZPASSWORD=$(echo "$(cat < "${LOCAL_BACKUP}/$GPGP_BACKUP_SECRET")" | base64 -d) if [ -z "${ZPASSWORD}" ]; then - return 13 + return 13 fi - # Exportar el anillo de claves GPG a un archivo de respaldo temporal + # Export full backup keys to backup work path local TMP_PATH=$(mktemp -d) local TMP_FILE="gpg.bak" gpg --export-options backup -o "${TMP_PATH}/${TMP_FILE}" --export @@ -157,10 +158,10 @@ function gpg_backup() { return $rc fi - # Copiar los archivos de revocación - mkdir ${TMP_PATH}/gnugp + # Copy full .gnugp for backup + mkdir ${TMP_PATH}/.gnugp if [ $? -eq 0 ]; then - cp -rf $GNUGP_PATH/* ${TMP_PATH}/gnugp + cp -rf $GNUGP_PATH/* ${TMP_PATH}/.gnugp rc=$? if [ $rc -ne 0 ] then @@ -169,7 +170,30 @@ function gpg_backup() { fi fi - # Cambiar el directorio de trabajo a la carpeta temporal para poder hacer el empaquetamiento zip + # Copy full .ssh for backup + mkdir ${TMP_PATH}/.ssh + if [ $? -eq 0 ]; then + cp -rf $HOME/.ssh/* ${TMP_PATH}/.ssh + rc=$? + if [ $rc -ne 0 ] + then + rm -rf "${TMP_PATH}" + return $rc + fi + fi + + # Copy .giconfig for user to backup + if [ -f $HOME/.gitconfig ]; then + cp -f $HOME/.gitconfig ${TMP_PATH}/ + rc=$? + if [ $rc -ne 0 ] + then + rm -rf "${TMP_PATH}" + return $rc + fi + fi + + # Change backup work path to make zip archive cd "${TMP_PATH}" # Comprimir el archivo de respaldo en un archivo ZIP protegido con contraseña @@ -186,3 +210,52 @@ function gpg_backup() { return 0 } + +# RESTORE .GNUGP PATH +function gpg_restore() { + + local BIN_CONFIG=$1 + local BACKUP_ZIP=$2 + + local rc=0 + + # Check provided backup zip filename + if [ -z "$BACKUP_ZIP" ]; then + return 10 + fi + + # Check if backup zip file exists + if [ ! -f "$BACKUP_ZIP" ] + then + return 11 + fi + + # Check if backup configuration file exists + if [ ! -f $BIN_CONFIG/$GPG_BACKUP_CFG ] + then + return 12 + fi + + local LOCAL_BACKUP=$HOME/$(cat < $BIN_CONFIG/$GPG_BACKUP_CFG) + + # Check if backup path exist + if [ -z "$LOCAL_BACKUP" ]; then + return 13 + fi + + # Get secret backup + ZPASSWORD=$(echo "$(cat < "${LOCAL_BACKUP}/$GPGP_BACKUP_SECRET")" | base64 -d) + if [ -z "${ZPASSWORD}" ]; then + return 14 + fi + + # Restore unzip full .gnugp path + unzip -qqo -P "$ZPASSWORD" "$BACKUP_ZIP" ".gnugp/*" -d $HOME + rc=$? + if [ $rc -ne 0 ]; then + return $rc + fi + + return 0 + +} diff --git a/bin/lib/sqlite.lib b/bin/lib/sqlite.lib index c3c9368..8b0b162 100644 --- a/bin/lib/sqlite.lib +++ b/bin/lib/sqlite.lib @@ -1,6 +1,7 @@ #!/bin/bash # # Library: sqlite.lib +# Description: SQLITE Developers Library # Modified: 2024/12/09 08:20:00 # Derechos de Autor (C) [2024] [Mauro Rosero P. ] # @@ -80,9 +81,9 @@ function sqlite_dump() { do # Check if table exists EXIST=$(sqlite3 $DATABASE "SELECT name FROM sqlite_master WHERE type='table' AND name='$TABLE';") - if [ "$EXIST" == "$TABLE" ]; then - sqlite3 "$DATABASE" .dump "$TABLE" >> "$DUMP_FILE" + clear + sqlite3 "$DATABASE" ".dump $TABLE" >> $DUMP_FILE rc=$? if [ $rc -gt 1 ]; then return $rc diff --git a/bin/msg/bootstrap.es b/bin/msg/bootstrap.es index 914ddc3..b7d2717 100644 --- a/bin/msg/bootstrap.es +++ b/bin/msg/bootstrap.es @@ -1,7 +1,7 @@ #!/usr/bin/env bash #bash script : bootstrap.es -#apps : Personal Developer Utilities -#description : Bootstrap Translate Messages (es) +#apps : Bootstrap Functions Library +#description : Translate Messages (es) #author : MRP/mrp - Mauro Rosero P. #company email : mauro@rosero.one #personal email : mauro.rosero@gmail.com diff --git a/bin/msg/container.es b/bin/msg/container.es index 393abb6..b8470bf 100644 --- a/bin/msg/container.es +++ b/bin/msg/container.es @@ -1,7 +1,7 @@ #!/usr/bin/env bash #bash script : container.es -#apps : Podman/Docker Container Developer Utilities -#description : Container Translate Messages (es) +#apps : Containers Functions Library +#description : Translate Messages (es) #author : MRP/mrp - Mauro Rosero P. #company email : mauro@rosero.one #personal email : mauro.rosero@gmail.com diff --git a/bin/msg/gpg.es b/bin/msg/developers.es similarity index 90% rename from bin/msg/gpg.es rename to bin/msg/developers.es index 39dcf2d..99227ed 100644 --- a/bin/msg/gpg.es +++ b/bin/msg/developers.es @@ -1,7 +1,7 @@ #!/usr/bin/env bash -#bash script : gpg.es -#apps : GPG Developer Utilities -#description : GPG Translate Messages (es) +#bash script : developers.es +#apps : Developers Functions Library +#description : Translate Messages (es) #author : MRP/mrp - Mauro Rosero P. #company email : mauro@rosero.one #personal email : mauro.rosero@gmail.com diff --git a/bin/msg/head.es b/bin/msg/head.es index 07accdd..94d8734 100644 --- a/bin/msg/head.es +++ b/bin/msg/head.es @@ -1,7 +1,7 @@ #!/usr/bin/env bash #bash script : head.es -#apps : MRosero Personal Developer Utilities -#description : Head Translate Messages (es) +#apps : Base Functions Library +#description : Translate Messages (es) #author : MRP/mrp - Mauro Rosero P. #company email : mauro@rosero.one #personal email : mauro.rosero@gmail.com diff --git a/bin/gpg_backup.sh b/bin/profile_backup.sh similarity index 95% rename from bin/gpg_backup.sh rename to bin/profile_backup.sh index e6ff86e..744fbd7 100755 --- a/bin/gpg_backup.sh +++ b/bin/profile_backup.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# gpg_backup.sh +# profile_backup.sh # Modified: 2024/12/09 10:27:00 # Derechos de Autor (C) [2024] [Mauro Rosero P. ] # @@ -37,15 +37,15 @@ source $BIN_HOME/$BIN_LIBS/console.lib source $BIN_HOME/$BIN_LIBS/sqlite.lib #sqlitelib_test -# LOAD GPG BASH LIBRARY -source $BIN_HOME/$BIN_LIBS/gpg.lib +# LOAD DEVELOPERS BASH LIBRARY +source $BIN_HOME/$BIN_LIBS/developers.lib #gpglib_test # Load head messages load_messages $BIN_HOME $BIN_MESG $BIN_LANG "head" # Load gpg messages -load_messages $BIN_HOME $BIN_MESG $BIN_LANG "gpg" +load_messages $BIN_HOME $BIN_MESG $BIN_LANG "developers"