Colourise Core Output Text (#1471)

* Define colours within COL_TABLE
* Do not output colours for non-terminal instances
* Removed ":::"
* Fixed indenting & spacing
* Made output consistent throughout project
* Reworded text to fit on standard 80 char wide Terminal screen
* Made 'sudo raspi-config' warning (insufficient disk space) only show on RPi
* Make "Installation/Update Complete" the final msg
* Remove redundant messages
* Simplify update available message
* Confirm user would like to begin uninstall
* If "git pull" string says "Already up-to-date.", place [i] before it
* Colour Temp/Interface output
* Made `pihole disable 5z` invalid
* Added error fallback if invalid argument (not s/m) is detected
* Quoted "$2" for consistency
* Updated help text
* L185/286: Replaced echo with redirect
* User agents for adblock.mahakala.is/adaway.org unnecessary 
* Print newline on confirmation of repository reset
* Add output to admin-related dnsmasq restarts
* Return error message for "pihole -q"
* Imply default checkout behaviour with y/N
* Fix uninstall failing to remove pihole user
* Print checkout 'git remote show origin' STDERR on new line
* Replaced checkout "AdminLTE" wording with "Web Admin"
This commit is contained in:
Adam Warner 2017-06-21 12:49:05 +01:00 committed by WaLLy3K
parent 6f2ec22894
commit 536585b846
11 changed files with 1076 additions and 792 deletions

View file

@ -22,6 +22,10 @@ readonly PI_HOLE_FILES_DIR="/etc/.pihole"
PH_TEST=true
source ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh
colfile="/opt/pihole/COL_TABLE"
source ${colfile}
# is_repo() sourced from basic-install.sh
# make_repo() sourced from basic-install.sh
# update_repo() source from basic-install.sh
@ -49,14 +53,14 @@ GitCheckUpdateAvail() {
REMOTE="$(git rev-parse @{upstream})"
if [[ ${#LOCAL} == 0 ]]; then
echo "::: Error: Local revision could not be obtained, ask Pi-hole support."
echo "::: Additional debugging output:"
echo -e " ${COL_LIGHT_RED}Error: Local revision could not be obtained, ask Pi-hole support."
echo -e " Additional debugging output:${COL_NC}"
git status
exit
fi
if [[ ${#REMOTE} == 0 ]]; then
echo "::: Error: Remote revision could not be obtained, ask Pi-hole support."
echo "::: Additional debugging output:"
echo -e " ${COL_LIGHT_RED}Error: Remote revision could not be obtained, ask Pi-hole support."
echo -e " Additional debugging output:${COL_NC}"
git status
exit
fi
@ -94,52 +98,52 @@ main() {
#This is unlikely
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
echo "::: Critical Error: Core Pi-hole repo is missing from system!"
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
echo -e " ${COL_LIGHT_RED}Critical Error: Core Pi-hole repo is missing from system!"
echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
exit 1;
fi
echo "::: Checking for updates..."
echo -e " ${INFO} Checking for updates..."
if GitCheckUpdateAvail "${PI_HOLE_FILES_DIR}" ; then
core_update=true
echo "::: Pi-hole Core: update available"
echo -e " ${INFO} Pi-hole Core:\t${COL_YELLOW}update available${COL_NC}"
else
core_update=false
echo "::: Pi-hole Core: up to date"
echo -e " ${INFO} Pi-hole Core:\t${COL_LIGHT_GREEN}up to date${COL_NC}"
fi
if FTLcheckUpdate ; then
FTL_update=true
echo "::: FTL: update available"
echo -e " ${INFO} FTL:\t\t${COL_YELLOW}update available${COL_NC}"
else
FTL_update=false
echo "::: FTL: up to date"
echo -e " ${INFO} FTL:\t\t${COL_LIGHT_GREEN}up to date${COL_NC}"
fi
# Logic: Don't update FTL when there is a core update available
# since the core update will run the installer which will itself
# re-install (i.e. update) FTL
if ${FTL_update} && ! ${core_update}; then
echo ":::"
echo "::: FTL out of date"
echo ""
echo -e " ${INFO} FTL out of date"
FTLdetect
echo ":::"
echo ""
fi
if [[ ${INSTALL_WEB} == true ]]; then
if ! is_repo "${ADMIN_INTERFACE_DIR}" ; then
echo "::: Critical Error: Web Admin repo is missing from system!"
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
echo -e " ${COL_LIGHT_RED}Critical Error: Web Admin repo is missing from system!"
echo -e " Please re-run install script from https://github.com/pi-hole/pi-hole${COL_NC}"
exit 1;
fi
if GitCheckUpdateAvail "${ADMIN_INTERFACE_DIR}" ; then
web_update=true
echo "::: Web Interface: update available"
echo -e " ${INFO} Web Interface:\t${COL_YELLOW}update available${COL_NC}"
else
web_update=false
echo "::: Web Interface: up to date"
echo -e " ${INFO} Web Interface:\t${COL_LIGHT_GREEN}up to date${COL_NC}"
fi
# Logic
@ -154,64 +158,64 @@ main() {
if ! ${core_update} && ! ${web_update} ; then
if ! ${FTL_update} ; then
echo ":::"
echo "::: Everything is up to date!"
echo ""
echo -e " ${TICK} Everything is up to date!"
exit 0
fi
elif ! ${core_update} && ${web_update} ; then
echo ":::"
echo "::: Pi-hole Web Admin files out of date"
echo ""
echo -e " ${INFO} Pi-hole Web Admin files out of date"
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
elif ${core_update} && ! ${web_update} ; then
echo ":::"
echo "::: Pi-hole core files out of date"
echo ""
echo -e " ${INFO} Pi-hole core files out of date"
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || echo -e " ${COL_LIGHT_RED}Unable to complete update, contact Pi-hole${COL_NC}" && exit 1
elif ${core_update} && ${web_update} ; then
echo ":::"
echo "::: Updating Pi-hole core and web admin files"
echo ""
echo -e " ${INFO} Updating Pi-hole core and web admin files"
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --unattended || echo -e " ${COL_LIGHT_RED}Unable to complete update, contact Pi-hole${COL_NC}" && exit 1
else
echo "*** Update script has malfunctioned, fallthrough reached. Please contact support"
echo -e " ${COL_LIGHT_RED}Update script has malfunctioned, fallthrough reached. Please contact support${COL_NC}"
exit 1
fi
else # Web Admin not installed, so only verify if core is up to date
if ! ${core_update}; then
if ! ${FTL_update} ; then
echo ":::"
echo "::: Everything is up to date!"
echo ""
echo -e " ${INFO} Everything is up to date!"
exit 0
fi
else
echo ":::"
echo "::: Pi-hole core files out of date"
echo ""
echo -e " ${INFO} Pi-hole core files out of date"
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || echo -e " ${COL_LIGHT_RED}Unable to complete update, contact Pi-hole${COL_NC}" && exit 1
fi
fi
if [[ "${web_update}" == true ]]; then
web_version_current="$(/usr/local/bin/pihole version --admin --current)"
echo ":::"
echo "::: Web Admin version is now at ${web_version_current/* v/v}}"
echo "::: If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'"
echo ""
echo -e " ${INFO} Web Admin version is now at ${web_version_current/* v/v}"
echo -e " ${INFO} If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'"
fi
if [[ "${core_update}" == true ]]; then
pihole_version_current="$(/usr/local/bin/pihole version --pihole --current)"
echo ":::"
echo "::: Pi-hole version is now at ${pihole_version_current/* v/v}}"
echo "::: If you had made any changes in '/etc/.pihole/', they have been stashed using 'git stash'"
echo ""
echo -e " ${INFO} Pi-hole version is now at ${pihole_version_current/* v/v}"
echo -e " ${INFO} If you had made any changes in '/etc/.pihole/', they have been stashed using 'git stash'"
fi
if [[ ${FTL_update} == true ]]; then
FTL_version_current="$(/usr/local/bin/pihole version --ftl --current)"
echo ":::"
echo "::: FTL version is now at ${FTL_version_current/* v/v}}"
FTL_version_current="$(/usr/bin/pihole-FTL tag)"
echo ""
echo -e " ${INFO} FTL version is now at ${FTL_version_current/* v/v}"
start_service pihole-FTL
enable_service pihole-FTL
fi