Make the help text of "pihole checkout [what] [branch]" more colorful

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2024-08-22 21:22:52 +02:00
parent 7206569b1d
commit a302d7b5d7
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD
3 changed files with 23 additions and 19 deletions

View file

@ -77,7 +77,7 @@ checkout() {
if [[ "${1}" == "dev" ]] ; then if [[ "${1}" == "dev" ]] ; then
# Shortcut to check out development branches # Shortcut to check out development branches
echo -e " ${INFO} Shortcut \"dev\" detected - checking out development / devel branches..." echo -e " ${INFO} Shortcut \"${COL_YELLOW}dev${COL_NC}\" detected - checking out development / devel branches..."
echo "" echo ""
echo -e " ${INFO} Pi-hole Core" echo -e " ${INFO} Pi-hole Core"
fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "development" || { echo " ${CROSS} Unable to pull Core development branch"; exit 1; } fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "development" || { echo " ${CROSS} Unable to pull Core development branch"; exit 1; }
@ -92,7 +92,7 @@ checkout() {
chmod 644 /etc/pihole/ftlbranch chmod 644 /etc/pihole/ftlbranch
elif [[ "${1}" == "master" ]] ; then elif [[ "${1}" == "master" ]] ; then
# Shortcut to check out master branches # Shortcut to check out master branches
echo -e " ${INFO} Shortcut \"master\" detected - checking out master branches..." echo -e " ${INFO} Shortcut \"${COL_YELLOW}master${COL_NC}\" detected - checking out master branches..."
echo -e " ${INFO} Pi-hole core" echo -e " ${INFO} Pi-hole core"
fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "master" || { echo " ${CROSS} Unable to pull Core master branch"; exit 1; } fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "master" || { echo " ${CROSS} Unable to pull Core master branch"; exit 1; }
echo -e " ${INFO} Web interface" echo -e " ${INFO} Web interface"
@ -123,7 +123,7 @@ checkout() {
echo "" echo ""
# Have the user choose the branch they want # Have the user choose the branch they want
if ! (for e in "${corebranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then if ! (for e in "${corebranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then
echo -e " ${INFO} Requested branch \"${2}\" is not available" echo -e " ${INFO} Requested branch \"${COL_CYAN}${2}${COL_NC}\" is not available"
echo -e " ${INFO} Available branches for Core are:" echo -e " ${INFO} Available branches for Core are:"
for e in "${corebranches[@]}"; do echo " - $e"; done for e in "${corebranches[@]}"; do echo " - $e"; done
exit 1 exit 1
@ -150,7 +150,7 @@ checkout() {
echo "" echo ""
# Have the user choose the branch they want # Have the user choose the branch they want
if ! (for e in "${webbranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then if ! (for e in "${webbranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then
echo -e " ${INFO} Requested branch \"${2}\" is not available" echo -e " ${INFO} Requested branch \"${COL_CYAN}${2}${COL_NC}\" is not available"
echo -e " ${INFO} Available branches for Web Admin are:" echo -e " ${INFO} Available branches for Web Admin are:"
for e in "${webbranches[@]}"; do echo " - $e"; done for e in "${webbranches[@]}"; do echo " - $e"; done
exit 1 exit 1
@ -164,6 +164,7 @@ checkout() {
path="${2}/${binary}" path="${2}/${binary}"
oldbranch="$(pihole-FTL -b)" oldbranch="$(pihole-FTL -b)"
echo -e " ${INFO} Checking for branch ${COL_CYAN}${2}${COL_NC} on https://ftl.pi-hole.net"
check_download_exists "$path" check_download_exists "$path"
local ret=$? local ret=$?
if [ $ret -eq 0 ]; then if [ $ret -eq 0 ]; then
@ -193,7 +194,7 @@ checkout() {
fi fi
else else
echo -e " ${INFO} Requested option \"${1}\" is not available" echo -e " ${CROSS} Requested option \"${1}\" is not available"
exit 1 exit 1
fi fi

View file

@ -16,9 +16,10 @@
# #
# curl -sSL https://install.pi-hole.net | bash # curl -sSL https://install.pi-hole.net | bash
# -e option instructs bash to immediately exit if any command [1] has a non-zero exit status # -e option instructs bash to immediately exit if any command [1] has a non-zero
# We do not want users to end up with a partially working install, so we exit the script # exit status We do not want users to end up with a partially working install,
# instead of continuing the installation with something broken # so we exit the script instead of continuing the installation with something
# broken
set -e set -e
# Append common folders to the PATH to ensure that all basic commands are available. # Append common folders to the PATH to ensure that all basic commands are available.

24
pihole
View file

@ -408,19 +408,21 @@ piholeCheckoutFunc() {
unsupportedFunc unsupportedFunc
else else
if [[ "$2" == "-h" ]] || [[ "$2" == "--help" ]]; then if [[ "$2" == "-h" ]] || [[ "$2" == "--help" ]]; then
echo "Usage: pihole checkout [repo] [branch] echo "Switch Pi-hole subsystems to a different GitHub branch
Example: 'pihole checkout master' or 'pihole checkout core dev' Usage: ${COL_GREEN}pihole checkout${COL_NC} ${COL_YELLOW}shortcut${COL_NC}
Switch Pi-hole subsystems to a different GitHub branch or ${COL_GREEN}pihole checkout${COL_NC} ${COL_PURPLE}repo${COL_NC} ${COL_CYAN}branch${COL_NC}
Example: ${COL_GREEN}pihole checkout${COL_NC} ${COL_YELLOW}master${COL_NC}
or ${COL_GREEN}pihole checkout${COL_NC} ${COL_PURPLE}ftl ${COL_CYAN}development${COL_NC}
Repositories: Shortcuts:
core [branch] Change the branch of Pi-hole's core subsystem ${COL_YELLOW}master${COL_NC} Update all subsystems to the latest stable release
web [branch] Change the branch of Web Interface subsystem ${COL_YELLOW}dev${COL_NC} Update all subsystems to the latest development release
ftl [branch] Change the branch of Pi-hole's FTL subsystem
Individual components:
${COL_PURPLE}core${COL_NC} ${COL_CYAN}branch${COL_NC} Change the branch of Pi-hole's core subsystem
${COL_PURPLE}web${COL_NC} ${COL_CYAN}branch${COL_NC} Change the branch of the web interface subsystem
${COL_PURPLE}ftl${COL_NC} ${COL_CYAN}branch${COL_NC} Change the branch of Pi-hole's FTL subsystem"
Branches:
master Update subsystems to the latest stable release
dev Update subsystems to the latest development release
branchname Update subsystems to the specified branchname"
exit 0 exit 0
fi fi