Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaLLy3K <WaLLy3K@users.noreply.github.com>2017-05-11 07:19:13 +0300
committerGitHub <noreply@github.com>2017-05-11 07:19:13 +0300
commitc6596f2c5481d5d266b0bb25db2e9b38dff9f6da (patch)
tree14ff99ff549b20533cd0ec211908b67bb80ec940 /advanced/Scripts/version.sh
parent2863308090296a43ae69c7ecc4f1ef176b756090 (diff)
Modified syntax to be valid for Shellcheck
Diffstat (limited to 'advanced/Scripts/version.sh')
-rwxr-xr-xadvanced/Scripts/version.sh26
1 files changed, 12 insertions, 14 deletions
diff --git a/advanced/Scripts/version.sh b/advanced/Scripts/version.sh
index 8ab95367..923d86d8 100755
--- a/advanced/Scripts/version.sh
+++ b/advanced/Scripts/version.sh
@@ -16,7 +16,7 @@ WEBGITDIR="/var/www/html/admin/"
getLocalVersion() {
# FTL requires a different method
if [ "$1" == "FTL" ]; then
- echo $(pihole-FTL version)
+ pihole-FTL version
return 0
fi
@@ -25,8 +25,7 @@ getLocalVersion() {
local version
cd "${directory}" || { echo "${DEFAULT}"; return 1; }
- version=$(git describe --tags --always || \
- echo "${DEFAULT}")
+ version=$(git describe --tags --always || echo "$DEFAULT")
if [[ "${version}" =~ ^v ]]; then
echo "${version}"
elif [[ "${version}" == "${DEFAULT}" ]]; then
@@ -50,8 +49,7 @@ getLocalHash() {
local hash
cd "${directory}" || { echo "${DEFAULT}"; return 1; }
- hash=$(git rev-parse --short HEAD || \
- echo "${DEFAULT}")
+ hash=$(git rev-parse --short HEAD || echo "$DEFAULT")
if [[ "${hash}" == "${DEFAULT}" ]]; then
echo "ERROR"
return 1
@@ -66,7 +64,7 @@ getRemoteVersion(){
local daemon="${1}"
local version
- version=$(curl --silent --fail https://api.github.com/repos/pi-hole/${daemon}/releases/latest | \
+ version=$(curl --silent --fail "https://api.github.com/repos/pi-hole/${daemon}/releases/latest" | \
awk -F: '$1 ~/tag_name/ { print $2 }' | \
tr -cd '[[:alnum:]]._-')
if [[ "${version}" =~ ^v ]]; then
@@ -79,19 +77,19 @@ getRemoteVersion(){
}
versionOutput() {
- [ "$1" == "pi-hole" ] && GITDIR=${COREGITDIR}
- [ "$1" == "AdminLTE" ] && GITDIR=${WEBGITDIR}
+ [ "$1" == "pi-hole" ] && GITDIR=$COREGITDIR
+ [ "$1" == "AdminLTE" ] && GITDIR=$WEBGITDIR
[ "$1" == "FTL" ] && GITDIR="FTL"
- [ "$2" == "-c" -o "$2" == "--current" -o -z "$2" ] && current=$(getLocalVersion $GITDIR)
- [ "$2" == "-l" -o "$2" == "--latest" -o -z "$2" ] && latest=$(getRemoteVersion $1)
- [ "$2" == "-h" -o "$2" == "--hash" ] && hash=$(getLocalHash $GITDIR)
+ [ "$2" == "-c" ] || [ "$2" == "--current" ] || [ -z "$2" ] && current=$(getLocalVersion $GITDIR)
+ [ "$2" == "-l" ] || [ "$2" == "--latest" ] || [ -z "$2" ] && latest=$(getRemoteVersion "$1")
+ [ "$2" == "-h" ] || [ "$2" == "--hash" ] && hash=$(getLocalHash "$GITDIR")
- if [ -n "$current" -a -n "$latest" ]; then
+ if [ -n "$current" ] && [ -n "$latest" ]; then
output="${1^} version is $current (Latest: $latest)"
- elif [ -n "$current" -a -z "$latest" ]; then
+ elif [ -n "$current" ] && [ -z "$latest" ]; then
output="Current ${1^} version is $current"
- elif [ -z "$current" -a -n "$latest" ]; then
+ elif [ -z "$current" ] && [ -n "$latest" ]; then
output="Latest ${1^} version is $latest"
elif [ "$hash" == "N/A" ]; then
output=""