mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Fix pihole -v
output if WebAdmin not installed (#4370)
* Fix https://github.com/pi-hole/pi-hole/issues/4279 Signed-off-by: Subhaditya Nath <sn03.general@gmail.com> * Don't ignore exit code of version.sh If it exits with a non-zero return code, that means some error occurred, and so it shouldn't be ignored. Signed-off-by: Subhaditya Nath <sn03.general@gmail.com> * Implement changes suggested by @Michalng Signed-off-by: Subhaditya Nath <sn03.general@gmail.com> * Implement changes suggested by @PromoFaux Signed-off-by: Subhaditya Nath <sn03.general@gmail.com> * Always source /etc/pihole/setupVars.conf https://github.com/pi-hole/pi-hole/pull/4370#issuecomment-978149567 Co-authored-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
parent
e485a7b9bb
commit
ba6d700e7e
2 changed files with 14 additions and 8 deletions
|
@ -13,6 +13,10 @@ DEFAULT="-1"
|
||||||
COREGITDIR="/etc/.pihole/"
|
COREGITDIR="/etc/.pihole/"
|
||||||
WEBGITDIR="/var/www/html/admin/"
|
WEBGITDIR="/var/www/html/admin/"
|
||||||
|
|
||||||
|
# Source the setupvars config file
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
source /etc/pihole/setupVars.conf
|
||||||
|
|
||||||
getLocalVersion() {
|
getLocalVersion() {
|
||||||
# FTL requires a different method
|
# FTL requires a different method
|
||||||
if [[ "$1" == "FTL" ]]; then
|
if [[ "$1" == "FTL" ]]; then
|
||||||
|
@ -91,10 +95,11 @@ getRemoteVersion(){
|
||||||
#If the above file exists, then we can read from that. Prevents overuse of GitHub API
|
#If the above file exists, then we can read from that. Prevents overuse of GitHub API
|
||||||
if [[ -f "$cachedVersions" ]]; then
|
if [[ -f "$cachedVersions" ]]; then
|
||||||
IFS=' ' read -r -a arrCache < "$cachedVersions"
|
IFS=' ' read -r -a arrCache < "$cachedVersions"
|
||||||
|
|
||||||
case $daemon in
|
case $daemon in
|
||||||
"pi-hole" ) echo "${arrCache[0]}";;
|
"pi-hole" ) echo "${arrCache[0]}";;
|
||||||
"AdminLTE" ) echo "${arrCache[1]}";;
|
"AdminLTE" ) [[ "${INSTALL_WEB_INTERFACE}" == true ]] && echo "${arrCache[1]}";;
|
||||||
"FTL" ) echo "${arrCache[2]}";;
|
"FTL" ) [[ "${INSTALL_WEB_INTERFACE}" == true ]] && echo "${arrCache[2]}" || echo "${arrCache[1]}";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
@ -140,6 +145,11 @@ getLocalBranch(){
|
||||||
}
|
}
|
||||||
|
|
||||||
versionOutput() {
|
versionOutput() {
|
||||||
|
if [[ "$1" == "AdminLTE" && "${INSTALL_WEB_INTERFACE}" != true ]]; then
|
||||||
|
echo " WebAdmin not installed"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
[[ "$1" == "pi-hole" ]] && GITDIR=$COREGITDIR
|
[[ "$1" == "pi-hole" ]] && GITDIR=$COREGITDIR
|
||||||
[[ "$1" == "AdminLTE" ]] && GITDIR=$WEBGITDIR
|
[[ "$1" == "AdminLTE" ]] && GITDIR=$WEBGITDIR
|
||||||
[[ "$1" == "FTL" ]] && GITDIR="FTL"
|
[[ "$1" == "FTL" ]] && GITDIR="FTL"
|
||||||
|
@ -166,6 +176,7 @@ versionOutput() {
|
||||||
output="Latest ${1^} hash is $latHash"
|
output="Latest ${1^} hash is $latHash"
|
||||||
else
|
else
|
||||||
errorOutput
|
errorOutput
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$output" ]] && echo " $output"
|
[[ -n "$output" ]] && echo " $output"
|
||||||
|
@ -177,10 +188,6 @@ errorOutput() {
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultOutput() {
|
defaultOutput() {
|
||||||
# Source the setupvars config file
|
|
||||||
# shellcheck disable=SC1091
|
|
||||||
source /etc/pihole/setupVars.conf
|
|
||||||
|
|
||||||
versionOutput "pi-hole" "$@"
|
versionOutput "pi-hole" "$@"
|
||||||
|
|
||||||
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
|
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
|
||||||
|
|
3
pihole
3
pihole
|
@ -95,8 +95,7 @@ uninstallFunc() {
|
||||||
|
|
||||||
versionFunc() {
|
versionFunc() {
|
||||||
shift
|
shift
|
||||||
"${PI_HOLE_SCRIPT_DIR}"/version.sh "$@"
|
exec "${PI_HOLE_SCRIPT_DIR}"/version.sh "$@"
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get PID of main pihole-FTL process
|
# Get PID of main pihole-FTL process
|
||||||
|
|
Loading…
Reference in a new issue