|
|
|
@ -13,7 +13,6 @@
|
|
|
|
|
# Must be root to use this tool
|
|
|
|
|
if [[ ! $EUID -eq 0 ]];then
|
|
|
|
|
if [ -x "$(command -v sudo)" ];then
|
|
|
|
|
echo "::: Elevating to root with sudo"
|
|
|
|
|
exec sudo bash "$0" "$@"
|
|
|
|
|
exit $?
|
|
|
|
|
else
|
|
|
|
@ -44,9 +43,48 @@ flushFunc() {
|
|
|
|
|
exit 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getGitFiles() {
|
|
|
|
|
# Setup git repos for directory and repository passed
|
|
|
|
|
# as arguments 1 and 2
|
|
|
|
|
echo ":::"
|
|
|
|
|
echo "::: Checking for existing repository..."
|
|
|
|
|
if is_repo "${1}"; then
|
|
|
|
|
update_repo "${1}"
|
|
|
|
|
else
|
|
|
|
|
make_repo "${1}" "${2}"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
is_repo() {
|
|
|
|
|
# Use git to check if directory is currently under VCS
|
|
|
|
|
echo -n "::: Checking $1 is a repo..."
|
|
|
|
|
cd "${1}" &> /dev/null || return 1
|
|
|
|
|
git status &> /dev/null && echo " OK!"; return 0 || echo " not found!"; return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
make_repo() {
|
|
|
|
|
# Remove the non-repod interface and clone the interface
|
|
|
|
|
echo -n "::: Cloning $2 into $1..."
|
|
|
|
|
rm -rf "${1}"
|
|
|
|
|
git clone -q --depth 1 "${2}" "${1}" > /dev/null & spinner $!
|
|
|
|
|
echo " done!"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update_repo() {
|
|
|
|
|
# Pull the latest commits
|
|
|
|
|
echo -n "::: Updating repo in $1..."
|
|
|
|
|
cd "${1}" || exit 1
|
|
|
|
|
git pull -q > /dev/null & spinner $!
|
|
|
|
|
echo " done!"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updatePiholeFunc() {
|
|
|
|
|
|
|
|
|
|
webInterfaceGitUrl="https://github.com/pi-hole/AdminLTE.git"
|
|
|
|
|
webInterfaceDir="/var/www/html/admin"
|
|
|
|
|
piholeGitUrl="https://github.com/pi-hole/pi-hole.git"
|
|
|
|
|
piholeFilesDir="/etc/.pihole"
|
|
|
|
|
|
|
|
|
|
if [ ! -d "/etc/.pihole" ]; then #This is unlikely
|
|
|
|
|
echo "::: Critical Error: Pi-Hole repo missing from system!"
|
|
|
|
|
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
|
|
|
@ -75,17 +113,17 @@ updatePiholeFunc() {
|
|
|
|
|
echo ":::"
|
|
|
|
|
|
|
|
|
|
if [[ ${webVersion} == ${webVersionLatest} ]] ; then
|
|
|
|
|
echo "::: Web Admin files are already up to date!"
|
|
|
|
|
echo "::: Web Admin files are already up to date! Version: ${webVersionLatest}"
|
|
|
|
|
echo "::: No need to update!"
|
|
|
|
|
echo ":::"
|
|
|
|
|
else
|
|
|
|
|
echo "::: An Update is available for the Web Admin!"
|
|
|
|
|
echo ":::"
|
|
|
|
|
echo "::: Fetching latest changes from GitHub..."
|
|
|
|
|
cd /var/www/html/admin
|
|
|
|
|
git pull origin master
|
|
|
|
|
# Update Git files for Core
|
|
|
|
|
getGitFiles ${webInterfaceDir} ${webInterfaceGitUrl}
|
|
|
|
|
echo ":::"
|
|
|
|
|
echo "::: Pi-hole Web Admin has been updated to ${webVersion}"
|
|
|
|
|
echo "::: Pi-hole Web Admin has been updated to ${webVersionLatest}"
|
|
|
|
|
echo "::: See https://changes.pi-hole.net for details"
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
@ -97,8 +135,8 @@ updatePiholeFunc() {
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "::: Fetching latest changes from GitHub..."
|
|
|
|
|
cd /etc/.pihole
|
|
|
|
|
git pull origin master
|
|
|
|
|
# Update Git files for Core
|
|
|
|
|
getGitFiles ${piholeFilesDir} ${piholeGitUrl}
|
|
|
|
|
/etc/.pihole/automated\ install/basic-install.sh --unattended
|
|
|
|
|
|
|
|
|
|
echo ":::"
|
|
|
|
|