mirror of
https://github.com/pi-hole/pi-hole
synced 2024-11-18 22:28:18 +00:00
Merge pull request #1688 from pi-hole/tweak/customBlockPage
Allow for Custom block page
This commit is contained in:
commit
7a1df15724
@ -1082,6 +1082,10 @@ installConfigs() {
|
|||||||
fi
|
fi
|
||||||
# and copy in the config file Pi-hole needs
|
# and copy in the config file Pi-hole needs
|
||||||
cp ${PI_HOLE_LOCAL_REPO}/advanced/${LIGHTTPD_CFG} /etc/lighttpd/lighttpd.conf
|
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
|
# Make the directories if they do not exist and set the owners
|
||||||
mkdir -p /var/run/lighttpd
|
mkdir -p /var/run/lighttpd
|
||||||
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/run/lighttpd
|
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/run/lighttpd
|
||||||
@ -1293,68 +1297,27 @@ CreateLogFile() {
|
|||||||
installPiholeWeb() {
|
installPiholeWeb() {
|
||||||
echo ""
|
echo ""
|
||||||
echo " ${INFO} Installing blocking page..."
|
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"
|
local str="Creating directory for blocking page, and copying files"
|
||||||
echo -ne " ${INFO} ${str}..."
|
echo -ne " ${INFO} ${str}..."
|
||||||
# and if the index file exists,
|
# Install the directory
|
||||||
if [[ -f "/var/www/html/pihole/index.js" ]]; then
|
install -d /var/www/html/pihole
|
||||||
# do not overwrite it,
|
# and the blockpage
|
||||||
echo -e " ${COL_LIGHT_GREEN}detected index.js, not overwriting${COL_NC}"
|
install -D ${PI_HOLE_LOCAL_REPO}/advanced/{index,blockingpage}.* /var/www/html/pihole/
|
||||||
else
|
echo -e "${OVER} ${TICK} ${str}"
|
||||||
# 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="Installing blockingpage.css"
|
local str="Backing up index.lighttpd.html"
|
||||||
echo -ne " ${INFO} ${str}..."
|
echo -ne " ${INFO} ${str}..."
|
||||||
# and if the index file exists,
|
# If the default index file exists,
|
||||||
if [[ -f "/var/www/html/pihole/blockingpage.css" ]]; then
|
if [[ -f "/var/www/html/index.lighttpd.html" ]]; then
|
||||||
# do not overwrite it,
|
# back it up
|
||||||
echo -e " ${COL_LIGHT_GREEN}detected blockingpage.css, not overwriting${COL_NC}"
|
mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig
|
||||||
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/
|
|
||||||
echo -e "${OVER} ${TICK} ${str}"
|
echo -e "${OVER} ${TICK} ${str}"
|
||||||
|
# Othwerwise,
|
||||||
local str="Backing up index.lighttpd.html"
|
else
|
||||||
echo -ne " ${INFO} ${str}..."
|
# don't do anything
|
||||||
# If the default index file exists,
|
echo -e "${OVER} ${CROSS} ${str}
|
||||||
if [[ -f "/var/www/html/index.lighttpd.html" ]]; then
|
No default index.lighttpd.html file found... not backing up"
|
||||||
# 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
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Sudoers file
|
# Install Sudoers file
|
||||||
|
@ -189,107 +189,6 @@ def test_installPiholeWeb_fresh_install_no_errors(Pihole):
|
|||||||
assert 'index.js' in web_directory
|
assert 'index.js' in web_directory
|
||||||
assert 'blockingpage.css' in web_directory
|
assert 'blockingpage.css' in web_directory
|
||||||
|
|
||||||
def test_installPiholeWeb_empty_directory_no_errors(Pihole):
|
|
||||||
''' confirms all web page assets from Core repo are installed in an emtpy directory '''
|
|
||||||
installWeb = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
mkdir -p /var/www/html/pihole
|
|
||||||
installPiholeWeb
|
|
||||||
''')
|
|
||||||
assert info_box + ' Installing blocking page...' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing index.php' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing index.js' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing blockingpage.css' in installWeb.stdout
|
|
||||||
assert 'No default index.lighttpd.html file found... not backing up' not in installWeb.stdout
|
|
||||||
assert tick_box + ' Installing sudoer file' in installWeb.stdout
|
|
||||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
|
||||||
assert 'index.php' in web_directory
|
|
||||||
assert 'index.js' in web_directory
|
|
||||||
assert 'blockingpage.css' in web_directory
|
|
||||||
|
|
||||||
def test_installPiholeWeb_index_php_no_errors(Pihole):
|
|
||||||
''' confirms all web page assets from Core repo are installed when necessary '''
|
|
||||||
installWeb = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
mkdir -p /var/www/html/pihole
|
|
||||||
touch /var/www/html/pihole/index.php
|
|
||||||
installPiholeWeb
|
|
||||||
''')
|
|
||||||
assert info_box + ' Installing blocking page...' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing index.php' in installWeb.stdout
|
|
||||||
assert 'detected index.php, not overwriting' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing index.js' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing blockingpage.css' in installWeb.stdout
|
|
||||||
assert 'No default index.lighttpd.html file found... not backing up' not in installWeb.stdout
|
|
||||||
assert tick_box + ' Installing sudoer file' in installWeb.stdout
|
|
||||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
|
||||||
assert 'index.php' in web_directory
|
|
||||||
assert 'index.js' in web_directory
|
|
||||||
assert 'blockingpage.css' in web_directory
|
|
||||||
|
|
||||||
def test_installPiholeWeb_index_js_no_errors(Pihole):
|
|
||||||
''' confirms all web page assets from Core repo are installed when necessary '''
|
|
||||||
installWeb = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
mkdir -p /var/www/html/pihole
|
|
||||||
touch /var/www/html/pihole/index.js
|
|
||||||
installPiholeWeb
|
|
||||||
''')
|
|
||||||
assert info_box + ' Installing blocking page...' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing index.php' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing index.js' in installWeb.stdout
|
|
||||||
assert 'detected index.js, not overwriting' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing blockingpage.css' in installWeb.stdout
|
|
||||||
assert 'No default index.lighttpd.html file found... not backing up' not in installWeb.stdout
|
|
||||||
assert tick_box + ' Installing sudoer file' in installWeb.stdout
|
|
||||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
|
||||||
assert 'index.php' in web_directory
|
|
||||||
assert 'index.js' in web_directory
|
|
||||||
assert 'blockingpage.css' in web_directory
|
|
||||||
|
|
||||||
def test_installPiholeWeb_blockingpage_css_no_errors(Pihole):
|
|
||||||
''' confirms all web page assets from Core repo are installed when necessary '''
|
|
||||||
installWeb = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
mkdir -p /var/www/html/pihole
|
|
||||||
touch /var/www/html/pihole/blockingpage.css
|
|
||||||
installPiholeWeb
|
|
||||||
''')
|
|
||||||
assert info_box + ' Installing blocking page...' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing index.php' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing index.js' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing blockingpage.css' in installWeb.stdout
|
|
||||||
assert 'detected blockingpage.css, not overwriting' in installWeb.stdout
|
|
||||||
assert 'No default index.lighttpd.html file found... not backing up' not in installWeb.stdout
|
|
||||||
assert tick_box + ' Installing sudoer file' in installWeb.stdout
|
|
||||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
|
||||||
assert 'index.php' in web_directory
|
|
||||||
assert 'index.js' in web_directory
|
|
||||||
assert 'blockingpage.css' in web_directory
|
|
||||||
|
|
||||||
def test_installPiholeWeb_already_populated_no_errors(Pihole):
|
|
||||||
''' confirms all web page assets from Core repo are installed when necessary '''
|
|
||||||
installWeb = Pihole.run('''
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
mkdir -p /var/www/html/pihole
|
|
||||||
touch /var/www/html/pihole/index.php
|
|
||||||
touch /var/www/html/pihole/index.js
|
|
||||||
touch /var/www/html/pihole/blockingpage.css
|
|
||||||
installPiholeWeb
|
|
||||||
''')
|
|
||||||
assert info_box + ' Installing blocking page...' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing index.php' in installWeb.stdout
|
|
||||||
assert 'detected index.php, not overwriting' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing index.js' in installWeb.stdout
|
|
||||||
assert 'detected index.js, not overwriting' in installWeb.stdout
|
|
||||||
assert info_box + ' Installing blockingpage.css' in installWeb.stdout
|
|
||||||
assert 'detected blockingpage.css, not overwriting' in installWeb.stdout
|
|
||||||
assert tick_box + ' Installing sudoer file' in installWeb.stdout
|
|
||||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
|
||||||
assert 'index.php' in web_directory
|
|
||||||
assert 'index.js' in web_directory
|
|
||||||
assert 'blockingpage.css' in web_directory
|
|
||||||
|
|
||||||
def test_update_package_cache_success_no_errors(Pihole):
|
def test_update_package_cache_success_no_errors(Pihole):
|
||||||
''' confirms package cache was updated without any errors'''
|
''' confirms package cache was updated without any errors'''
|
||||||
updateCache = Pihole.run('''
|
updateCache = Pihole.run('''
|
||||||
|
Loading…
Reference in New Issue
Block a user