2
#########################################################################
4
# add-bintray.sh is automatically generated, #
5
# please do not modify! #
7
#########################################################################
9
#########################################################################
11
# Script ID: add-bintray.sh #
12
# Author: Copyright (C) 2020 Mark Grant #
14
# Released under the GPLv3 only. #
15
# SPDX-License-Identifier: GPL-3.0 #
18
# To add a bintray apt key to a trusted apt keyring in the apt #
19
# directory. This is designed to be run via the apt-key-scripts.sh #
20
# script but can be run manually. #
22
# Syntax: add-bintray.sh [ -h || --help ] || #
23
# [ -v || --verbose ] || #
24
# [ -V || --version ] #
27
# Bash standard Exit Codes: 0 - success #
28
# 1 - general failure #
29
# User-defined exit code range is 64 - 113 #
30
# C/C++ Semi-standard exit codes from sysexits.h range is 64 - 78 #
31
# EX_USAGE 64 command line usage error #
32
# EX_DATAERR 65 data format error #
33
# EX_NOINPUT 66 cannot open input #
34
# EX_NOUSER 67 addressee unknown #
35
# EX_NOHOST 68 host name unknown #
36
# EX_UNAVAILABLE 69 service unavailable #
37
# EX_SOFTWARE 70 internal software error #
38
# EX_OSERR 71 system error (e.g., can't fork) #
39
# EX_OSFILE 72 critical OS file missing #
40
# EX_CANTCREAT 73 can't create (user) output file #
41
# EX_IOERR 74 input/output error #
42
# EX_TEMPFAIL 75 temp failure; user is invited #
44
# EX_PROTOCOL 76 remote error in protocol #
45
# EX_NOPERM 77 permission denied #
46
# EX_CONFIG 78 configuration error #
47
# User-defined (here) exit codes range 79 - 113: #
52
#########################################################################
54
#########################################################################
58
# Date Author Version Description #
60
# 21/05/2020 MG 1.0.1 Created. #
62
#########################################################################
71
readonly version=1.0.1 # Script version
72
readonly outputprefix="$(basename $0): "
73
readonly packageversion=@pkgversion@ # Package version
90
-h or --help Displays usage information
91
-v or --verbose Display more verbose output
92
-V or --version Displays version information
96
# Standard function to emit messages depending on various parameters.
97
# Parameters - $1 What:- The message to emit.
98
# $2 Where:- stdout == 0
106
printf "%s\n" "$1" 1>&2
110
# Standard function to tidy up and return exit code.
111
# Parameters - $1 is the exit code.
118
# Standard function to test command error and exit if non-zero.
119
# Parameters - $1 is the exit code, (normally $? from the preceeding command).
121
std_cmd_err_handler()
128
# Standard trap exit function.
133
local -i exit_code=$?
136
msg="Script terminating with exit code $exit_code due to trap received."
138
script_exit $exit_code
142
trap trap_exit SIGHUP SIGINT SIGQUIT SIGTERM
144
# Process command line arguments with GNU getopt.
145
# Parameters - $1 is the command line.
152
tmpGETOPTTEMP="getopt -o hvV --long help,verbose,version"
153
GETOPTTEMP=$($tmpGETOPTTEMP -n "$0" -- "$@")
154
std_cmd_err_handler $?
156
eval set -- "$GETOPTTEMP"
157
std_cmd_err_handler $?
171
printf "Script version %s\n" $version
172
printf "Package version %s\n" $packageversion
179
*) output "Internal error." 1
185
# Script does not accept other arguments.
187
output "Invalid argument." 1
200
wget -"$verbose"O - https://bintray.com/user/downloadSubjectPublicKey?username=mgrantprg | sudo apt-key --keyring @sysconfdir@/apt/trusted.gpg.d/bintray-keyring.gpg add -