1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-10-23 00:09:23 +00:00

Add TRAP to the installer

Signed-off-by: Christian König <github@yubiuser.dev>
This commit is contained in:
Christian König 2024-09-29 22:45:47 +02:00
parent e1e99854a0
commit 31f222e73d
No known key found for this signature in database

View File

@ -25,6 +25,9 @@ set -e
# When using "su" an incomplete PATH could be passed: https://github.com/pi-hole/pi-hole/issues/3209
export PATH+=':/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
# Trap any errors, then exit
trap abort INT QUIT TERM
######## VARIABLES #########
# For better maintainability, we store as much information that can change in variables
# This allows us to make a change in one place that can propagate to all instances of the variable
@ -195,6 +198,15 @@ show_ascii_berry() {
"
}
abort() {
echo -e "\\n\\n ${COL_LIGHT_RED}Installation was interrupted${COL_NC}\\n"
echo -e "Pi-hole's dependencies might be already installed. If you want to remove them you can try to\\n"
echo -e "a) run 'pihole uninstall' \\n"
echo -e "b) Remove the meta-package 'pihole-meta' manually \\n"
echo -e "E.g. sudo apt-get remove pihole-meta && apt-get autoremove \\n"
exit 1
}
is_command() {
# Checks to see if the given command (passed as a string argument) exists on the system.
# The function returns 0 (success) if the command exists, and 1 if it doesn't.