summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorLiam Crilly <liam.crilly@nginx.com>2023-02-27 14:25:58 +0000
committerLiam Crilly <liam.crilly@nginx.com>2023-02-27 14:25:58 +0000
commitbbeccabe0a40c689466d97570e44829e3c1ddb3b (patch)
treebcb67d82a51c07f5eeda4507512cc62e82d3c10a /tools
parent5ed6eae7188f3da17c8805a26c9e3a6f2289329a (diff)
downloadunit-bbeccabe0a40c689466d97570e44829e3c1ddb3b.tar.gz
unit-bbeccabe0a40c689466d97570e44829e3c1ddb3b.tar.bz2
Tools: improved detection of unitd control socket.
Now unitc obtains the path to the unitd binary from information contained in the unitd: main process. If unitd was started with an explicit path then that path will be used to obtain the default control socket, instead of using the unitd binary in $PATH.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/unitc10
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/unitc b/tools/unitc
index bf12f111..71fef314 100755
--- a/tools/unitc
+++ b/tools/unitc
@@ -43,7 +43,7 @@ while [ $# -gt 0 ]; do
;;
*)
- if [ -r $1 ]; then
+ if [ -f $1 ] && [ -r $1 ]; then
CONF_FILES+=($1)
elif [ "${1:0:1}" = "/" ] || [ "${1:0:4}" = "http" ] && [ "$URI" = "" ]; then
URI=$1
@@ -121,9 +121,9 @@ if [ $REMOTE -eq 0 ]; then
if [ -r /tmp/${0##*/}.$PID.env ]; then
source /tmp/${0##*/}.$PID.env
else
- # Check we have unitd in $PATH (and all the other tools we will need)
+ # Check we have all the tools we will need (that we didn't already use)
#
- MISSING=$(hash unitd curl ps grep tr cut sed tail sleep 2>&1 | cut -f4 -d: | tr -d '\n')
+ MISSING=$(hash curl tr cut sed tail sleep 2>&1 | cut -f4 -d: | tr -d '\n')
if [ "$MISSING" != "" ]; then
echo "${0##*/}: ERROR: cannot find$MISSING: please install or add to \$PATH"
exit 1
@@ -131,10 +131,10 @@ if [ $REMOTE -eq 0 ]; then
# Get control address
#
- PARAMS=$(ps $PID | grep unitd | cut -f2- -dv | tr '[]' ' ' | cut -f4- -d ' ' | sed -e 's/ --/\n--/g')
+ PARAMS=$(ps $PID | grep unitd | cut -f2- -dv | tr '[]' ' ' | cut -f3- -d ' ' | sed -e 's/ --/\n--/g')
CTRL_ADDR=$(echo "$PARAMS" | grep '\--control' | cut -f2 -d' ')
if [ "$CTRL_ADDR" = "" ]; then
- CTRL_ADDR=$(unitd --help | grep -A1 '\--control' | tail -1 | cut -f2 -d\")
+ CTRL_ADDR=$(`echo "$PARAMS" | grep unitd` --help | grep -A1 '\--control' | tail -1 | cut -f2 -d\")
fi
# Prepare for network or Unix socket addressing