From 4972d15ecd21a6f8dfe6f8451d19ac678fa2865b Mon Sep 17 00:00:00 2001 From: Roberto Hueso Gómez Date: Mon, 19 Oct 2020 13:38:11 +0200 Subject: #988 Read json config file in scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch implements the function source_json_config() that is used to read the new ogserver.json config file in the scripts. This replaces the old 'source .../ogserver.cfg'. Co-authored-by: Javier Sánchez Parra --- installer/opengnsys_export.sh | 6 ++++-- installer/opengnsys_import.sh | 5 +++-- installer/opengnsys_update.sh | 7 ++++++- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'installer') diff --git a/installer/opengnsys_export.sh b/installer/opengnsys_export.sh index 67ad008e..1fe7e081 100755 --- a/installer/opengnsys_export.sh +++ b/installer/opengnsys_export.sh @@ -57,7 +57,7 @@ if ! which realpath &>/dev/null ; then fi # Comprobamos acceso a ficheros de configuración -if ! [ -r $OPENGNSYS/etc/ogserver.cfg ]; then +if ! [ -r $OPENGNSYS/etc/ogserver.json ]; then echo "$PROG: ERROR: Sin acceso a la configuración de OpenGnsys." | tee -a $FILESAL exit 3 fi @@ -74,7 +74,9 @@ done # Exportar la base de datos echo "Exportamos la información de la base de datos." -source $OPENGNSYS/etc/ogserver.cfg +source $OPENGNSYS/lib/ogfunctions.sh || exit 1 +source_json_config $OPENGNSYS/etc/ogserver.json + # Crear fichero temporal de acceso a la BD MYCNF=$(mktemp /tmp/.my.cnf.XXXXX) chmod 600 $MYCNF diff --git a/installer/opengnsys_import.sh b/installer/opengnsys_import.sh index 0962e34b..d49c3312 100755 --- a/installer/opengnsys_import.sh +++ b/installer/opengnsys_import.sh @@ -278,7 +278,7 @@ if ! [ -r $BACKUPFILE ]; then fi # Comprobamos acceso a ficheros de configuración -if ! [ -r $OPENGNSYS/etc/ogserver.cfg ]; then +if ! [ -r $OPENGNSYS/etc/ogserver.json ]; then echo "$PROG: ERROR: Sin acceso a la configuración de OpenGnsys." | tee -a $FILESAL exit 3 fi @@ -333,7 +333,8 @@ fi # MYSQL echo " * Importamos informacion mysql." -source $OPENGNSYS/etc/ogserver.cfg +source $OPENGNSYS/lib/ogfunctions.sh || exit 1 +source_json_config $OPENGNSYS/etc/ogserver.json # Crear fichero temporal de acceso a la BD if [ ! -r $MYCNF ]; then chmod 600 $MYCNF diff --git a/installer/opengnsys_update.sh b/installer/opengnsys_update.sh index bd689008..11c64a8e 100755 --- a/installer/opengnsys_update.sh +++ b/installer/opengnsys_update.sh @@ -52,8 +52,13 @@ if [ ! -d $INSTALL_TARGET ]; then echo "ERROR: OpenGnsys is not installed, cannot update!!" exit 1 fi + +source $INSTALL_TARGET/lib/ogfunctions.sh || exit 1 + # Cargar configuración de acceso a la base de datos. -if [ -r $INSTALL_TARGET/etc/ogserver.cfg ]; then +if [ -r $INSTALL_TARGET/etc/ogserver.json ]; then + source_json_config $INSTALL_TARGET/etc/ogserver.json +elif [ -r $INSTALL_TARGET/etc/ogserver.cfg ]; then source $INSTALL_TARGET/etc/ogserver.cfg elif [ -r $INSTALL_TARGET/etc/ogAdmServer.cfg ]; then source $INSTALL_TARGET/etc/ogAdmServer.cfg -- cgit v1.2.3-18-g5258