|
|
@ -18,17 +18,17 @@ piholeGitUrl="https://github.com/pi-hole/pi-hole.git"
|
|
|
|
piholeFilesDir="/etc/.pihole"
|
|
|
|
piholeFilesDir="/etc/.pihole"
|
|
|
|
|
|
|
|
|
|
|
|
spinner() {
|
|
|
|
spinner() {
|
|
|
|
local pid=$1
|
|
|
|
local pid=${1}
|
|
|
|
local delay=0.50
|
|
|
|
local delay=0.50
|
|
|
|
local spinstr='/-\|'
|
|
|
|
local spinstr='/-\|'
|
|
|
|
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
|
|
|
|
while [ "$(ps a | awk '{print $1}' | grep "${pid}")" ]; do
|
|
|
|
local temp=${spinstr#?}
|
|
|
|
local temp=${spinstr#?}
|
|
|
|
printf " [%c] " "$spinstr"
|
|
|
|
printf " [%c] " "${spinstr}"
|
|
|
|
local spinstr=${temp}${spinstr%"$temp"}
|
|
|
|
local spinstr=${temp}${spinstr%"$temp"}
|
|
|
|
sleep ${delay}
|
|
|
|
sleep ${delay}
|
|
|
|
printf "\b\b\b\b\b\b"
|
|
|
|
printf "\b\b\b\b\b\b"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
printf " \b\b\b\b"
|
|
|
|
printf " \b\b\b\b"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getGitFiles() {
|
|
|
|
getGitFiles() {
|
|
|
@ -37,45 +37,45 @@ getGitFiles() {
|
|
|
|
echo ":::"
|
|
|
|
echo ":::"
|
|
|
|
echo "::: Checking for existing repository..."
|
|
|
|
echo "::: Checking for existing repository..."
|
|
|
|
if is_repo "${1}"; then
|
|
|
|
if is_repo "${1}"; then
|
|
|
|
update_repo "${1}"
|
|
|
|
update_repo "${1}"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
make_repo "${1}" "${2}"
|
|
|
|
make_repo "${1}" "${2}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
is_repo() {
|
|
|
|
is_repo() {
|
|
|
|
# Use git to check if directory is currently under VCS
|
|
|
|
# Use git to check if directory is currently under VCS
|
|
|
|
echo -n "::: Checking $1 is a repo..."
|
|
|
|
echo -n "::: Checking $1 is a repo..."
|
|
|
|
cd "${1}" &> /dev/null || return 1
|
|
|
|
cd "${1}" &> /dev/null || return 1
|
|
|
|
git status &> /dev/null && echo " OK!"; return 0 || echo " not found!"; return 1
|
|
|
|
git status &> /dev/null && echo " OK!"; return 0 || echo " not found!"; return 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
make_repo() {
|
|
|
|
make_repo() {
|
|
|
|
# Remove the non-repod interface and clone the interface
|
|
|
|
# Remove the non-repod interface and clone the interface
|
|
|
|
echo -n "::: Cloning $2 into $1..."
|
|
|
|
echo -n "::: Cloning $2 into $1..."
|
|
|
|
rm -rf "${1}"
|
|
|
|
rm -rf "${1}"
|
|
|
|
git clone -q --depth 1 "${2}" "${1}" > /dev/null & spinner $!
|
|
|
|
git clone -q --depth 1 "${2}" "${1}" > /dev/null & spinner $!
|
|
|
|
echo " done!"
|
|
|
|
echo " done!"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
update_repo() {
|
|
|
|
update_repo() {
|
|
|
|
# Pull the latest commits
|
|
|
|
# Pull the latest commits
|
|
|
|
echo -n "::: Updating repo in $1..."
|
|
|
|
echo -n "::: Updating repo in $1..."
|
|
|
|
cd "${1}" || exit 1
|
|
|
|
cd "${1}" || exit 1
|
|
|
|
git stash -q > /dev/null & spinner $!
|
|
|
|
git stash -q > /dev/null & spinner $!
|
|
|
|
git pull -q > /dev/null & spinner $!
|
|
|
|
git pull -q > /dev/null & spinner $!
|
|
|
|
echo " done!"
|
|
|
|
echo " done!"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -d "/etc/.pihole" ]; then #This is unlikely
|
|
|
|
if [ ! -d "/etc/.pihole" ]; then #This is unlikely
|
|
|
|
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
|
|
|
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
|
|
|
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
|
|
|
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
|
|
|
exit 1;
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ ! -d "/var/www/html/admin" ]; then #This is unlikely
|
|
|
|
if [ ! -d "/var/www/html/admin" ]; then #This is unlikely
|
|
|
|
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
|
|
|
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
|
|
|
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
|
|
|
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
|
|
|
exit 1;
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo "::: Checking for updates..."
|
|
|
|
echo "::: Checking for updates..."
|
|
|
@ -105,40 +105,38 @@ echo ":::"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ ${piholeVersion} == ${piholeVersionLatest} && ${webVersion} == ${webVersionLatest} ]]; then
|
|
|
|
if [[ ${piholeVersion} == ${piholeVersionLatest} && ${webVersion} == ${webVersionLatest} ]]; then
|
|
|
|
echo "::: Everything is up to date!"
|
|
|
|
echo "::: Everything is up to date!"
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
exit 0
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
|
|
|
|
elif [[ ${piholeVersion} == ${piholeVersionLatest} && ${webVersion} != ${webVersionLatest} ]]; then
|
|
|
|
elif [[ ${piholeVersion} == ${piholeVersionLatest} && ${webVersion} != ${webVersionLatest} ]]; then
|
|
|
|
echo "::: Pi-hole Web Admin files out of date"
|
|
|
|
echo "::: Pi-hole Web Admin files out of date"
|
|
|
|
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl}
|
|
|
|
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl}
|
|
|
|
echo ":::"
|
|
|
|
echo ":::"
|
|
|
|
webVersion=$(pihole -v -a -c)
|
|
|
|
webVersion=$(pihole -v -a -c)
|
|
|
|
echo "::: Web Admin version is now at ${webVersion}"
|
|
|
|
echo "::: Web Admin version is now at ${webVersion}"
|
|
|
|
echo "::: If you had made any changes in '/var/www/html/admin', they have been stashed using 'git stash'"
|
|
|
|
echo "::: If you had made any changes in '/var/www/html/admin', they have been stashed using 'git stash'"
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
elif [[ ${piholeVersion} != ${piholeVersionLatest} && ${webVersion} == ${webVersionLatest} ]]; then
|
|
|
|
elif [[ ${piholeVersion} != ${piholeVersionLatest} && ${webVersion} == ${webVersionLatest} ]]; then
|
|
|
|
echo "::: Pi-hole core files out of date"
|
|
|
|
echo "::: Pi-hole core files out of date"
|
|
|
|
getGitFiles ${piholeFilesDir} ${piholeGitUrl}
|
|
|
|
getGitFiles ${piholeFilesDir} ${piholeGitUrl}
|
|
|
|
/etc/.pihole/automated\ install/basic-install.sh --reconfigure --unattended
|
|
|
|
/etc/.pihole/automated\ install/basic-install.sh --reconfigure --unattended
|
|
|
|
echo ":::"
|
|
|
|
echo ":::"
|
|
|
|
piholeVersion=$(pihole -v -p -c)
|
|
|
|
piholeVersion=$(pihole -v -p -c)
|
|
|
|
echo "::: Pi-hole version is now at ${piholeVersion}"
|
|
|
|
echo "::: Pi-hole version is now at ${piholeVersion}"
|
|
|
|
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
|
|
|
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
elif [[ ${piholeVersion} != ${piholeVersionLatest} && ${webVersion} != ${webVersionLatest} ]]; then
|
|
|
|
elif [[ ${piholeVersion} != ${piholeVersionLatest} && ${webVersion} != ${webVersionLatest} ]]; then
|
|
|
|
echo "::: Updating Everything"
|
|
|
|
echo "::: Updating Everything"
|
|
|
|
getGitFiles ${piholeFilesDir} ${piholeGitUrl}
|
|
|
|
getGitFiles ${piholeFilesDir} ${piholeGitUrl}
|
|
|
|
/etc/.pihole/automated\ install/basic-install.sh --unattended
|
|
|
|
/etc/.pihole/automated\ install/basic-install.sh --unattended
|
|
|
|
webVersion=$(pihole -v -a -c)
|
|
|
|
webVersion=$(pihole -v -a -c)
|
|
|
|
piholeVersion=$(pihole -v -p -c)
|
|
|
|
piholeVersion=$(pihole -v -p -c)
|
|
|
|
echo ":::"
|
|
|
|
echo ":::"
|
|
|
|
echo "::: Pi-hole version is now at ${piholeVersion}"
|
|
|
|
echo "::: Pi-hole version is now at ${piholeVersion}"
|
|
|
|
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
|
|
|
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
|
|
|
echo ":::"
|
|
|
|
echo ":::"
|
|
|
|
echo "::: Pi-hole version is now at ${piholeVersion}"
|
|
|
|
echo "::: Pi-hole version is now at ${piholeVersion}"
|
|
|
|
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
|
|
|
echo "::: If you had made any changes in '/etc/.pihole', they have been stashed using 'git stash'"
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|