summaryrefslogtreecommitdiffhomepage
path: root/tools/unitc
diff options
context:
space:
mode:
authorLiam Crilly <liam.crilly@nginx.com>2023-10-18 22:26:13 +0100
committerLiam Crilly <liam.crilly@nginx.com>2023-10-18 22:26:13 +0100
commitd51f7def1442ff7519e14263559e3483a9a28f93 (patch)
treed933a53571da9a83156b7871c24e714418f56971 /tools/unitc
parent5265b7e0580edee488c07e0cc2953d88ae2aed1b (diff)
downloadunit-d51f7def1442ff7519e14263559e3483a9a28f93.tar.gz
unit-d51f7def1442ff7519e14263559e3483a9a28f93.tar.bz2
Tools: unitc remote mode edit fix.
Previously, the edit method created a temporary file that was then sent to curl(1) as --data-binary @filename.tmp. This did not work with remote instances because the temporary file is not on the remote host. The edit method now passes the configuration to curl(1) using stdin, the same way as for all other configuration changes.
Diffstat (limited to 'tools/unitc')
-rwxr-xr-xtools/unitc4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/unitc b/tools/unitc
index e671f384..4ab5f663 100755
--- a/tools/unitc
+++ b/tools/unitc
@@ -271,7 +271,7 @@ if [ -t 0 ] && [ ${#CONF_FILES[@]} -eq 0 ]; then
$RPC_CMD curl -X DELETE $UNIT_CTRL/config/settings/js_module && \
$RPC_CMD curl -fsSX DELETE $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \
printf "%s" "$(< $EDIT_FILENAME.js)" | $RPC_CMD curl -fX PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \
- $RPC_CMD curl -X PUT --data-binary @/tmp/${0##*/}.$$_js_module $UNIT_CTRL/config/settings/js_module 2> /tmp/${0##*/}.$$
+ cat /tmp/${0##*/}.$$_js_module | $RPC_CMD curl -X PUT --data-binary @- $UNIT_CTRL/config/settings/js_module 2> /tmp/${0##*/}.$$
elif [ $CONVERT -eq 1 ]; then
$CONVERT_FROM_JSON < $EDIT_FILENAME > $EDIT_FILENAME.yaml
$EDITOR $EDIT_FILENAME.yaml || exit 2
@@ -279,7 +279,7 @@ if [ -t 0 ] && [ ${#CONF_FILES[@]} -eq 0 ]; then
else
tr -d '\r' < $EDIT_FILENAME > $EDIT_FILENAME.json # Remove carriage-return from newlines
$EDITOR $EDIT_FILENAME.json || exit 2
- $RPC_CMD curl -X PUT --data-binary @$EDIT_FILENAME.json $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT
+ cat $EDIT_FILENAME.json | $RPC_CMD curl -X PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT
fi
else
SHOW_LOG=$(echo $URI | grep -c ^/control/)