1
0
mirror of https://github.com/pi-hole/pi-hole synced 2025-01-05 05:30:55 +00:00

Merge branch 'development' into adminPageAsOption

This commit is contained in:
Mcat12 2017-02-09 16:27:07 -05:00 committed by GitHub
commit ba67144e34
4 changed files with 48 additions and 24 deletions

View File

@ -42,14 +42,14 @@ helpFunc() {
::: Usage: pihole -${letter} domain1 [domain2 ...] ::: Usage: pihole -${letter} domain1 [domain2 ...]
::: :::
::: Options: ::: Options:
::: -d, --delmode Remove domains from the ${word}list ::: -d, --delmode Remove domains from the ${word}list
::: -nr, --noreload Update ${word}list without refreshing dnsmasq ::: -nr, --noreload Update ${word}list without refreshing dnsmasq
::: -q, --quiet output is less verbose ::: -q, --quiet Output is less verbose
::: -h, --help Show this help dialog ::: -h, --help Show this help dialog
::: -l, --list Display your ${word}listed domains ::: -l, --list Display your ${word}listed domains
EOM EOM
if [[ "${letter}" == "b" ]]; then if [[ "${letter}" == "b" ]]; then
echo "::: -wild, --wildcard Add whitecard entry (only blacklist)" echo "::: -wild, --wildcard Add wildcard entry (only blacklist)"
fi fi
exit 0 exit 0
} }
@ -229,4 +229,3 @@ PoplistFile
if ${reload}; then if ${reload}; then
Reload Reload
fi fi

View File

