Merge pull request #2271 from pi-hole/feature/installer_spacing

Start changes to new code style for repository. Revise basic installer.sh spacing.
This commit is contained in:
Dan Schaper 2018-07-14 19:55:13 -07:00 committed by GitHub
commit 037989b8e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1947 additions and 1958 deletions

View file

@ -9,7 +9,7 @@ end_of_line = lf
insert_final_newline = true insert_final_newline = true
indent_style = space indent_style = space
indent_size = tab indent_size = tab
tab_width = 2 tab_width = 4
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true

View file

@ -1,11 +1,5 @@
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173"> <code_scheme name="Project" version="173">
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</value>
</option>
<MarkdownNavigatorCodeStyleSettings> <MarkdownNavigatorCodeStyleSettings>
<option name="RIGHT_MARGIN" value="72" /> <option name="RIGHT_MARGIN" value="72" />
</MarkdownNavigatorCodeStyleSettings> </MarkdownNavigatorCodeStyleSettings>

View file

@ -291,7 +291,6 @@ elif command -v rpm &> /dev/null; then
"${PKG_INSTALL[@]}" "yum-utils" &> /dev/null "${PKG_INSTALL[@]}" "yum-utils" &> /dev/null
yum-config-manager --enable ${REMI_REPO} &> /dev/null yum-config-manager --enable ${REMI_REPO} &> /dev/null
echo -e " ${TICK} Remi's RPM repository has been enabled for PHP7" echo -e " ${TICK} Remi's RPM repository has been enabled for PHP7"
fi fi
fi fi
fi fi
@ -302,7 +301,6 @@ elif command -v rpm &> /dev/null; then
exit exit
fi fi
# If neither apt-get or rmp/dnf are found # If neither apt-get or rmp/dnf are found
else else
# it's not an OS we can support, # it's not an OS we can support,
@ -458,7 +456,6 @@ find_IPv4_information() {
IPV4_ADDRESS=$(ip -o -f inet addr show | grep "${IPv4bare}" | awk '{print $4}' | awk 'END {print}') IPV4_ADDRESS=$(ip -o -f inet addr show | grep "${IPv4bare}" | awk '{print $4}' | awk 'END {print}')
# Get the default gateway (the way to reach the Internet) # Get the default gateway (the way to reach the Internet)
IPv4gw=$(awk '{print $3}' <<< "${route}") IPv4gw=$(awk '{print $3}' <<< "${route}")
} }
# Get available interfaces that are UP # Get available interfaces that are UP
@ -483,7 +480,6 @@ In the next section, you can choose to use your current network settings (DHCP)
# We need to make sure there is enough space before installing, so there is a function to check this # We need to make sure there is enough space before installing, so there is a function to check this
verifyFreeDiskSpace() { verifyFreeDiskSpace() {
# 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.) # 50MB is the minimum space needed (45MB install (includes web admin bootstrap/jquery libraries etc) + 5MB one day of logs.)
# - Fourdee: Local ensures the variable is only created, and accessible within this function/void. Generally considered a "good" coding practice for non-global variables. # - Fourdee: Local ensures the variable is only created, and accessible within this function/void. Generally considered a "good" coding practice for non-global variables.
local str="Disk space check" local str="Disk space check"
@ -496,27 +492,27 @@ verifyFreeDiskSpace() {
# If the existing space is not an integer, # If the existing space is not an integer,
if ! [[ "${existing_free_kilobytes}" =~ ^([0-9])+$ ]]; then if ! [[ "${existing_free_kilobytes}" =~ ^([0-9])+$ ]]; then
# show an error that we can't determine the free space # show an error that we can't determine the free space
echo -e " ${CROSS} ${str} echo -e " ${CROSS} ${str}"
Unknown free disk space! echo -e " ${INFO} Unknown free disk space!"
We were unable to determine available free disk space on this system. echo -e " ${INFO} We were unable to determine available free disk space on this system."
You may override this check, however, it is not recommended echo -e " ${INFO} You may override this check, however, it is not recommended"
The option '${COL_LIGHT_RED}--i_do_not_follow_recommendations${COL_NC}' can override this echo -e " ${INFO} The option '${COL_LIGHT_RED}--i_do_not_follow_recommendations${COL_NC}' can override this"
e.g: curl -L https://install.pi-hole.net | bash /dev/stdin ${COL_LIGHT_RED}<option>${COL_NC}" echo -e " ${INFO} e.g: curl -L https://install.pi-hole.net | bash /dev/stdin ${COL_LIGHT_RED}<option>${COL_NC}"
# exit with an error code # exit with an error code
exit 1 exit 1
# If there is insufficient free disk space, # If there is insufficient free disk space,
elif [[ "${existing_free_kilobytes}" -lt "${required_free_kilobytes}" ]]; then elif [[ "${existing_free_kilobytes}" -lt "${required_free_kilobytes}" ]]; then
# show an error message # show an error message
echo -e " ${CROSS} ${str} echo -e " ${CROSS} ${str}"
Your system disk appears to only have ${existing_free_kilobytes} KB free echo -e " ${INFO} Your system disk appears to only have ${existing_free_kilobytes} KB free"
It is recommended to have a minimum of ${required_free_kilobytes} KB to run the Pi-hole" echo -e " ${INFO} It is recommended to have a minimum of ${required_free_kilobytes} KB to run the Pi-hole"
# if the vcgencmd command exists, # if the vcgencmd command exists,
if command -v vcgencmd &> /dev/null; then if command -v vcgencmd &> /dev/null; then
# it's probably a Raspbian install, so show a message about expanding the filesystem # it's probably a Raspbian install, so show a message about expanding the filesystem
echo " If this is a new install you may need to expand your disk echo -e " ${INFO} If this is a new install you may need to expand your disk"
Run 'sudo raspi-config', and choose the 'expand file system' option echo -e " ${INFO} Run 'sudo raspi-config', and choose the 'expand file system' option"
After rebooting, run this installation again echo -e " ${INFO} After rebooting, run this installation again"
e.g: curl -L https://install.pi-hole.net | bash" echo -e " ${INFO} e.g: curl -L https://install.pi-hole.net | bash"
fi fi
# Show there is not enough free space # Show there is not enough free space
echo -e "\\n ${COL_LIGHT_RED}Insufficient free space, exiting...${COL_NC}" echo -e "\\n ${COL_LIGHT_RED}Insufficient free space, exiting...${COL_NC}"
@ -2172,9 +2168,9 @@ get_binary_name() {
else else
# Something else - we try to use 32bit executable and warn the user # Something else - we try to use 32bit executable and warn the user
if [[ ! "${machine}" == "i686" ]]; then if [[ ! "${machine}" == "i686" ]]; then
echo -e "${OVER} ${CROSS} ${str}... echo -e "${OVER} ${CROSS} ${str}..."
${COL_LIGHT_RED}Not able to detect architecture (unknown: ${machine}), trying 32bit executable${COL_NC} echo -e " ${INFO} ${COL_LIGHT_RED}Not able to detect architecture (unknown: ${machine}), trying 32bit executable${COL_NC}"
Contact Pi-hole Support if you experience issues (e.g: FTL not running)" echo -e " ${INFO} Contact Pi-hole Support if you experience issues (e.g: FTL not running)"
else else
echo -e "${OVER} ${TICK} Detected 32bit (i686) architecture" echo -e "${OVER} ${TICK} Detected 32bit (i686) architecture"
fi fi
@ -2182,8 +2178,7 @@ get_binary_name() {
fi fi
} }
FTLcheckUpdate() FTLcheckUpdate() {
{
get_binary_name get_binary_name
#In the next section we check to see if FTL is already installed (in case of pihole -r). #In the next section we check to see if FTL is already installed (in case of pihole -r).
@ -2312,11 +2307,11 @@ main() {
# Otherwise, # Otherwise,
else else
# They do not have enough privileges, so let the user know # They do not have enough privileges, so let the user know
echo -e " ${CROSS} ${str} echo -e " ${CROSS} ${str}"
${COL_LIGHT_RED}Script called with non-root privileges${COL_NC} echo -e " ${INFO} ${COL_LIGHT_RED}Script called with non-root privileges${COL_NC}"
The Pi-hole requires elevated privileges to install and run echo -e " ${INFO} The Pi-hole requires elevated privileges to install and run"
Please check the installer for any concerns regarding this requirement echo -e " ${INFO} Please check the installer for any concerns regarding this requirement"
Make sure to download this script from a trusted source\\n" echo -e " ${INFO} Make sure to download this script from a trusted source\\n"
echo -ne " ${INFO} Sudo utility check" echo -ne " ${INFO} Sudo utility check"
# If the sudo command exists, # If the sudo command exists,
@ -2328,9 +2323,9 @@ main() {
# Otherwise, # Otherwise,
else else
# Let them know they need to run it as root # Let them know they need to run it as root
echo -e "${OVER} ${CROSS} Sudo utility check echo -e "${OVER} ${CROSS} Sudo utility check"
Sudo is needed for the Web Interface to run pihole commands\\n echo -e " ${INFO} Sudo is needed for the Web Interface to run pihole commands\\n"
${COL_LIGHT_RED}Please re-run this installer as root${COL_NC}" echo -e " ${INFO} ${COL_LIGHT_RED}Please re-run this installer as root${COL_NC}"
exit 1 exit 1
fi fi
fi fi
@ -2434,7 +2429,7 @@ main() {
# generate a random password # generate a random password
pw=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 8) pw=$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 8)
# shellcheck disable=SC1091 # shellcheck disable=SC1091
. /opt/pihole/webpage.sh /opt/pihole/webpage.sh
echo "WEBPASSWORD=$(HashPassword ${pw})" >> ${setupVars} echo "WEBPASSWORD=$(HashPassword ${pw})" >> ${setupVars}
fi fi
fi fi
@ -2467,8 +2462,8 @@ main() {
runGravity runGravity
# Force an update of the updatechecker # Force an update of the updatechecker
. /opt/pihole/updatecheck.sh /opt/pihole/updatecheck.sh
. /opt/pihole/updatecheck.sh x remote /opt/pihole/updatecheck.sh x remote
# #
if [[ "${useUpdateVars}" == false ]]; then if [[ "${useUpdateVars}" == false ]]; then
@ -2480,8 +2475,8 @@ main() {
# If there is a password, # If there is a password,
if (( ${#pw} > 0 )) ; then if (( ${#pw} > 0 )) ; then
# display the password # display the password
echo -e " ${INFO} Web Interface password: ${COL_LIGHT_GREEN}${pw}${COL_NC} echo -e " ${INFO} Web Interface password: ${COL_LIGHT_GREEN}${pw}${COL_NC}"
This can be changed using 'pihole -a -p'\\n" echo -e " ${INFO} This can be changed using 'pihole -a -p'\\n"
fi fi
fi fi
@ -2489,14 +2484,14 @@ main() {
if [[ "${useUpdateVars}" == false ]]; then if [[ "${useUpdateVars}" == false ]]; then
# If the Web interface was installed, # If the Web interface was installed,
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
echo -e " View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin" echo -e " ${INFO} View the web interface at http://pi.hole/admin or http://${IPV4_ADDRESS%/*}/admin"
echo "" echo ""
fi fi
# Explain to the user how to use Pi-hole as their DNS server # Explain to the user how to use Pi-hole as their DNS server
echo " You may now configure your devices to use the Pi-hole as their DNS server" echo -e " ${INFO} You may now configure your devices to use the Pi-hole as their DNS server"
[[ -n "${IPV4_ADDRESS%/*}" ]] && echo -e " ${INFO} Pi-hole DNS (IPv4): ${IPV4_ADDRESS%/*}" [[ -n "${IPV4_ADDRESS%/*}" ]] && echo -e " ${INFO} Pi-hole DNS (IPv4): ${IPV4_ADDRESS%/*}"
[[ -n "${IPV6_ADDRESS}" ]] && echo -e " ${INFO} Pi-hole DNS (IPv6): ${IPV6_ADDRESS}" [[ -n "${IPV6_ADDRESS}" ]] && echo -e " ${INFO} Pi-hole DNS (IPv6): ${IPV6_ADDRESS}"
echo -e " If you set a new IP address, please restart the server running the Pi-hole" echo -e " ${INFO} If you set a new IP address, please restart the server running the Pi-hole"
# #
INSTALL_TYPE="Installation" INSTALL_TYPE="Installation"
else else