Skip to content

Commit 789095b

Browse files
author
Artem Konev
committed
Tools: Updated built-in 'setup-unit' help, README.md command lines.
1 parent cf3ffb8 commit 789095b

File tree

2 files changed

+69
-70
lines changed

2 files changed

+69
-70
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ For a description of image tags, see the
5050
### Amazon Linux, Fedora, RedHat
5151

5252
``` console
53-
$ curl -sL 'https://unit.nginx.org/_downloads/setup-unit.sh' | sudo -E bash
54-
# yum install unit
53+
$ wget https://raw.githubusercontent.com/nginx/unit/master/tools/setup-unit && chmod +x setup-unit
54+
# ./setup-unit repo-config && yum install unit
55+
# ./setup-unit welcome
5556
```
5657

5758
For details and available language packages, see the
@@ -61,8 +62,9 @@ For details and available language packages, see the
6162
### Debian, Ubuntu
6263

6364
``` console
64-
$ curl -sL 'https://unit.nginx.org/_downloads/setup-unit.sh' | sudo -E bash
65-
# apt install unit
65+
$ wget https://raw.githubusercontent.com/nginx/unit/master/tools/setup-unit && chmod +x setup-unit
66+
# ./setup-unit repo-config && apt install unit
67+
# ./setup-unit welcome
6668
```
6769

6870
For details and available language packages, see the

tools/setup-unit

Lines changed: 63 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010

