From e7ffae8cc5081f7780b82beac7e7034ae328990b Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Tue, 3 Nov 2020 09:57:39 +0000 Subject: #988 Add ogserver.json creation when running opengnsys_update.sh This patch enables the creation of a default json config for the ogserver when running opengnsys_update.sh, if no prior json config is detected. Eg. when updating from 1.1.1c to 1.2.0 Reviewed-by: Jose M. Guisado --- installer/opengnsys_update.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'installer') diff --git a/installer/opengnsys_update.sh b/installer/opengnsys_update.sh index 0f48d04b..d7ee7d37 100755 --- a/installer/opengnsys_update.sh +++ b/installer/opengnsys_update.sh @@ -1089,7 +1089,28 @@ function ogServerCompilation() popd # Renaming OpenGnsys Server configuration file, if needed [ -e $INSTALL_TARGET/etc/ogAdmServer.cfg ] && \ - mv -v $INSTALL_TARGET/etc/ogAdmServer.cfg $INSTALL_TARGET/etc/ogserver.cfg + rm -f $INSTALL_TARGET/etc/ogAdmServer.cfg + [ -e $INSTALL_TARGET/etc/ogserver.cfg ] && \ + rm -f $INSTALL_TARGET/etc/ogserver.cfg + if [ ! -e $INSTALL_TARGET/etc/ogserver.json ]; then + echo "{ + \"rest\" : { + \"ip\" : \"$ServidorAdm\", + \"port\" : \"8888\", + \"api_token\": \"$APITOKEN\" + }, + \"database\" : { + \"ip\": \"$datasource\", + \"port\": \"3306\", + \"name\" : \"$CATALOG\", + \"user\" : \"$USUARIO\", + \"pass\" : \"$PASSWORD\" + }, + \"wol\" : { + \"interface\" : \"$INTERFACE\" + } + }" | jq '.' > "$INSTALL_TARGET"/etc/ogserver.json + fi # Remove old OpenGnsys services for serv in ogAdmAgent ogAdmRepo ogAdmServer; do pgrep $serv > /dev/null && pkill -9 $serv && \ @@ -1100,8 +1121,8 @@ function ogServerCompilation() fi done # Generating an ogServer API token, if it does not exist - grep -q "APITOKEN=" $INSTALL_TARGET/etc/ogserver.cfg || \ - $INSTALL_TARGET/bin/settoken -f + [ -z "$APITOKEN" ] && \ + $INSTALL_TARGET/bin/settoken -f # Updating service file, if needed if ! diff -q \ "$WORKDIR"/ogServer-"$BRANCH"/cfg/ogserver.service \ -- cgit v1.2.3-18-g5258