From 9e8ffc48dab1c2284895931a3b530d6c252009a6 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Mon, 14 Mar 2016 21:04:09 -0400 Subject: [PATCH] Improved installer and updated scripts --- advanced/Functions/install.funcs | 2 +- advanced/Functions/pihole.funcs | 2 - advanced/Functions/pihole.var | 2 +- advanced/Scripts/blacklist.sh | 1 + advanced/Scripts/updateDashboard.sh | 69 +++++++++-------------------- advanced/Scripts/whitelist.sh | 1 + automated install/install.sh | 23 ++++++---- 7 files changed, 40 insertions(+), 60 deletions(-) diff --git a/advanced/Functions/install.funcs b/advanced/Functions/install.funcs index 242b9866..3cf1e680 100644 --- a/advanced/Functions/install.funcs +++ b/advanced/Functions/install.funcs @@ -426,4 +426,4 @@ $piholeIPv6 If you set a new IP address, you should restart the Pi. The install log is in /etc/pihole." $r $c -} \ No newline at end of file +} diff --git a/advanced/Functions/pihole.funcs b/advanced/Functions/pihole.funcs index 661893f2..8424209b 100644 --- a/advanced/Functions/pihole.funcs +++ b/advanced/Functions/pihole.funcs @@ -10,8 +10,6 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -source pihole.var - RootCheck(){ echo ":::" if [[ $EUID -eq 0 ]];then diff --git a/advanced/Functions/pihole.var b/advanced/Functions/pihole.var index d9e87118..1acc3d60 100644 --- a/advanced/Functions/pihole.var +++ b/advanced/Functions/pihole.var @@ -38,4 +38,4 @@ IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}') piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1) -dhcpcdFile=/etc/dhcpcd.conf \ No newline at end of file +dhcpcdFile=/etc/dhcpcd.conf diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 857b2056..b39cdf08 100644 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -10,6 +10,7 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. +source /etc/pihole/Functions/pihole.var source /etc/pihole/Functions/pihole.funcs if [[ $# = 0 ]]; then diff --git a/advanced/Scripts/updateDashboard.sh b/advanced/Scripts/updateDashboard.sh index 6955683d..35d38064 100644 --- a/advanced/Scripts/updateDashboard.sh +++ b/advanced/Scripts/updateDashboard.sh @@ -10,60 +10,35 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -WEB_INTERFACE_GIT_URL="https://github.com/pi-hole/AdminLTE.git" -WEB_INTERFACE_DIR="/var/www/html/admin" +source /etc/pihole/Functions/pihole.var +source /etc/pihole/Functions/pihole.funcs +source /etc/pihole/Functions/git.funcs main() { prerequisites - if ! is_repo; then - make_repo + if ! is_repo $webInterfaceDir; then + make_repo $webInterfaceDir $webInterfaceGitUrl fi - update_repo + update_repo $webInterfaceDir } prerequisites() { - - # must be root to update - if [[ $EUID -ne 0 ]]; then - sudo bash "$0" "$@" - exit $? - fi - - # web interface must already exist. this is a (lazy) - # check to make sure pihole is actually installed. - if [ ! -d "$WEB_INTERFACE_DIR" ]; then - echo "$WEB_INTERFACE_DIR not found. Exiting." - exit 1 - fi - - if ! type "git" > /dev/null; then - apt-get -y install git - fi -} - -is_repo() { - # if the web interface directory does not have a .git folder - # it means its using the master.zip archive from the install - # script. - if [ ! -d "$WEB_INTERFACE_DIR/.git" ]; then - return 1 - fi - return 0 -} - -# removes the web interface installed from the master.zip archive and -# replaces it with the current master branch from github -make_repo() { - # remove the non-repod interface and clone the interface - rm -rf $WEB_INTERFACE_DIR - git clone "$WEB_INTERFACE_GIT_URL" "$WEB_INTERFACE_DIR" -} - -# pulls the latest master branch from github -update_repo() { - # pull the latest commits - cd "$WEB_INTERFACE_DIR" - git pull + # must be root to update + if [[ $EUID -ne 0 ]]; then + sudo bash "$0" "$@" + exit $? + fi + + # web interface must already exist. this is a (lazy) + # check to make sure pihole is actually installed. + if [ ! -d "$webInterfaceDir" ]; then + echo "$webInterfaceDir not found. Exiting." + exit 1 + fi + + if ! type "git" > /dev/null; then + apt-get -y install git + fi } main diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index fe914c6f..98a85628 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -10,6 +10,7 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. +source /etc/pihole/Functions/pihole.var source /etc/pihole/Functions/pihole.funcs if [[ $# = 0 ]]; then diff --git a/automated install/install.sh b/automated install/install.sh index 9495b991..266bb5af 100755 --- a/automated install/install.sh +++ b/automated install/install.sh @@ -11,14 +11,19 @@ # (at your option) any later version. # Get files, as they might have changed -curl -o $HOME/piholeInstall/pihole.var https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/Functions/pihole.var -curl -o $HOME/piholeInstall/pihole.funcs https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/Functions/pihole.funcs -curl -o $HOME/piholeInstall/install.funcs https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/Functions/install.funcs -curl -o $HOME/piholeInstall/git.funcs https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/Functions/git.funcs +if [ ! -d /tmp/piholeInstall ]; then + mkdir -p /tmp/piholeInstall +fi -source $HOME/piholeInstall/pihole.funcs -source $HOME/piholeInstall/install.funcs -source $HOME/piholeInstall/git.funcs +curl -o /tmp/piholeInstall/pihole.var https://raw.githubusercontent.com/pi-hole/pi-hole/ExportVariables/advanced/Functions/pihole.var +#curl -o /tmp/piholeInstall/pihole.funcs https://raw.githubusercontent.com/pi-hole/pi-hole/ExportVariables/advanced/Functions/pihole.funcs +curl -o /tmp/piholeInstall/install.funcs https://raw.githubusercontent.com/pi-hole/pi-hole/ExportVariables/advanced/Functions/install.funcs +curl -o /tmp/piholeInstall/git.funcs https://raw.githubusercontent.com/pi-hole/pi-hole/ExportVariables/advanced/Functions/git.funcs + +source /tmp/piholeInstall/pihole.var +source /tmp/piholeInstall/pihole.funcs +source /tmp/piholeInstall/install.funcs +source /tmp/piholeInstall/git.funcs ###########Begin Script RootCheck @@ -27,7 +32,7 @@ if [ ! -d /etc/pihole ];then $SUDO mkdir -p /etc/pihole/ fi -#Display the welcome dialogs +# Display the welcome dialogs welcomeDialogs # Just back up the original Pi-hole right away since it won't take long and it gets it out of the way @@ -50,4 +55,4 @@ displayFinalMessage # Start services $SUDO service dnsmasq start -$SUDO service lighttpd start \ No newline at end of file +$SUDO service lighttpd start