Tools: Updated built-in 'setup-unit' help, README.md command lines.

This commit is contained in:
Artem Konev
2022-12-14 21:17:01 +00:00
parent cf3ffb8cf3
commit 789095b8a0
2 changed files with 69 additions and 70 deletions

View File

@@ -50,8 +50,9 @@ For a description of image tags, see the
### Amazon Linux, Fedora, RedHat ### Amazon Linux, Fedora, RedHat
``` console ``` console
$ curl -sL 'https://unit.nginx.org/_downloads/setup-unit.sh' | sudo -E bash $ wget https://raw.githubusercontent.com/nginx/unit/master/tools/setup-unit && chmod +x setup-unit
# yum install unit # ./setup-unit repo-config && yum install unit
# ./setup-unit welcome
``` ```
For details and available language packages, see the For details and available language packages, see the
@@ -61,8 +62,9 @@ For details and available language packages, see the
### Debian, Ubuntu ### Debian, Ubuntu
``` console ``` console
$ curl -sL 'https://unit.nginx.org/_downloads/setup-unit.sh' | sudo -E bash $ wget https://raw.githubusercontent.com/nginx/unit/master/tools/setup-unit && chmod +x setup-unit
# apt install unit # ./setup-unit repo-config && apt install unit
# ./setup-unit welcome
``` ```
For details and available language packages, see the For details and available language packages, see the

View File