1111
if test -n ${BASH_VERSION} && test "${BASH_VERSINFO[0]}" -eq 3; then
12-
>&2 echo 'Your version of bash(1) is not supported by this script.';
13-
>&2 echo "You're probably running on MacOS. We recommend that you either";
14-
>&2 echo 'install a newer version of bash(1), or you run this script with';
15-
>&2 echo 'another shell, like for example zsh(1):';
12+
>&2 echo 'Your version of bash(1) isn't supported by this script.';
13+
>&2 echo "You're probably running on macOS. We recommend that you either";
14+
>&2 echo 'install a newer version of bash(1) or run this script with';
15+
>&2 echo 'another shell, such as zsh(1):';
1616
>&2 echo " $ zsh ${SUDO_USER:+sudo }$0 ...";
1717
exit 1;
1818
fi;
@@ -52,16 +52,16 @@ COMMANDS
5252
for later installation.
5353
5454
welcome
55-
Creates an initial configuration to serve a welcome web page
56-
for NGINX Unit.
55+
Create an initial configuration to serve a welcome web page
56+
with NGINX Unit.
5757
5858
OPTIONS
5959
-h, --help
6060
Print this help.
6161
6262
--help-more
63-
Print help for more commands. They are experimental. This is
64-
not recommended unless you know what you're doing.
63+
Print help for more commands. They are experimental. Using
64+
these isn't recommended, unless you know what you're doing.
6565
6666
__EOF__
6767
}
@@ -96,7 +96,7 @@ DESCRIPTION
9696
COMMANDS
9797
cmd Print the invocation line of unitd(8).
9898
99-
ctl Control a running unitd(8) instance through its control socket.
99+
ctl Control a running unitd(8) instance via its control API socket.
100100
101101
freeport
102102
Print an available TCP port.
@@ -106,24 +106,23 @@ COMMANDS
106106
array read from a file at a given INDEX.
107107
108108
os-probe
109-
This script probes the OS, and prints details about the
110-
version.
109+
Probe the OS and print details about its version.
111110
112111
ps List unitd(8) processes.
113112
114113
repo-config
115114
Configure your package manager with the NGINX Unit
116-
repository for later installation
115+
repository for later installation.
117116
118-
sock Print the address of the API control socket.
117+
sock Print the control API socket address.
119118
120119
welcome
121-
Creates an initial configuration to serve a welcome web page
122-
for NGINX Unit.
120+
Create an initial configuration to serve a welcome web page
121+
with NGINX Unit.
123122
124123
OPTIONS
125124
-h, --help
126-
Print the basic help (some commands are hidden).
125+
Print basic help (some commands are hidden).
127126
128127
--help-more
129128
Print the hidden help with more commands.
@@ -166,7 +165,7 @@ SYNOPSIS
166165
$program_name cmd [-h]
167166
168167
DESCRIPTION
169-
Print the invocation line of running instances of unitd(8).
168+
Print the invocation line of running unitd(8) instances.
170169
171170
OPTIONS
172171
-h, --help
@@ -210,42 +209,40 @@ SYNOPSIS
210209
+-- insert [-h] PATH INDEX
211210
212211
DESCRIPTION
213-
Control a running unitd(8) instance through its control socket.
212+
Control a running unitd(8) instance through its control API socket.
214213
215214
Run '$program_name ctl SUBCOMMAND -h' for more information on a
216215
subcommand.
217216
218217
SUBCOMMANDS
219-
http Send an HTTP request to the control socket.
218+
http Send an HTTP request to the control API socket.
220219
221-
insert Insert an element into a specified index in an array in the
220+
insert Insert an element at the specified index into an array in the
222221
JSON configuration.
223222
224223
OPTIONS
225224
-h, --help
226225
Print this help.
227226
228227
-s, --sock SOCK
229-
Use SOCK as the API control socket address. If not specified,
230-
the script will try to find it. This will be used by
231-
subcommands.
228+
Use SOCK as the control API socket address. If not specified,
229+
the script tries to find it. This value is used by subcommands.
232230
233-
The socket can be a tcp(7) socket or a unix(7) socket, and in
234-
the case of a unix(7) socket, it can be local, or it can be in
231+
The socket can be a tcp(7) socket or a unix(7) socket; in
232+
the case of a unix(7) socket, it can exist locally or on
235233
a remote machine, accessed through ssh(1). Accepted syntax
236234
for SOCK:
237235
238236
unix:/path/to/control.sock
239237
ssh://[user@]host[:port]/path/to/control.sock
240238
[http[s]://]host[:port]
241239
242-
The last form is less secure than the first two; you should
243-
have a look at:
240+
The last form is less secure than the first two; have a look:
244241
<https://unit.nginx.org/howto/security/#secure-socket-and-stat>
245242
246243
ENVIRONMENT
247-
Options take precedence over their equivalent environment variables,
248-
so if both are specified, the option will be used.
244+
Options take precedence over their equivalent environment variables;
245+
if both are specified, the command-line option is used.
249246
250247
UNIT_CTL_SOCK
251248
Equivalent to the option -s (--sock).
@@ -324,9 +321,8 @@ OPTIONS
324321
-c, --curl CURLOPT
325322
Pass CURLOPT as an option to curl. This script is implemented
326323
in terms of curl(1), so it's useful to be able to tweak its
327-
behavior. It can be used multiple times, which will be
328-
appended (and also appended to the contents of
329-
UNIT_CTL_HTTP_CURLOPTS).
324+
behavior. The option can be cumulatively used multiple times
325+
(the result is also appended to UNIT_CTL_HTTP_CURLOPTS).
330326
331327
-h, --help
332328
Print this help.
@@ -425,8 +421,8 @@ SYNOPSIS
425421
$program_name ctl [CTL-OPTS] insert [-h] PATH INDEX
426422
427423
DESCRIPTION
428-
Insert an element into a specified position (INDEX) in the JSON array
429-
in the unitd(8) configuration API at PATH.
424+
Insert an element at the specified position (INDEX) into the JSON array
425+
located at PATH in unitd(8) control API.
430426
431427
The new element is read from standard input.
432428
@@ -518,7 +514,7 @@ SYNOPSIS
518514
$program_name welcome [-hn]
519515
520516
DESCRIPTION
521-
This script tests an NGINX Unit instalation by creating an initial
517+
This script tests an NGINX Unit installation by creating an initial
522518
configuration and serving a welcome web page. Recommended for
523519
first-time users.
524520
@@ -527,7 +523,7 @@ OPTIONS
527523
Print this help.
528524
529525
-n, --dry-run
530-
Dry run. Print the commands to be run instea of actually
526+
Dry run. Print the commands to be run instead of actually
531527
running them. Each command is preceded by a line explaining
532528
what it does.
533529
@@ -580,7 +576,7 @@ unit_ctl_welcome()
580576
581577
if test 0 -eq "$nprocs"; then
582578
warn "welcome: NGINX Unit isn't running.";
583-
warn 'For help starting NGINX Unit, see:';
579+
warn 'For help with starting NGINX Unit, see:';
584580
err " <https://unit.nginx.org/installation/#startup-and-shutdown>";
585581
elif test 1 -ne "$nprocs"; then
586582
err 'welcome: Only one NGINX Unit instance should be running.';
@@ -590,7 +586,7 @@ unit_ctl_welcome()
590586
local curl_opt="$(unit_sock_find | unit_sock_filter -c)";
591587
592588
curl $curl_opt/ >/dev/null 2>&1 \
593-
|| err "welcome: Can't reach the control socket.";
589+
|| err "welcome: Can't reach the control API socket.";
594590
595591
if ! test -v force; then
596592
unit_cmd \
@@ -616,8 +612,8 @@ unit_ctl_welcome()
616612
if test -e $conffile; then
617613
if ! unit_ctl_http ---s "$sock" 'GET' '/config' </dev/null 2>/dev/null | grep -q '^{}.\?$'; # The '.\?' is for the possible carriage return.
618614
then
619-
warn 'welcome: NGINX Unit is already configured. If you are sure you want';
620-
err 'to overwrite its current configuration, run again with --force.';
615+
warn 'welcome: NGINX Unit is already configured. To overwrite';
616+
err 'its current configuration, run the script again with --force.';
621617
fi;
622618
fi;
623619
fi;
@@ -835,7 +831,7 @@ SYNOPSIS
835831
ARGUMENTS
836832
JSON Path to a JSON file containing a top-level array.
837833
838-
INDEX Position in the array where to insert the element.
834+
INDEX Position in the array to insert the element at.
839835
840836
DESCRIPTION
841837
Insert a JSON element read from standard input into a JSON array read
@@ -906,9 +902,9 @@ SYNOPSIS
906902
$program_name os-probe [-h]
907903
908904
DESCRIPTION
909-
This script probes the OS, and prints details about the version. It
910-
prints three fields, delimited by ':'; the first is the package manager,
911-
the second is the OS name, and the third is the OS version.
905+
This script probes the OS and prints three fields, delimited by ':';
906+
the first is the package manager, the second is the OS name, the third
907+
is the OS version.
912908
913909
OPTIONS
914910
-h, --help
@@ -939,7 +935,7 @@ unit_os_probe()
939935
local os=$(uname | tr '[:upper:]' '[:lower:]')
940936

941937
if [ "$os" != 'linux' ] && [ "$os" != 'freebsd' ]; then
942-
err "os-probe: The OS isn't Linux or FreeBSD, can't proceed."
938+
err "os-probe: The OS isn't Linux or FreeBSD; can't proceed."
943939
fi
944940

945941
if [ "$os" = 'linux' ]; then
@@ -960,14 +956,14 @@ unit_os_probe()
960956
local osName=$(grep "^ID=" "$osRelease" | sed s/\"//g | awk -F= '{ print $2 }' ||:)
961957
local osVersion=$(grep '^VERSION_ID=' "$osRelease" | sed s/\"//g | awk -F= '{ print $2 }' || lsb_release -cs)
962958
else
963-
err "os-probe: Unable to determine OS and version, or the OS isn't supported"
959+
err "os-probe: Unable to determine OS and version, or the OS isn't supported."
964960
fi
965961
else
966962
local pkgMngr='pkg';
967963
local osName=$os
968964
local osVersion=$(uname -rs | awk -F '[ -]' '{print $2}' ||:)
969965
if [ -z "$osVersion" ]; then
970-
err 'os-probe: Unable to get the FreeBSD version'
966+
err 'os-probe: Unable to get the FreeBSD version.'
971967
fi
972968
fi
973969

@@ -1059,8 +1055,8 @@ DESCRIPTION
10591055
This script configures the NGINX Unit repository for the system
10601056
package manager.
10611057
1062-
The script automatically detects your OS, and works accordingly.
1063-
However, in case the automatic selection fails, you may specify the
1058+
The script automatically detects the OS and proceeds accordingly.
1059+
However, if this automatic selection fails, you may specify the
10641060
package manager and the OS name and version.
10651061
10661062
ARGUMENTS
@@ -1071,15 +1067,15 @@ ARGUMENTS
10711067
Supported: 'debian', 'ubuntu', 'fedora', 'rhel', and 'amzn2'.
10721068
10731069
OS-VERSION
1074-
For most distributions this should be a numeric value, but for
1075-
debian derivatives, the codename should be used.
1070+
For most distributions, this should be a numeric value; for
1071+
Debian derivatives, use the codename instead.
10761072
10771073
OPTIONS
10781074
-h, --help
10791075
Print this help.
10801076
10811077
-n, --dry-run
1082-
Dry run. Print the commands to be run instea of actually
1078+
Dry run. Print the commands to be run instead of actually
10831079
running them. Each command is preceded by a line explaining
10841080
what it does.
10851081
@@ -1202,7 +1198,7 @@ __EOF__";
12021198
installAPT "$pkg_mngr" "$os_name" ${3:+$os_version};
12031199
;;
12041200
*)
1205-
err "repo-config: $os_name: The OS isn't supported";
1201+
err "repo-config: $os_name: The OS isn't supported.";
12061202
;;
12071203
esac
12081204
;;
@@ -1212,12 +1208,12 @@ __EOF__";
12121208
installYumDnf "$pkg_mngr" "$os_name" "$os_version" ${3:+ovr};
12131209
;;
12141210
*)
1215-
err "repo-config: $os_name: The OS isn't supported";
1211+
err "repo-config: $os_name: The OS isn't supported.";
12161212
;;
12171213
esac;
12181214
;;
12191215
*)
1220-
err "repo-config: $pkg_mngr: The package manager isn't supported";
1216+
err "repo-config: $pkg_mngr: The package manager isn't supported.";
12211217
;;
12221218
esac;
12231219

