diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2020-10-19 13:38:11 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2020-10-22 12:50:37 +0200 |
commit | 4972d15ecd21a6f8dfe6f8451d19ac678fa2865b (patch) | |
tree | 9cf270d2e9c9522a0f4590864082c14f96999a63 /server/bin/setserveraddr | |
parent | a0dd47a79ca4d5a06979fe22827bf7d4ea178fb7 (diff) |
#988 Read json config file in scripts
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 <jsanchez@soleta.eu>
Diffstat (limited to 'server/bin/setserveraddr')
-rwxr-xr-x | server/bin/setserveraddr | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/server/bin/setserveraddr b/server/bin/setserveraddr index b5092ae5..b9249af7 100755 --- a/server/bin/setserveraddr +++ b/server/bin/setserveraddr @@ -33,7 +33,7 @@ source $OPENGNSYS/lib/ogfunctions.sh || exit 1 [ "$USER" != "root" ] && raiseError access "Need to be root" [ $# -ne 1 ] && raiseError usage [ -r $DEFAULTFILE ] || raiseError access "Cannot read default configuration file" -for f in $OPENGNSYS/{etc/{ogserver,ogAdmRepo}.cfg,www/controlacceso.php,client/ogClient/cfg/ogclient.json}; do +for f in $OPENGNSYS/{etc/ogserver.json,etc/ogAdmRepo.cfg,www/controlacceso.php,client/ogClient/cfg/ogclient.json}; do [ -w $f ] || raiseError access "Cannot write to file: $f" done @@ -84,15 +84,17 @@ if [ -n "$SERVERIP" ]; then fi # Saving old IP address. - source $OPENGNSYS/etc/ogserver.cfg + source_json_config $OPENGNSYS/etc/ogserver.json OLDSERVERIP=$ServidorAdm # Checking if configuration files need to be modified. CHANGE=0 - for f in $OPENGNSYS/{etc/{ogserver,ogAdmRepo}.cfg,www/controlacceso.php}; do + for f in $OPENGNSYS/{etc/ogserver.json,etc/ogAdmRepo.cfg,www/controlacceso.php}; do # Updating configuration variables (if URL does not contain "localhost"). sed -e "s,\(ServidorAdm\|IPlocal\)=.*,\1=$SERVERIP," \ -e "s,^INTERFACE=.*,INTERFACE=$SERVERDEV," \ -e "s,UrlMenu=https?://\([^/]*\)/\(.*\),UrlMenu=https://$SERVERIP/\2," \ + -e "s/\"ip\": \".*\"/\"ip\": \"$SERVERIP\"/" $SERVERCFG \ + -e "s/\"interface\": \".*\"/\"interface\": \"$SERVERDEV\"/" $SERVERCFG \ -e '/localhost/!s,https\?://[^/]*/\(.*\),https://'$SERVERIP'/\1,' $f >$tmpfile file="${f/./-$SERVERDEV.}" # Copying updated file, if needed. |