diff options
author | Alejandro Colomar <alx@kernel.org> | 2024-02-09 00:26:47 +0100 |
---|---|---|
committer | Alejandro Colomar <alx@kernel.org> | 2024-02-20 16:04:24 +0100 |
commit | 565a8ed0183718deb4e14b3b3d67417db4a8092a (patch) | |
tree | f8a524d93b0319d5ba75d881d757bae1476bb62b /tools/setup-unit | |
parent | e9a0c49dbca628d8bfa6dbc8819846881b16b8b0 (diff) | |
download | unit-565a8ed0183718deb4e14b3b3d67417db4a8092a.tar.gz unit-565a8ed0183718deb4e14b3b3d67417db4a8092a.tar.bz2 |
Tools: setup-unit: ctl edit: Print file name on error
When editing the configuration in-place, it's easy to make a mistake.
If the configuration is wrong, it will be passed to the control socket,
which will reject it, keeping the old configuration. Those manual edits
would be lost, which can make it very uncomfortable to edit in-place.
By printing the name of the temporary file, we allow the user to recover
the changes.
Cc: Liam Crilly <liam@nginx.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'tools/setup-unit')
-rwxr-xr-x | tools/setup-unit | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/setup-unit b/tools/setup-unit index 48e5c998..0df19070 100755 --- a/tools/setup-unit +++ b/tools/setup-unit @@ -138,6 +138,11 @@ OPTIONS __EOF__ } +info() +{ + >&2 echo "$(basename "$0"): info: $*"; +} + warn() { >&2 echo "$(basename "$0"): error: $*"; @@ -430,7 +435,11 @@ unit_ctl_edit() || echo ed; ) "$tmp"; + trap "info 'ctl: edit: Invalid configuration saved in <$tmp>.'" ERR + unit_ctl_http ---s "$sock" PUT "$req_path" <"$tmp"; + + trap - ERR; } |