@@ -1239,19 +1235,19 @@ SYNOPSIS
12391235
+-- find [-h]
12401236
12411237
DESCRIPTION
1242-
Print the address of the control API socket of running instances of
1243-
unitd(8).
1238+
Print the control API socket address of running unitd(8)
1239+
instances.
12441240
12451241
Run '$program_name sock SUBCOMMAND -h' for more information on a
12461242
subcommand.
12471243
12481244
SUBCOMMANDS
1249-
filter Filter the output of the 'find' subcommand, and transform it
1250-
to something suitable to run other commands, such as curl(1)
1251-
or ssh(1).
1245+
filter Filter the output of the 'find' subcommand and transform it
1246+
to something suitable for running other commands, such as
1247+
curl(1) or ssh(1).
12521248
1253-
find Find and print the address of the control API socket of
1254-
running instances of unitd(8).
1249+
find Find and print the control API socket address of running
1250+
unitd(8) instances.
12551251
12561252
OPTIONS
12571253
-h, --help
@@ -1306,8 +1302,9 @@ SYNOPSIS
13061302
$program_name sock filter [-chs]
13071303
13081304
DESCRIPTION
1309-
Filter the output of the 'sock find' command, and transform it to
1310-
something suitable to run other commands, such as curl(1) or ssh(1).
1305+
Filter the output of the 'sock find' command and transform it to
1306+
something suitable for running other commands, such as
1307+
curl(1) or ssh(1).
13111308
13121309
OPTIONS
13131310
-c, --curl
@@ -1384,8 +1381,8 @@ SYNOPSIS
13841381
$program_name sock find [-h]
13851382
13861383
DESCRIPTION
1387-
Find and print the address of the control API socket of running
1388-
instances of unitd(8).
1384+
Find and print the control API socket address of running
1385+
unitd(8) instances.
13891386
13901387
OPTIONS
13911388
-h, --help

0 commit comments

Comments
 (0)