@@ -9,10 +9,10 @@
if test -n ${BASH_VERSION} && test "${BASH_VERSINFO[0]}" -eq 3; then if test -n ${BASH_VERSION} && test "${BASH_VERSINFO[0]}" -eq 3; then
>&2 echo 'Your version of bash(1) is not supported by this script.'; >&2 echo 'Your version of bash(1) isn't supported by this script.';
>&2 echo "You're probably running on MacOS. We recommend that you either"; >&2 echo "You're probably running on macOS. We recommend that you either";
>&2 echo 'install a newer version of bash(1), or you run this script with'; >&2 echo 'install a newer version of bash(1) or run this script with';
>&2 echo 'another shell, like for example zsh(1):'; >&2 echo 'another shell, such as zsh(1):';
>&2 echo " $ zsh ${SUDO_USER:+sudo }$0 ..."; >&2 echo " $ zsh ${SUDO_USER:+sudo }$0 ...";
exit 1; exit 1;
fi; fi;
@@ -52,16 +52,16 @@ COMMANDS
for later installation. for later installation.
welcome welcome
Creates an initial configuration to serve a welcome web page Create an initial configuration to serve a welcome web page
for NGINX Unit. with NGINX Unit.
OPTIONS OPTIONS
-h, --help -h, --help
Print this help. Print this help.
--help-more --help-more
Print help for more commands. They are experimental. This is Print help for more commands. They are experimental. Using
not recommended unless you know what you're doing. these isn't recommended, unless you know what you're doing.
__EOF__ __EOF__
} }
@@ -96,7 +96,7 @@ DESCRIPTION
COMMANDS COMMANDS
cmd Print the invocation line of unitd(8). cmd Print the invocation line of unitd(8).
ctl Control a running unitd(8) instance through its control socket. ctl Control a running unitd(8) instance via its control API socket.
freeport freeport
Print an available TCP port. Print an available TCP port.
@@ -106,24 +106,23 @@ COMMANDS
array read from a file at a given INDEX. array read from a file at a given INDEX.
os-probe os-probe
This script probes the OS, and prints details about the Probe the OS and print details about its version.
version.
ps List unitd(8) processes. ps List unitd(8) processes.
repo-config repo-config
Configure your package manager with the NGINX Unit Configure your package manager with the NGINX Unit
repository for later installation repository for later installation.
sock Print the address of the API control socket. sock Print the control API socket address.
welcome welcome
Creates an initial configuration to serve a welcome web page Create an initial configuration to serve a welcome web page
for NGINX Unit. with NGINX Unit.
OPTIONS OPTIONS
-h, --help -h, --help
Print the basic help (some commands are hidden). Print basic help (some commands are hidden).
--help-more --help-more
Print the hidden help with more commands. Print the hidden help with more commands.
@@ -166,7 +165,7 @@ SYNOPSIS
$program_name cmd [-h] $program_name cmd [-h]
DESCRIPTION DESCRIPTION
Print the invocation line of running instances of unitd(8). Print the invocation line of running unitd(8) instances.
OPTIONS OPTIONS
-h, --help -h, --help
@@ -210,15 +209,15 @@ SYNOPSIS
+-- insert [-h] PATH INDEX +-- insert [-h] PATH INDEX
DESCRIPTION DESCRIPTION
Control a running unitd(8) instance through its control socket. Control a running unitd(8) instance through its control API socket.
Run '$program_name ctl SUBCOMMAND -h' for more information on a Run '$program_name ctl SUBCOMMAND -h' for more information on a
subcommand. subcommand.
SUBCOMMANDS SUBCOMMANDS
http Send an HTTP request to the control socket. http Send an HTTP request to the control API socket.
insert Insert an element into a specified index in an array in the insert Insert an element at the specified index into an array in the
JSON configuration. JSON configuration.
OPTIONS OPTIONS
@@ -226,12 +225,11 @@ OPTIONS
Print this help. Print this help.
-s, --sock SOCK -s, --sock SOCK
Use SOCK as the API control socket address. If not specified, Use SOCK as the control API socket address. If not specified,
the script will try to find it. This will be used by the script tries to find it. This value is used by subcommands.
subcommands.
The socket can be a tcp(7) socket or a unix(7) socket, and in The socket can be a tcp(7) socket or a unix(7) socket; in
the case of a unix(7) socket, it can be local, or it can be in the case of a unix(7) socket, it can exist locally or on
a remote machine, accessed through ssh(1). Accepted syntax a remote machine, accessed through ssh(1). Accepted syntax
for SOCK: for SOCK:
@@ -239,13 +237,12 @@ OPTIONS
ssh://[user@]host[:port]/path/to/control.sock ssh://[user@]host[:port]/path/to/control.sock
[http[s]://]host[:port] [http[s]://]host[:port]
The last form is less secure than the first two; you should The last form is less secure than the first two; have a look:
have a look at:
<https://unit.nginx.org/howto/security/#secure-socket-and-stat> <https://unit.nginx.org/howto/security/#secure-socket-and-stat>
ENVIRONMENT ENVIRONMENT
Options take precedence over their equivalent environment variables, Options take precedence over their equivalent environment variables;
so if both are specified, the option will be used. if both are specified, the command-line option is used.
UNIT_CTL_SOCK UNIT_CTL_SOCK
Equivalent to the option -s (--sock). Equivalent to the option -s (--sock).
@@ -324,9 +321,8 @@ OPTIONS
-c, --curl CURLOPT -c, --curl CURLOPT
Pass CURLOPT as an option to curl. This script is implemented Pass CURLOPT as an option to curl. This script is implemented
in terms of curl(1), so it's useful to be able to tweak its in terms of curl(1), so it's useful to be able to tweak its
behavior. It can be used multiple times, which will be behavior. The option can be cumulatively used multiple times
appended (and also appended to the contents of (the result is also appended to UNIT_CTL_HTTP_CURLOPTS).
UNIT_CTL_HTTP_CURLOPTS).
-h, --help -h, --help
Print this help. Print this help.
@@ -425,8 +421,8 @@ SYNOPSIS
$program_name ctl [CTL-OPTS] insert [-h] PATH INDEX $program_name ctl [CTL-OPTS] insert [-h] PATH INDEX
DESCRIPTION DESCRIPTION
Insert an element into a specified position (INDEX) in the JSON array Insert an element at the specified position (INDEX) into the JSON array
in the unitd(8) configuration API at PATH. located at PATH in unitd(8) control API.
The new element is read from standard input. The new element is read from standard input.
@@ -518,7 +514,7 @@ SYNOPSIS
$program_name welcome [-hn] $program_name welcome [-hn]
DESCRIPTION DESCRIPTION
This script tests an NGINX Unit instalation by creating an initial This script tests an NGINX Unit installation by creating an initial
configuration and serving a welcome web page. Recommended for configuration and serving a welcome web page. Recommended for
first-time users. first-time users.
@@ -527,7 +523,7 @@ OPTIONS
Print this help. Print this help.
-n, --dry-run -n, --dry-run
Dry run. Print the commands to be run instea of actually Dry run. Print the commands to be run instead of actually
running them. Each command is preceded by a line explaining running them. Each command is preceded by a line explaining
what it does. what it does.
@@ -580,7 +576,7 @@ unit_ctl_welcome()
if test 0 -eq "$nprocs"; then if test 0 -eq "$nprocs"; then
warn "welcome: NGINX Unit isn't running."; warn "welcome: NGINX Unit isn't running.";
warn 'For help starting NGINX Unit, see:'; warn 'For help with starting NGINX Unit, see:';
err " <https://unit.nginx.org/installation/#startup-and-shutdown>"; err " <https://unit.nginx.org/installation/#startup-and-shutdown>";
elif test 1 -ne "$nprocs"; then elif test 1 -ne "$nprocs"; then
err 'welcome: Only one NGINX Unit instance should be running.'; err 'welcome: Only one NGINX Unit instance should be running.';
@@ -590,7 +586,7 @@ unit_ctl_welcome()
local curl_opt="$(unit_sock_find | unit_sock_filter -c)"; local curl_opt="$(unit_sock_find | unit_sock_filter -c)";
curl $curl_opt/ >/dev/null 2>&1 \ curl $curl_opt/ >/dev/null 2>&1 \
|| err "welcome: Can't reach the control socket."; || err "welcome: Can't reach the control API socket.";
if ! test -v force; then if ! test -v force; then
unit_cmd \ unit_cmd \
@@ -616,8 +612,8 @@ unit_ctl_welcome()
if test -e $conffile; then if test -e $conffile; then
if ! unit_ctl_http ---s "$sock" 'GET' '/config' </dev/null 2>/dev/null | grep -q '^{}.\?$'; # The '.\?' is for the possible carriage return. if ! unit_ctl_http ---s "$sock" 'GET' '/config' </dev/null 2>/dev/null | grep -q '^{}.\?$'; # The '.\?' is for the possible carriage return.
then then
warn 'welcome: NGINX Unit is already configured. If you are sure you want'; warn 'welcome: NGINX Unit is already configured. To overwrite';
err 'to overwrite its current configuration, run again with --force.'; err 'its current configuration, run the script again with --force.';
fi; fi;
fi; fi;
fi; fi;
@@ -835,7 +831,7 @@ SYNOPSIS
ARGUMENTS ARGUMENTS
JSON Path to a JSON file containing a top-level array. JSON Path to a JSON file containing a top-level array.
INDEX Position in the array where to insert the element. INDEX Position in the array to insert the element at.
DESCRIPTION DESCRIPTION
Insert a JSON element read from standard input into a JSON array read Insert a JSON element read from standard input into a JSON array read
@@ -906,9 +902,9 @@ SYNOPSIS
$program_name os-probe [-h] $program_name os-probe [-h]
DESCRIPTION DESCRIPTION
This script probes the OS, and prints details about the version. It This script probes the OS and prints three fields, delimited by ':';
prints three fields, delimited by ':'; the first is the package manager, the first is the package manager, the second is the OS name, the third
the second is the OS name, and the third is the OS version. is the OS version.
OPTIONS OPTIONS
-h, --help -h, --help
@@ -939,7 +935,7 @@ unit_os_probe()
local os=$(uname | tr '[:upper:]' '[:lower:]') local os=$(uname | tr '[:upper:]' '[:lower:]')
if [ "$os" != 'linux' ] && [ "$os" != 'freebsd' ]; then if [ "$os" != 'linux' ] && [ "$os" != 'freebsd' ]; then
err "os-probe: The OS isn't Linux or FreeBSD, can't proceed." err "os-probe: The OS isn't Linux or FreeBSD; can't proceed."
fi fi
if [ "$os" = 'linux' ]; then if [ "$os" = 'linux' ]; then
@@ -960,14 +956,14 @@ unit_os_probe()
local osName=$(grep "^ID=" "$osRelease" | sed s/\"//g | awk -F= '{ print $2 }' ||:) local osName=$(grep "^ID=" "$osRelease" | sed s/\"//g | awk -F= '{ print $2 }' ||:)
local osVersion=$(grep '^VERSION_ID=' "$osRelease" | sed s/\"//g | awk -F= '{ print $2 }' || lsb_release -cs) local osVersion=$(grep '^VERSION_ID=' "$osRelease" | sed s/\"//g | awk -F= '{ print $2 }' || lsb_release -cs)
else else
err "os-probe: Unable to determine OS and version, or the OS isn't supported" err "os-probe: Unable to determine OS and version, or the OS isn't supported."
fi fi
else else
local pkgMngr='pkg'; local pkgMngr='pkg';
local osName=$os local osName=$os
local osVersion=$(uname -rs | awk -F '[ -]' '{print $2}' ||:) local osVersion=$(uname -rs | awk -F '[ -]' '{print $2}' ||:)
if [ -z "$osVersion" ]; then if [ -z "$osVersion" ]; then
err 'os-probe: Unable to get the FreeBSD version' err 'os-probe: Unable to get the FreeBSD version.'
fi fi
fi fi
@@ -1059,8 +1055,8 @@ DESCRIPTION
This script configures the NGINX Unit repository for the system This script configures the NGINX Unit repository for the system
package manager. package manager.
The script automatically detects your OS, and works accordingly. The script automatically detects the OS and proceeds accordingly.
However, in case the automatic selection fails, you may specify the However, if this automatic selection fails, you may specify the
package manager and the OS name and version. package manager and the OS name and version.
ARGUMENTS ARGUMENTS
@@ -1071,15 +1067,15 @@ ARGUMENTS
Supported: 'debian', 'ubuntu', 'fedora', 'rhel', and 'amzn2'. Supported: 'debian', 'ubuntu', 'fedora', 'rhel', and 'amzn2'.
OS-VERSION OS-VERSION
For most distributions this should be a numeric value, but for For most distributions, this should be a numeric value; for
debian derivatives, the codename should be used. Debian derivatives, use the codename instead.
OPTIONS OPTIONS
-h, --help -h, --help
Print this help. Print this help.
-n, --dry-run -n, --dry-run
Dry run. Print the commands to be run instea of actually Dry run. Print the commands to be run instead of actually
running them. Each command is preceded by a line explaining running them. Each command is preceded by a line explaining
what it does. what it does.
@@ -1202,7 +1198,7 @@ __EOF__";
installAPT "$pkg_mngr" "$os_name" ${3:+$os_version}; installAPT "$pkg_mngr" "$os_name" ${3:+$os_version};
;; ;;
*) *)
err "repo-config: $os_name: The OS isn't supported"; err "repo-config: $os_name: The OS isn't supported.";
;; ;;
esac esac
;; ;;
@@ -1212,12 +1208,12 @@ __EOF__";
installYumDnf "$pkg_mngr" "$os_name" "$os_version" ${3:+ovr}; installYumDnf "$pkg_mngr" "$os_name" "$os_version" ${3:+ovr};
;; ;;
*) *)
err "repo-config: $os_name: The OS isn't supported"; err "repo-config: $os_name: The OS isn't supported.";
;; ;;
esac; esac;
;; ;;
*) *)
err "repo-config: $pkg_mngr: The package manager isn't supported"; err "repo-config: $pkg_mngr: The package manager isn't supported.";
;; ;;
esac; esac;
@@ -1239,19 +1235,19 @@ SYNOPSIS
+-- find [-h] +-- find [-h]
DESCRIPTION DESCRIPTION
Print the address of the control API socket of running instances of Print the control API socket address of running unitd(8)
unitd(8). instances.
Run '$program_name sock SUBCOMMAND -h' for more information on a Run '$program_name sock SUBCOMMAND -h' for more information on a
subcommand. subcommand.
SUBCOMMANDS SUBCOMMANDS
filter Filter the output of the 'find' subcommand, and transform it filter Filter the output of the 'find' subcommand and transform it
to something suitable to run other commands, such as curl(1) to something suitable for running other commands, such as
or ssh(1). curl(1) or ssh(1).
find Find and print the address of the control API socket of find Find and print the control API socket address of running
running instances of unitd(8). unitd(8) instances.
OPTIONS OPTIONS
-h, --help -h, --help
@@ -1306,8 +1302,9 @@ SYNOPSIS
$program_name sock filter [-chs] $program_name sock filter [-chs]
DESCRIPTION DESCRIPTION
Filter the output of the 'sock find' command, and transform it to Filter the output of the 'sock find' command and transform it to
something suitable to run other commands, such as curl(1) or ssh(1). something suitable for running other commands, such as
curl(1) or ssh(1).
OPTIONS OPTIONS
-c, --curl -c, --curl
@@ -1384,8 +1381,8 @@ SYNOPSIS
$program_name sock find [-h] $program_name sock find [-h]
DESCRIPTION DESCRIPTION
Find and print the address of the control API socket of running Find and print the control API socket address of running
instances of unitd(8). unitd(8) instances.
OPTIONS OPTIONS
-h, --help -h, --help