Skip to content

Commit d51f7de

Browse files
committed
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.
1 parent 5265b7e commit d51f7de

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/unitc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,15 @@ if [ -t 0 ] && [ ${#CONF_FILES[@]} -eq 0 ]; then
271271
$RPC_CMD curl -X DELETE $UNIT_CTRL/config/settings/js_module && \
272272
$RPC_CMD curl -fsSX DELETE $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \
273273
printf "%s" "$(< $EDIT_FILENAME.js)" | $RPC_CMD curl -fX PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \
274-
$RPC_CMD curl -X PUT --data-binary @/tmp/${0##*/}.$$_js_module $UNIT_CTRL/config/settings/js_module 2> /tmp/${0##*/}.$$
274+
cat /tmp/${0##*/}.$$_js_module | $RPC_CMD curl -X PUT --data-binary @- $UNIT_CTRL/config/settings/js_module 2> /tmp/${0##*/}.$$
275275
elif [ $CONVERT -eq 1 ]; then
276276
$CONVERT_FROM_JSON < $EDIT_FILENAME > $EDIT_FILENAME.yaml
277277
$EDITOR $EDIT_FILENAME.yaml || exit 2
278278
$CONVERT_TO_JSON < $EDIT_FILENAME.yaml | $RPC_CMD curl -X PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT
279279
else
280280
tr -d '\r' < $EDIT_FILENAME > $EDIT_FILENAME.json # Remove carriage-return from newlines
281281
$EDITOR $EDIT_FILENAME.json || exit 2
282-
$RPC_CMD curl -X PUT --data-binary @$EDIT_FILENAME.json $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT
282+
cat $EDIT_FILENAME.json | $RPC_CMD curl -X PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT
283283
fi
284284
else
285285
SHOW_LOG=$(echo $URI | grep -c ^/control/)

0 commit comments

Comments
 (0)