mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +00:00
Factor out downloader from detector function.
Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
parent
339f95b00c
commit
87edbeaf58
@ -1,38 +0,0 @@
|
|||||||
version: 2
|
|
||||||
|
|
||||||
always_pending:
|
|
||||||
title_regex: '(WIP|wip)'
|
|
||||||
labels:
|
|
||||||
- wip
|
|
||||||
explanation: 'This PR is a work in progress...'
|
|
||||||
|
|
||||||
group_defaults:
|
|
||||||
reset_on_push:
|
|
||||||
enabled: true
|
|
||||||
reject_value: -2
|
|
||||||
approve_regex: '^(Approved|:shipit:|:\+1:|Engage)'
|
|
||||||
reject_regex: '^(Rejected|:-1:|Borg)'
|
|
||||||
author_approval:
|
|
||||||
auto: true
|
|
||||||
|
|
||||||
|
|
||||||
groups:
|
|
||||||
development:
|
|
||||||
approve_by_comment:
|
|
||||||
enabled: true
|
|
||||||
conditions:
|
|
||||||
branches:
|
|
||||||
- development
|
|
||||||
required: 2
|
|
||||||
teams:
|
|
||||||
- approvers
|
|
||||||
|
|
||||||
master:
|
|
||||||
approve_by_comment:
|
|
||||||
enabled: true
|
|
||||||
conditions:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
required: -1
|
|
||||||
teams:
|
|
||||||
- admin
|
|
@ -1026,9 +1026,7 @@ installPihole() {
|
|||||||
fi
|
fi
|
||||||
installCron
|
installCron
|
||||||
installLogrotate
|
installLogrotate
|
||||||
if FTLdownload; then
|
FTLdetect || echo "::: FTL Engine not installed."
|
||||||
FTLinstall
|
|
||||||
fi
|
|
||||||
configureFirewall
|
configureFirewall
|
||||||
finalExports
|
finalExports
|
||||||
#runGravity
|
#runGravity
|
||||||
@ -1060,9 +1058,7 @@ updatePihole() {
|
|||||||
fi
|
fi
|
||||||
installCron
|
installCron
|
||||||
installLogrotate
|
installLogrotate
|
||||||
if FTLdownload; then
|
FTLdetect || echo "::: FTL Engine not installed."
|
||||||
FTLinstall
|
|
||||||
fi
|
|
||||||
finalExports #re-export setupVars.conf to account for any new vars added in new versions
|
finalExports #re-export setupVars.conf to account for any new vars added in new versions
|
||||||
#runGravity
|
#runGravity
|
||||||
}
|
}
|
||||||
@ -1156,12 +1152,40 @@ if [[ "${reconfigure}" == true ]]; then
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
FTLdownload() {
|
FTLinstall() {
|
||||||
|
# Download and Install FTL binary
|
||||||
|
local binary="${1}"
|
||||||
|
local latesttag
|
||||||
|
echo ":::"
|
||||||
|
echo -n "::: Installing FTL ... "
|
||||||
|
|
||||||
|
latesttag=$(curl -s https://api.github.com/repos/pi-hole/FTL/releases/latest | grep "tag_name" | sed "s/.*: \"//;s/\",//;")
|
||||||
|
if [ ! "${latesttag}" ]; then
|
||||||
|
echo "::: failed (error in getting latest release tag from GitHub)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if curl -sSL --fail "https://github.com/pi-hole/FTL/releases/download/${latesttag}/${binary}" -o "/opt/pihole/pihole-FTL"; then
|
||||||
|
echo "::: done"
|
||||||
|
install -m 0755 /opt/pihole/pihole-FTL /usr/bin
|
||||||
|
touch /var/log/pihole-FTL.log /var/run/pihole-FTL.pid /var/run/pihole-FTL.port
|
||||||
|
chmod 0666 /var/log/pihole-FTL.log /var/run/pihole-FTL.pid /var/run/pihole-FTL.port
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "::: failed (download of binary from Github failed)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo "done"
|
||||||
|
}
|
||||||
|
|
||||||
|
FTLdetect() {
|
||||||
# Download suitable FTL binary
|
# Download suitable FTL binary
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Downloading latest version of FTL..."
|
echo "::: Downloading latest version of FTL..."
|
||||||
|
|
||||||
local machine=$(arch)
|
local machine
|
||||||
|
local binary
|
||||||
|
|
||||||
|
machine=$(arch)
|
||||||
|
|
||||||
if [[ $machine == arm* || $machine == *aarch* ]]; then
|
if [[ $machine == arm* || $machine == *aarch* ]]; then
|
||||||
# ARM
|
# ARM
|
||||||
@ -1198,30 +1222,8 @@ FTLdownload() {
|
|||||||
binary="pihole-FTL-linux-x86_32"
|
binary="pihole-FTL-linux-x86_32"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
latesttag=$(curl -s https://api.github.com/repos/pi-hole/FTL/releases/latest | grep "tag_name" | sed "s/.*: \"//;s/\",//;")
|
FTLinstall "${binary}" || return 1
|
||||||
if [ ! "${latesttag}" ]; then
|
|
||||||
echo "::: failed (error in getting latest release tag from GitHub)"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if curl -sSL --fail "https://github.com/pi-hole/FTL/releases/download/${latesttag}/${binary}" -o "/opt/pihole/pihole-FTL"; then
|
|
||||||
echo "::: done"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "::: failed (download of binary from Github failed)"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
FTLinstall() {
|
|
||||||
# Install FTL binary
|
|
||||||
echo ":::"
|
|
||||||
echo -n "::: Installing FTL ... "
|
|
||||||
|
|
||||||
install -m 0755 /opt/pihole/pihole-FTL /usr/bin
|
|
||||||
touch /var/log/pihole-FTL.log /var/run/pihole-FTL.pid /var/run/pihole-FTL.port
|
|
||||||
chmod 0666 /var/log/pihole-FTL.log /var/run/pihole-FTL.pid /var/run/pihole-FTL.port
|
|
||||||
|
|
||||||
echo "done"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
@ -305,7 +305,7 @@ def test_FTL_detect_aarch64_no_errors(Pihole):
|
|||||||
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-aarch64.so.1', '0')}, Pihole)
|
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-aarch64.so.1', '0')}, Pihole)
|
||||||
detectPlatform = Pihole.run('''
|
detectPlatform = Pihole.run('''
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLdownload
|
FTLdetect
|
||||||
''')
|
''')
|
||||||
expected_stdout = 'Detected ARM-aarch64 architecture'
|
expected_stdout = 'Detected ARM-aarch64 architecture'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
@ -318,7 +318,7 @@ def test_FTL_detect_armv6l_no_errors(Pihole):
|
|||||||
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-armhf.so.3', '0')}, Pihole)
|
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-armhf.so.3', '0')}, Pihole)
|
||||||
detectPlatform = Pihole.run('''
|
detectPlatform = Pihole.run('''
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLdownload
|
FTLdetect
|
||||||
''')
|
''')
|
||||||
expected_stdout = 'Detected ARM-hf architecture (armv6 or lower)'
|
expected_stdout = 'Detected ARM-hf architecture (armv6 or lower)'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
@ -331,7 +331,7 @@ def test_FTL_detect_armv7l_no_errors(Pihole):
|
|||||||
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-armhf.so.3', '0')}, Pihole)
|
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-armhf.so.3', '0')}, Pihole)
|
||||||
detectPlatform = Pihole.run('''
|
detectPlatform = Pihole.run('''
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLdownload
|
FTLdetect
|
||||||
''')
|
''')
|
||||||
expected_stdout = 'Detected ARM-hf architecture (armv7+)'
|
expected_stdout = 'Detected ARM-hf architecture (armv7+)'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
@ -340,7 +340,7 @@ def test_FTL_detect_x86_64_no_errors(Pihole):
|
|||||||
''' confirms only x86_64 package is downloaded for FTL engine '''
|
''' confirms only x86_64 package is downloaded for FTL engine '''
|
||||||
detectPlatform = Pihole.run('''
|
detectPlatform = Pihole.run('''
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLdownload
|
FTLdetect
|
||||||
''')
|
''')
|
||||||
expected_stdout = 'Detected x86_64 architecture'
|
expected_stdout = 'Detected x86_64 architecture'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
@ -351,7 +351,7 @@ def test_FTL_detect_unknown_no_errors(Pihole):
|
|||||||
mock_command('arch', {'*':('mips', '0')}, Pihole)
|
mock_command('arch', {'*':('mips', '0')}, Pihole)
|
||||||
detectPlatform = Pihole.run('''
|
detectPlatform = Pihole.run('''
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
FTLdownload
|
FTLdetect
|
||||||
''')
|
''')
|
||||||
expected_stdout = 'Not able to detect architecture (unknown: mips)'
|
expected_stdout = 'Not able to detect architecture (unknown: mips)'
|
||||||
assert expected_stdout in detectPlatform.stdout
|
assert expected_stdout in detectPlatform.stdout
|
||||||
|
Loading…
Reference in New Issue
Block a user