diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2020-10-24 01:54:03 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2020-10-24 11:42:28 +0200 |
commit | 084fdc10f7e861ce6e83120dc099d2416904af55 (patch) | |
tree | a309b4a76f02fd23ff0817281362e31456fb3ce6 /server/bin | |
parent | 4972d15ecd21a6f8dfe6f8451d19ac678fa2865b (diff) |
#988 Fix setserveraddr json handling
setserveraddr script modified ogserver.json values with "sed". This
caused unwanted changes in database.ip.
This commit replaces "sed" with "jq" for modifying ogserver.json,
ensuring only rest.ip and wol.interface values change.
Diffstat (limited to 'server/bin')
-rwxr-xr-x | server/bin/setserveraddr | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/server/bin/setserveraddr b/server/bin/setserveraddr index b9249af7..6694e3c4 100755 --- a/server/bin/setserveraddr +++ b/server/bin/setserveraddr @@ -88,13 +88,11 @@ if [ -n "$SERVERIP" ]; then OLDSERVERIP=$ServidorAdm # Checking if configuration files need to be modified. CHANGE=0 - for f in $OPENGNSYS/{etc/ogserver.json,etc/ogAdmRepo.cfg,www/controlacceso.php}; do + for f in $OPENGNSYS/{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. @@ -105,6 +103,18 @@ if [ -n "$SERVERIP" ]; then fi done + f="$OPENGNSYS"/etc/ogserver.json + file="${f/./-$SERVERDEV.}" + step_one=$(mktemp) + jq --arg ip "$SERVERIP" '.rest.ip = $ip' "$file" > "$step_one" + step_two=$(mktemp) + jq --arg iface "$SERVERDEV" '.wol.interface = $iface' "$step_one" > "$step_two" + if [ ! "$f" -ef "$file" ] || ! diff -q "$step_two" "$file" &>/dev/null; then + cp "$step_two" "$file" + ln -f "$file" "$f" + CHANGE=1 + fi + # Processing when something has changed. if [ $CHANGE == 1 ]; then # Config ogClient. |