@ -79,8 +79,8 @@ if command -v apt-get &> /dev/null; then
phpVer="php5" phpVer="php5"
fi fi
# ######################################### # #########################################
INSTALLER_DEPS=(apt-utils debconf dhcpcd5 git whiptail) INSTALLER_DEPS=(apt-utils debconf dhcpcd5 git ${iproute_pkg} whiptail)
PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils ${iproute_pkg} iputils-ping lsof netcat sudo unzip wget) PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils iputils-ping lsof netcat sudo unzip wget)
PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi) PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi)
LIGHTTPD_USER="www-data" LIGHTTPD_USER="www-data"
LIGHTTPD_GROUP="www-data" LIGHTTPD_GROUP="www-data"
@ -174,11 +174,9 @@ getGitFiles() {
echo ":::" echo ":::"
echo "::: Checking for existing repository..." echo "::: Checking for existing repository..."
if is_repo "${directory}"; then if is_repo "${directory}"; then
echo -n "::: Updating repository in ${directory}..."
update_repo "${directory}" || { echo "*** Error: Could not update local repository. Contact support."; exit 1; } update_repo "${directory}" || { echo "*** Error: Could not update local repository. Contact support."; exit 1; }
echo " done!" echo " done!"
else else
echo -n "::: Cloning ${remoteRepo} into ${directory}..."
make_repo "${directory}" "${remoteRepo}" || { echo "Unable to clone repository, please contact support"; exit 1; } make_repo "${directory}" "${remoteRepo}" || { echo "Unable to clone repository, please contact support"; exit 1; }
echo " done!" echo " done!"
fi fi
@ -726,7 +724,7 @@ enable_service() {
echo " done." echo " done."
} }
update_pacakge_cache() { update_package_cache() {
#Running apt-get update/upgrade with minimal output can cause some issues with #Running apt-get update/upgrade with minimal output can cause some issues with
#requiring user input (e.g password for phpmyadmin see #218) #requiring user input (e.g password for phpmyadmin see #218)
@ -735,8 +733,11 @@ update_pacakge_cache() {
echo ":::" echo ":::"
echo -n "::: Updating local cache of available packages..." echo -n "::: Updating local cache of available packages..."
${UPDATE_PKG_CACHE} &> /dev/null if eval ${UPDATE_PKG_CACHE} &> /dev/null; then
echo " done!" echo " done!"
else
echo -n "\n!!! ERROR - Unable to update package cache. Please try \"${UPDATE_PKG_CACHE}\""
fi
} }
notify_package_updates_available() { notify_package_updates_available() {
@ -1203,7 +1204,7 @@ main() {
fi fi
# Update package cache # Update package cache
update_pacakge_cache update_package_cache
# Notify user of package availability # Notify user of package availability
notify_package_updates_available notify_package_updates_available

19
pihole
View File

@ -274,19 +274,20 @@ helpFunc() {
::: Add -h after -w (whitelist), -b (blacklist), -c (chronometer), or -a (admin) for more information on usage ::: Add -h after -w (whitelist), -b (blacklist), -c (chronometer), or -a (admin) for more information on usage
::: :::
::: Options: ::: Options:
::: -w, whitelist Whitelist domains ::: -w, whitelist Whitelist domain(s)
::: -b, blacklist Blacklist domains ::: -b, blacklist Blacklist domain(s) (exact match)
::: -d, debug Start a debugging session if having trouble ::: -wild, wildcard Blacklist whole domain(s) (wildcard)
::: -f, flush Flush the pihole.log file ::: -d, debug Start a debugging session
::: -t, tail Output the last lines of the pihole.log file. Lines are appended as the file grows ::: -f, flush Flush the 'pihole.log' file
::: -up, updatePihole Update Pi-hole ::: -t, tail Output the last lines of the 'pihole.log' file. Lines are appended as the file grows
::: -up, updatePihole Update Pi-hole components
::: -r, reconfigure Reconfigure or Repair Pi-hole ::: -r, reconfigure Reconfigure or Repair Pi-hole
::: -g, updateGravity Update the list of ad-serving domains ::: -g, updateGravity Update the list of ad-serving domains
::: -c, chronometer Calculates stats and displays to an LCD ::: -c, chronometer Calculates stats and displays to an LCD
::: -h, help Show this help dialog ::: -h, help Show this help dialog
::: -v, version Show current versions ::: -v, version Show installed versions of Pi-Hole and Web-Admin
::: -q, query Query the adlists for a specific domain ::: -q, query Query the adlists for a specific domain
::: Use pihole -q domain -exact if you want to see exact matches only ::: Use 'pihole -q domain -exact' if you want to see exact matches only
::: -l, logging Enable or Disable logging (pass 'on' or 'off') ::: -l, logging Enable or Disable logging (pass 'on' or 'off')
::: -a, admin Admin webpage options ::: -a, admin Admin webpage options
::: uninstall Uninstall Pi-Hole from your system :(! ::: uninstall Uninstall Pi-Hole from your system :(!
@ -294,7 +295,7 @@ helpFunc() {
::: enable Enable Pi-Hole DNS Blocking ::: enable Enable Pi-Hole DNS Blocking
::: disable Disable Pi-Hole DNS Blocking ::: disable Disable Pi-Hole DNS Blocking
::: Blocking can also be disabled only temporarily, e.g., ::: Blocking can also be disabled only temporarily, e.g.,
::: pihole disable 5m - will disable blocking for 5 minutes ::: 'pihole disable 5m' - will disable blocking for 5 minutes
::: restartdns Restart dnsmasq ::: restartdns Restart dnsmasq
EOM EOM
exit 0 exit 0

View File

@ -274,6 +274,29 @@ def test_installPiholeWeb_already_populated_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_update_package_cache_success_no_errors(Pihole):
''' confirms package cache was updated without any errors'''
updateCache = Pihole.run('''
source /opt/pihole/basic-install.sh
distro_check
update_package_cache
''')
assert 'Updating local cache of available packages...' in updateCache.stdout
assert 'ERROR' not in updateCache.stdout
assert 'done!' in updateCache.stdout
def test_update_package_cache_failure_no_errors(Pihole):
''' confirms package cache was not updated'''
mock_command('apt-get', {'update':('', '1')}, Pihole)
updateCache = Pihole.run('''
source /opt/pihole/basic-install.sh
distro_check
update_package_cache
''')
assert 'Updating local cache of available packages...' in updateCache.stdout
assert 'ERROR' in updateCache.stdout
assert 'done!' not in updateCache.stdout
# Helper functions # Helper functions
def mock_command(script, args, container): def mock_command(script, args, container):
''' Allows for setup of commands we don't really want to have to run for real in unit tests ''' ''' Allows for setup of commands we don't really want to have to run for real in unit tests '''