|
|
|
@ -154,7 +154,12 @@ if command -v apt-get &> /dev/null; then
|
|
|
|
|
# fall back on the php5 packages
|
|
|
|
|
phpVer="php5"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# We also need the correct version for `php-sqlite` (which differs across distros)
|
|
|
|
|
if ${PKG_MANAGER} install --dry-run ${phpVer}-sqlite3 > /dev/null 2>&1; then
|
|
|
|
|
phpSqlite="sqlite3"
|
|
|
|
|
else
|
|
|
|
|
phpSqlite="sqlite"
|
|
|
|
|
fi
|
|
|
|
|
# Since our install script is so large, we need several other programs to successfuly get a machine provisioned
|
|
|
|
|
# These programs are stored in an array so they can be looped through later
|
|
|
|
|
INSTALLER_DEPS=(apt-utils dialog debconf dhcpcd5 git ${iproute_pkg} whiptail)
|
|
|
|
@ -162,7 +167,7 @@ if command -v apt-get &> /dev/null; then
|
|
|
|
|
PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils iputils-ping lsof netcat sudo unzip wget)
|
|
|
|
|
# The Web dashboard has some that also need to be installed
|
|
|
|
|
# It's useful to separate the two since our repos are also setup as "Core" code and "Web" code
|
|
|
|
|
PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi)
|
|
|
|
|
PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi ${phpVer}-${phpSqlite})
|
|
|
|
|
# The Web server user,
|
|
|
|
|
LIGHTTPD_USER="www-data"
|
|
|
|
|
# group,
|
|
|
|
@ -172,22 +177,22 @@ if command -v apt-get &> /dev/null; then
|
|
|
|
|
# The DNS server user
|
|
|
|
|
DNSMASQ_USER="dnsmasq"
|
|
|
|
|
|
|
|
|
|
# A function to check...
|
|
|
|
|
test_dpkg_lock() {
|
|
|
|
|
# An iterator used for counting loop iterations
|
|
|
|
|
i=0
|
|
|
|
|
# fuser is a program to show which processes use the named files, sockets, or filesystems
|
|
|
|
|
# So while the command is true
|
|
|
|
|
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
|
|
|
|
|
# Wait half a second
|
|
|
|
|
sleep 0.5
|
|
|
|
|
# and increase the iterator
|
|
|
|
|
((i=i+1))
|
|
|
|
|
done
|
|
|
|
|
# Always return success, since we only return if there is no
|
|
|
|
|
# lock (anymore)
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
# A function to check...
|
|
|
|
|
test_dpkg_lock() {
|
|
|
|
|
# An iterator used for counting loop iterations
|
|
|
|
|
i=0
|
|
|
|
|
# fuser is a program to show which processes use the named files, sockets, or filesystems
|
|
|
|
|
# So while the command is true
|
|
|
|
|
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
|
|
|
|
|
# Wait half a second
|
|
|
|
|
sleep 0.5
|
|
|
|
|
# and increase the iterator
|
|
|
|
|
((i=i+1))
|
|
|
|
|
done
|
|
|
|
|
# Always return success, since we only return if there is no
|
|
|
|
|
# lock (anymore)
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# If apt-get is not found, check for rpm to see if it's a Red Hat family OS
|
|
|
|
|
elif command -v rpm &> /dev/null; then
|
|
|
|
@ -204,7 +209,7 @@ elif command -v rpm &> /dev/null; then
|
|
|
|
|
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
|
|
|
|
|
INSTALLER_DEPS=(dialog git iproute net-tools newt procps-ng)
|
|
|
|
|
PIHOLE_DEPS=(bc bind-utils cronie curl dnsmasq findutils nmap-ncat sudo unzip wget)
|
|
|
|
|
PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php php-common php-cli)
|
|
|
|
|
PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php php-common php-cli php-pdo)
|
|
|
|
|
if ! grep -q 'Fedora' /etc/redhat-release; then
|
|
|
|
|
INSTALLER_DEPS=("${INSTALLER_DEPS[@]}" "epel-release");
|
|
|
|
|
fi
|
|
|
|
@ -1077,6 +1082,10 @@ installConfigs() {
|
|
|
|
|
fi
|
|
|
|
|
# and copy in the config file Pi-hole needs
|
|
|
|
|
cp ${PI_HOLE_LOCAL_REPO}/advanced/${LIGHTTPD_CFG} /etc/lighttpd/lighttpd.conf
|
|
|
|
|
# if there is a custom block page in the html/pihole directory, replace 404 handler in lighttpd config
|
|
|
|
|
if [[ -f "/var/www/html/pihole/custom.php" ]]; then
|
|
|
|
|
sed -i 's/^\(server\.error-handler-404\s*=\s*\).*$/\1"pihole\/custom\.php"/' /etc/lighttpd/lighttpd.conf
|
|
|
|
|
fi
|
|
|
|
|
# Make the directories if they do not exist and set the owners
|
|
|
|
|
mkdir -p /var/run/lighttpd
|
|
|
|
|
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/run/lighttpd
|
|
|
|
@ -1288,68 +1297,27 @@ CreateLogFile() {
|
|
|
|
|
installPiholeWeb() {
|
|
|
|
|
echo ""
|
|
|
|
|
echo " ${INFO} Installing blocking page..."
|
|
|
|
|
# If the pihole Web directory exists,
|
|
|
|
|
if [[ -d "/var/www/html/pihole" ]]; then
|
|
|
|
|
local str="Installing index.php"
|
|
|
|
|
echo -ne " ${INFO} ${str}..."
|
|
|
|
|
# and if the index file exists,
|
|
|
|
|
if [[ -f "/var/www/html/pihole/index.php" ]]; then
|
|
|
|
|
# do not overwrite it,
|
|
|
|
|
echo -e " ${COL_LIGHT_GREEN}detected index.php, not overwriting${COL_NC}"
|
|
|
|
|
# if it doesn't exist
|
|
|
|
|
else
|
|
|
|
|
# install it by copying it from the repo
|
|
|
|
|
cp ${PI_HOLE_LOCAL_REPO}/advanced/index.php /var/www/html/pihole/
|
|
|
|
|
echo -e "${OVER} ${TICK} ${str}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local str="Installing index.js"
|
|
|
|
|
echo -ne " ${INFO} ${str}..."
|
|
|
|
|
# and if the index file exists,
|
|
|
|
|
if [[ -f "/var/www/html/pihole/index.js" ]]; then
|
|
|
|
|
# do not overwrite it,
|
|
|
|
|
echo -e " ${COL_LIGHT_GREEN}detected index.js, not overwriting${COL_NC}"
|
|
|
|
|
else
|
|
|
|
|
# install it by copying it from the repo
|
|
|
|
|
cp ${PI_HOLE_LOCAL_REPO}/advanced/index.js /var/www/html/pihole/
|
|
|
|
|
echo -e "${OVER} ${TICK} ${str}"
|
|
|
|
|
fi
|
|
|
|
|
local str="Creating directory for blocking page, and copying files"
|
|
|
|
|
echo -ne " ${INFO} ${str}..."
|
|
|
|
|
# Install the directory
|
|
|
|
|
install -d /var/www/html/pihole
|
|
|
|
|
# and the blockpage
|
|
|
|
|
install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* /var/www/html/pihole/
|
|
|
|
|
echo -e "${OVER} ${TICK} ${str}"
|
|
|
|
|
|
|
|
|
|
local str="Installing blockingpage.css"
|
|
|
|
|
echo -ne " ${INFO} ${str}..."
|
|
|
|
|
# and if the index file exists,
|
|
|
|
|
if [[ -f "/var/www/html/pihole/blockingpage.css" ]]; then
|
|
|
|
|
# do not overwrite it,
|
|
|
|
|
echo -e " ${COL_LIGHT_GREEN}detected blockingpage.css, not overwriting${COL_NC}"
|
|
|
|
|
else
|
|
|
|
|
# install it by copying it from the repo
|
|
|
|
|
cp ${PI_HOLE_LOCAL_REPO}/advanced/blockingpage.css /var/www/html/pihole
|
|
|
|
|
echo -e "${OVER} ${TICK} ${str}"
|
|
|
|
|
fi
|
|
|
|
|
# If the pihole Web directory does not exist,
|
|
|
|
|
else
|
|
|
|
|
local str="Creating directory for blocking page, and copying files"
|
|
|
|
|
echo -ne " ${INFO} ${str}..."
|
|
|
|
|
# Install the directory
|
|
|
|
|
install -d /var/www/html/pihole
|
|
|
|
|
# and the blockpage
|
|
|
|
|
install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* /var/www/html/pihole/
|
|
|
|
|
local str="Backing up index.lighttpd.html"
|
|
|
|
|
echo -ne " ${INFO} ${str}..."
|
|
|
|
|
# If the default index file exists,
|
|
|
|
|
if [[ -f "/var/www/html/index.lighttpd.html" ]]; then
|
|
|
|
|
# back it up
|
|
|
|
|
mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig
|
|
|
|
|
echo -e "${OVER} ${TICK} ${str}"
|
|
|
|
|
|
|
|
|
|
local str="Backing up index.lighttpd.html"
|
|
|
|
|
echo -ne " ${INFO} ${str}..."
|
|
|
|
|
# If the default index file exists,
|
|
|
|
|
if [[ -f "/var/www/html/index.lighttpd.html" ]]; then
|
|
|
|
|
# back it up
|
|
|
|
|
mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig
|
|
|
|
|
echo -e "${OVER} ${TICK} ${str}"
|
|
|
|
|
# Othwerwise,
|
|
|
|
|
else
|
|
|
|
|
# don't do anything
|
|
|
|
|
echo -e "${OVER} ${CROSS} ${str}
|
|
|
|
|
No default index.lighttpd.html file found... not backing up"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Othwerwise,
|
|
|
|
|
else
|
|
|
|
|
# don't do anything
|
|
|
|
|
echo -e "${OVER} ${CROSS} ${str}
|
|
|
|
|
No default index.lighttpd.html file found... not backing up"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Install Sudoers file
|
|
|
|
|