196 lines
4.1 KiB
Bash
196 lines
4.1 KiB
Bash
|
#!/bin/bash
|
||
|
#
|
||
|
# profile_restore.sh
|
||
|
# Modified: 2024/12/15 14:27:00
|
||
|
# Derechos de Autor (C) [2024] [Mauro Rosero P. <mauro@roser.one>]
|
||
|
#
|
||
|
# 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 <https://www.gnu.org/licenses/>.
|
||
|
|
||
|
DEVSPATH=devs
|
||
|
BIN_HOME=$HOME/$DEVSPATH
|
||
|
BIN_MESG=bin/msg
|
||
|
BIN_LIBS=bin/lib
|
||
|
VERSION=0.98.0
|
||
|
|
||
|
# CHECK SHELL LANGUAGE
|
||
|
BIN_LANG=${LANG:0:2}
|
||
|
|
||
|
# LOAD BASE BASH LIBRARY
|
||
|
source $BIN_HOME/$BIN_LIBS/base.lib
|
||
|
#baselib_test
|
||
|
|
||
|
# LOAD CONSOLE BASH LIBRARY
|
||
|
source $BIN_HOME/$BIN_LIBS/console.lib
|
||
|
#consolelib_test
|
||
|
|
||
|
# LOAD SQLITE3 BASH LIBRARY
|
||
|
source $BIN_HOME/$BIN_LIBS/sqlite.lib
|
||
|
#sqlitelib_test
|
||
|
|
||
|
# 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 developers messages
|
||
|
load_messages $BIN_HOME $BIN_MESG $BIN_LANG "developers"
|
||
|
|
||
|
# Function to display help message
|
||
|
function help() {
|
||
|
echo "$dvmsg_101_1 $0 $dvmsg_101_2"
|
||
|
echo "$dvmsg_101_0 $VERSION"
|
||
|
echo "$dvmsg_102"
|
||
|
echo "$dvmsg_103"
|
||
|
echo "$dvmsg_104"
|
||
|
echo "$dvmsg_105"
|
||
|
echo "$dvmsg_106"
|
||
|
echo "$dvmsg_107"
|
||
|
}
|
||
|
|
||
|
|
||
|
########### MAIN PROGRAM ###########
|
||
|
|
||
|
# Set program title
|
||
|
title="$head_000 $head_002"
|
||
|
apps_title="${gpmsg_001}"
|
||
|
|
||
|
# Check if dialog is not installed, exited!
|
||
|
command_installed "dialog"
|
||
|
if [ $? -ne 0 ]
|
||
|
then
|
||
|
display_devstools_header "${gpmsg_001}"
|
||
|
echo "${head_001}"
|
||
|
exit 200
|
||
|
fi
|
||
|
|
||
|
# Check if os is valid!
|
||
|
get_osname
|
||
|
if [ "${os_name}" == "${head_unknow}" ]
|
||
|
then
|
||
|
dialog_error_box "${head_error}" "${head_os_error}"
|
||
|
exit 3
|
||
|
fi
|
||
|
|
||
|
command_installed "zip"
|
||
|
if [ $? -ne 0 ]; then
|
||
|
dialog_error_box "${head_error}" "${head_zip}"
|
||
|
exit 9
|
||
|
fi
|
||
|
|
||
|
# Check for arguments option
|
||
|
help=false
|
||
|
version=false
|
||
|
update=false
|
||
|
while [[ $# -gt 0 ]]; do
|
||
|
case $1 in
|
||
|
--help)
|
||
|
help=true
|
||
|
shift
|
||
|
;;
|
||
|
--version)
|
||
|
version=true
|
||
|
shift
|
||
|
;;
|
||
|
*)
|
||
|
if [[ -z $BACKUP_ZIPFILE ]]; then
|
||
|
BACKUP_ZIPFILE="$1"
|
||
|
shift
|
||
|
else
|
||
|
help
|
||
|
exit 1
|
||
|
fi
|
||
|
;;
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
# Check to show help
|
||
|
if $help; then
|
||
|
help
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
# Check to show command version
|
||
|
if $version; then
|
||
|
display_devstools_header ""
|
||
|
echo "$0"
|
||
|
echo "${dvmsg_101_0} $VERSION"
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
# Check for empty project path
|
||
|
if [[ -z $BACKUP_ZIPFILE ]]; then
|
||
|
help
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
BASEZIPFILE=$(basename $BACKUP_ZIPFILE)
|
||
|
|
||
|
# Developer Profile Restore
|
||
|
dialog_yesno "${gpmsg_113} $BASEZIPFILE?"
|
||
|
case ${result} in
|
||
|
0)
|
||
|
developer_restore "$BIN_HOME/$GPG_CONFIG_PATH" "$BACKUP_ZIPFILE"
|
||
|
rc=$?
|
||
|
case $rc in
|
||
|
0)
|
||
|
dialog_error_box "${head_info}" "${gpmsg_114}"
|
||
|
clear
|
||
|
exit 0
|
||
|
;;
|
||
|
10)
|
||
|
dialog_error_box "${head_error}" "${gpmsg_107}"
|
||
|
clear
|
||
|
exit $rc
|
||
|
;;
|
||
|
11)
|
||
|
dialog_error_box "${head_error}" "${gpmsg_108}"
|
||
|
clear
|
||
|
exit $rc
|
||
|
;;
|
||
|
13)
|
||
|
dialog_error_box "${head_error}" "${gpmsg_109}"
|
||
|
clear
|
||
|
exit $rc
|
||
|
;;
|
||
|
14)
|
||
|
dialog_error_box "${head_error}" "${gpmsg_111}"
|
||
|
clear
|
||
|
exit $rc
|
||
|
;;
|
||
|
15)
|
||
|
dialog_error_box "${head_error}" "${gpmsg_112}"
|
||
|
clear
|
||
|
exit $rc
|
||
|
;;
|
||
|
18)
|
||
|
dialog_error_box "${head_error}" "${gpmsg_110}"
|
||
|
clear
|
||
|
exit $rc
|
||
|
;;
|
||
|
*)
|
||
|
dialog_error_box "${head_error}" "${head_op_error} (${rc})"
|
||
|
exi $rc
|
||
|
;;
|
||
|
esac
|
||
|
;;
|
||
|
*)
|
||
|
dialog_error_box "${head_error}" "${head_op_error}"
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
# End Main Program
|
||
|
clear
|