Skip to content

Commit ea22774

Browse files
committed
Wrap entire function in the check for the ENVVAR
Signed-off-by: Adam Warner <[email protected]>
1 parent 643d2c0 commit ea22774

File tree

1 file changed

+50
-47
lines changed

1 file changed

+50
-47
lines changed

automated install/basic-install.sh

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -175,58 +175,61 @@ is_command() {
175175
}
176176

177177
os_check() {
178-
# This function gets a list of supported OS versions from a TXT record at versions.pi-hole.net
179-
# and determines whether or not the script is running on one of those systems
180-
local remote_os_domain valid_os valid_version detected_os_pretty detected_os detected_version display_warning
181-
remote_os_domain="versions.pi-hole.net"
182-
valid_os=false
183-
valid_version=false
184-
display_warning=true
185-
186-
detected_os_pretty=$(cat /etc/*release | grep PRETTY_NAME | cut -d '=' -f2- | tr -d '"')
187-
detected_os="${detected_os_pretty%% *}"
188-
detected_version=$(cat /etc/*release | grep VERSION_ID | cut -d '=' -f2- | tr -d '"')
189-
190-
IFS=" " read -r -a supportedOS < <(dig +short -t txt ${remote_os_domain} | tr -d '"')
191-
192-
for i in "${supportedOS[@]}"
193-
do
194-
os_part=$(echo "$i" | cut -d '=' -f1)
195-
versions_part=$(echo "$i" | cut -d '=' -f2-)
196-
197-
if [[ "${detected_os}" =~ ${os_part} ]]; then
198-
valid_os=true
199-
IFS="," read -r -a supportedVer <<<"${versions_part}"
200-
for x in "${supportedVer[@]}"
201-
do
202-
if [[ "${detected_version}" =~ $x ]];then
203-
valid_version=true
204-
break
178+
if [ "$PIHOLE_SKIP_OS_CHECK" != true ]; then
179+
# This function gets a list of supported OS versions from a TXT record at versions.pi-hole.net
180+
# and determines whether or not the script is running on one of those systems
181+
local remote_os_domain valid_os valid_version detected_os_pretty detected_os detected_version display_warning
182+
remote_os_domain="versions.pi-hole.net"
183+
valid_os=false
184+
valid_version=false
185+
display_warning=true
186+
187+
detected_os_pretty=$(cat /etc/*release | grep PRETTY_NAME | cut -d '=' -f2- | tr -d '"')
188+
detected_os="${detected_os_pretty%% *}"
189+
detected_version=$(cat /etc/*release | grep VERSION_ID | cut -d '=' -f2- | tr -d '"')
190+
191+
IFS=" " read -r -a supportedOS < <(dig +short -t txt ${remote_os_domain} | tr -d '"')
192+
193+
for i in "${supportedOS[@]}"
194+
do
195+
os_part=$(echo "$i" | cut -d '=' -f1)
196+
versions_part=$(echo "$i" | cut -d '=' -f2-)
197+
198+
if [[ "${detected_os}" =~ ${os_part} ]]; then
199+
valid_os=true
200+
IFS="," read -r -a supportedVer <<<"${versions_part}"
201+
for x in "${supportedVer[@]}"
202+
do
203+
if [[ "${detected_version}" =~ $x ]];then
204+
valid_version=true
205+
break
206+
fi
207+
done
208+
break
205209
fi
206-
done
207-
break
210+
done
211+
212+
if [ "$valid_os" = true ] && [ "$valid_version" = true ]; then
213+
display_warning=false
208214
fi
209-
done
210215

211-
if [ "$valid_os" = true ] && [ "$valid_version" = true ]; then
212-
display_warning=false
213-
fi
216+
if [ "$display_warning" = true ]; then
217+
printf " %b %bUnsupported OS detected%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}"
218+
printf " https://docs.pi-hole.net/main/prerequesites/#supported-operating-systems\\n"
219+
printf "\\n"
220+
printf " This check can be skipped by setting the environment variable %bPIHOLE_SKIP_OS_CHECK%b to %btrue%b\\n" "${COL_LIGHT_RED}" "${COL_NC}" "${COL_LIGHT_RED}" "${COL_NC}"
221+
printf " e.g: 'sudo PIHOLE_SKIP_OS_CHECK=true curl -sSL https://install.pi-hole.net | bash'\\n"
222+
printf " or 'sudo PIHOLE_SKIP_OS_CHECK=true pihole -up'\\n"
223+
printf " By setting this variable to true you acknowledge there may be issues with Pi-hole during or after the install\\n"
224+
printf " If that is the case, you can feel free to ask the community on Discourse with the %bCommunity Help%b category:\\n" "${COL_LIGHT_RED}" "${COL_NC}"
225+
printf " https://discourse.pi-hole.net/c/bugs-problems-issues/community-help/\\n"
226+
exit 1
214227

215-
if [ "$display_warning" = true ] && [ "$PIHOLE_SKIP_OS_CHECK" != true ]; then
216-
printf " %b %bUnsupported OS detected%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}"
217-
printf " https://docs.pi-hole.net/main/prerequesites/#supported-operating-systems\\n"
218-
printf "\\n"
219-
printf " This check can be skipped by setting the environment variable %bPIHOLE_SKIP_OS_CHECK%b to %btrue%b\\n" "${COL_LIGHT_RED}" "${COL_NC}" "${COL_LIGHT_RED}" "${COL_NC}"
220-
printf " e.g: 'sudo PIHOLE_SKIP_OS_CHECK=true curl -sSL https://install.pi-hole.net | bash'\\n"
221-
printf " or 'sudo PIHOLE_SKIP_OS_CHECK=true pihole -up'\\n"
222-
printf " By setting this variable to true you acknowledge there may be issues with Pi-hole during or after the install\\n"
223-
printf " If that is the case, you can feel free to ask the community on Discourse with the %bCommunity Help%b category:\\n" "${COL_LIGHT_RED}" "${COL_NC}"
224-
printf " https://discourse.pi-hole.net/c/bugs-problems-issues/community-help/\\n"
225-
exit 1
226-
elif [ "$display_warning" = true ] && [ "$PIHOLE_SKIP_OS_CHECK" = true ]; then
227-
printf " %b %bUnsupported OS detected%b. PIHOLE_SKIP_OS_CHECK env variable set to true - installer will continue\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}"
228+
else
229+
printf " %b %bSupported OS detected%b\\n" "${TICK}" "${COL_LIGHT_GREEN}" "${COL_NC}"
230+
fi
228231
else
229-
printf " %b %bSupported OS detected%b\\n" "${TICK}" "${COL_LIGHT_GREEN}" "${COL_NC}"
232+
printf " %b %bPIHOLE_SKIP_OS_CHECK env variable set to true - installer will continue%b\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${COL_NC}"
230233
fi
231234
}
232235

0 commit comments

Comments
 (0)