|
1 | 1 | #!/usr/bin/env bash
|
2 | 2 |
|
3 | 3 | # The install script is based off of the Apache 2.0 licensed script from Helm,
|
4 |
| -# the Kubernetes resouce manager: https://github.com/helm/helm. |
| 4 | +# the Kubernetes resource manager: https://github.com/helm/helm. |
5 | 5 |
|
6 |
| -GITHUB_REPOSITORY="nobl9/sloctl" |
| 6 | +PROGRAM_NAME="sloctl" |
| 7 | +GITHUB_REPOSITORY="nobl9/$PROGRAM_NAME" |
7 | 8 |
|
8 |
| -: "${BINARY_NAME:="sloctl"}" |
| 9 | +: "${BINARY_NAME:=$PROGRAM_NAME}" |
9 | 10 | : "${USE_SUDO:="true"}"
|
10 | 11 | : "${DEBUG:="false"}"
|
11 | 12 | : "${VERIFY_CHECKSUM:="true"}"
|
12 |
| -: "${VERIFY_SIGNATURES:="false"}" |
13 | 13 | : "${SLOCTL_INSTALL_DIR:="/usr/local/bin"}"
|
14 | 14 |
|
15 | 15 | HAS_CURL="$(type "curl" &>/dev/null && echo true || echo false)"
|
@@ -197,33 +197,48 @@ testVersion() {
|
197 | 197 | set -e
|
198 | 198 | }
|
199 | 199 |
|
200 |
| -# help provides possible cli installation arguments |
| 200 | +# help provides possible cli installation arguments. |
201 | 201 | help() {
|
202 |
| - echo "Accepted cli arguments are:" |
203 |
| - echo -e "\t[--help|-h ] ->> prints this help" |
204 |
| - echo -e "\t[--version|-v <desired_version>] . When not defined it fetches the latest release from GitHub" |
205 |
| - echo -e "\te.g. --version v0.10.0" |
206 |
| - echo -e "\t[--no-sudo] ->> install without sudo" |
| 202 | + local script_name |
| 203 | + script_name=$(basename "$0") |
| 204 | + cat >&2 <<EOF |
| 205 | + Usage: ${script_name} [OPTS] |
| 206 | +An installer script for ${PROGRAM_NAME}! |
| 207 | +It can be used to both install the binary and upgrade an existing ${PROGRAM_NAME} version. |
| 208 | +OPTS: |
| 209 | + -h, --help Print this message |
| 210 | + --version, -v <desired_version> When not defined it fetches the latest release from GitHub |
| 211 | + --no-sudo Install without sudo |
| 212 | +ENV VARIABLES: |
| 213 | + BINARY_NAME Installed binary name, defaults to ${PROGRAM_NAME} |
| 214 | + USE_SUDO Whether to install with sudo, defaults to true |
| 215 | + DEBUG Print additional debug information, defaults to false |
| 216 | + VERIFY_CHECKSUM Verify the SHA256 checksum of the binary, defaults to true |
| 217 | + SLOCTL_INSTALL_DIR Install directory, defaults to /usr/local/bin |
| 218 | +Examples: |
| 219 | + SLOCTL_INSTALL_DIR=/home/me/go/bin ${script_name} --no-sudo --version=v0.10.0 |
| 220 | +EOF |
207 | 221 | }
|
208 | 222 |
|
| 223 | +# cleanup temporary files. |
209 | 224 | cleanup() {
|
210 | 225 | if [[ -d "${SLOCTL_TMP_ROOT:-}" ]]; then
|
211 | 226 | rm -rf "$SLOCTL_TMP_ROOT"
|
212 | 227 | fi
|
213 | 228 | }
|
214 | 229 |
|
215 |
| -# Execution |
| 230 | +# Execution. |
216 | 231 |
|
217 |
| -#Stop execution on any error |
| 232 | +# Stop execution on any error. |
218 | 233 | trap "fail_trap" EXIT
|
219 | 234 | set -e
|
220 | 235 |
|
221 |
| -# Set debug if desired |
| 236 | +# Set debug if desired. |
222 | 237 | if [ "${DEBUG}" == "true" ]; then
|
223 | 238 | set -x
|
224 | 239 | fi
|
225 | 240 |
|
226 |
| -# Parsing input arguments (if any) |
| 241 | +# Parsing input arguments (if any). |
227 | 242 | export INPUT_ARGUMENTS="${*}"
|
228 | 243 | set -u
|
229 | 244 | while [[ $# -gt 0 ]]; do
|
@@ -256,6 +271,7 @@ while [[ $# -gt 0 ]]; do
|
256 | 271 | done
|
257 | 272 | set +u
|
258 | 273 |
|
| 274 | +# Run. |
259 | 275 | initArch
|
260 | 276 | initOS
|
261 | 277 | verifySupported
|
|
0 commit comments