style(helpers): reformat update script and bump version
This commit is contained in:
parent
4d5f3fa809
commit
03e0631964
@ -1,11 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
### update script for ab-nginx container and utility scripts
|
||||
# version 2.0.0
|
||||
#
|
||||
# update script for ab-nginx container and utility scripts
|
||||
# version 2.1.0
|
||||
# script by Asif Bacchus
|
||||
###
|
||||
#
|
||||
|
||||
### functions
|
||||
#
|
||||
# functions
|
||||
errMsg() {
|
||||
printf "\n%s%s%s\n\n" "$err" "$1" "$norm"
|
||||
exit 1
|
||||
@ -25,27 +27,27 @@ okNotify() {
|
||||
|
||||
scriptHelp() {
|
||||
textNewline
|
||||
textblock "Update ${containerName} container and helper script files"
|
||||
textblock "${bold}Usage: ${localScriptName} [parameters]${norm}"
|
||||
textBlock "Update ${containerName} container and helper script files"
|
||||
textBlock "${bold}Usage: ${localScriptName} [parameters]${norm}"
|
||||
textNewline
|
||||
textblock "If run with no parameters, the script will update both the container and the helper script files, including this update script."
|
||||
textblockHeader " parameters "
|
||||
textblockParam "-h|-?|--help" "Display this help screen."
|
||||
textblockParam "-c|--container|--container-only" "Update the docker container only."
|
||||
textblockParam "-s|--scripts|--scripts-only" "Update the helper scripts (including this update script) only."
|
||||
textBlock "If run with no parameters, the script will update both the container and the helper script files, including this update script."
|
||||
textBlockHeader " parameters "
|
||||
textBlockParam "-h|-?|--help" "Display this help screen."
|
||||
textBlockParam "-c|--container|--container-only" "Update the docker container only."
|
||||
textBlockParam "-s|--scripts|--scripts-only" "Update the helper scripts (including this update script) only."
|
||||
textNewline
|
||||
exit 0
|
||||
}
|
||||
|
||||
textblock() {
|
||||
textBlock() {
|
||||
printf "%s\n" "$1" | fold -w "$width" -s
|
||||
}
|
||||
|
||||
textblockHeader() {
|
||||
textBlockHeader() {
|
||||
printf "\n%s***%s***%s\n" "$header" "$1" "$norm"
|
||||
}
|
||||
|
||||
textblockParam() {
|
||||
textBlockParam() {
|
||||
printf "%s%-35s%s%s\n" "$info" "$1" "$2" "$norm"
|
||||
}
|
||||
|
||||
@ -53,7 +55,8 @@ textNewline() {
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
### text formatting presets
|
||||
#
|
||||
# text formatting presets
|
||||
if command -v tput >/dev/null 2>&1; then
|
||||
bold=$(tput bold)
|
||||
err=$(tput bold)$(tput setaf 1)
|
||||
@ -74,7 +77,8 @@ else
|
||||
width=80
|
||||
fi
|
||||
|
||||
### pre-requisites
|
||||
#
|
||||
# pre-requisites
|
||||
# check if wget is installed
|
||||
if ! command -v wget >/dev/null 2>&1; then
|
||||
errMsg "Sorry, this script requires that 'wget' is installed in order to download updates. Exiting."
|
||||
@ -102,7 +106,8 @@ doScriptUpdate=1
|
||||
localScriptName="$(basename "$0")"
|
||||
repoScriptName='update.sh'
|
||||
|
||||
### process startup parameters
|
||||
#
|
||||
# process startup parameters
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-h | -\? | --help)
|
||||
@ -126,7 +131,8 @@ while [ $# -gt 0 ]; do
|
||||
shift
|
||||
done
|
||||
|
||||
### update container
|
||||
#
|
||||
# update container
|
||||
if [ "$doDockerUpdate" -eq 1 ]; then
|
||||
# check if docker is installed
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
@ -148,7 +154,8 @@ if [ "$doDockerUpdate" -eq 1 ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
### update scripts
|
||||
#
|
||||
# update scripts
|
||||
if [ "$doScriptUpdate" -eq 1 ]; then
|
||||
printf "%s*** Updating %s service scripts ***%s\n" "$info" "$containerName" "$norm"
|
||||
|
||||
@ -239,7 +246,8 @@ if [ "$doScriptUpdate" -eq 1 ]; then
|
||||
done <"$checksumFilename"
|
||||
fi
|
||||
|
||||
### display results
|
||||
#
|
||||
# display results
|
||||
if [ "$doScriptUpdate" -eq 1 ]; then
|
||||
printf "\n%s*** Results ***%s\n" "$info" "$norm"
|
||||
printf "\tUpdates: %s available\n" "$updatesAvailable"
|
||||
|
Loading…
Reference in New Issue
Block a user