mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-09-15 13:21:15 +08:00
41
pihole
41
pihole
@ -30,10 +30,36 @@ if [ -f "${versionsfile}" ]; then
|
||||
source "${versionsfile}"
|
||||
fi
|
||||
|
||||
webpageFunc() {
|
||||
source "${PI_HOLE_SCRIPT_DIR}/webpage.sh"
|
||||
main "$@"
|
||||
exit 0
|
||||
# TODO: We can probably remove the reliance on this function too, just tell people to pihole-FTL --config webserver.api.password "password"
|
||||
SetWebPassword() {
|
||||
if [ -n "$2" ] ; then
|
||||
readonly PASSWORD="$2"
|
||||
readonly CONFIRM="${PASSWORD}"
|
||||
else
|
||||
# Prevents a bug if the user presses Ctrl+C and it continues to hide the text typed.
|
||||
# So we reset the terminal via stty if the user does press Ctrl+C
|
||||
trap '{ echo -e "\nNot changed" ; stty sane ; exit 1; }' INT
|
||||
read -s -r -p "Enter New Password (Blank for no password): " PASSWORD
|
||||
echo ""
|
||||
|
||||
if [ "${PASSWORD}" == "" ]; then
|
||||
setFTLConfigValue "webserver.api.pwhash" "" >/dev/null
|
||||
echo -e " ${TICK} Password Removed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
read -s -r -p "Confirm Password: " CONFIRM
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${PASSWORD}" == "${CONFIRM}" ] ; then
|
||||
# pihole-FTL will automatically hash the password
|
||||
setFTLConfigValue "webserver.api.password" "${PASSWORD}" >/dev/null
|
||||
echo -e " ${TICK} New password set"
|
||||
else
|
||||
echo -e " ${CROSS} Passwords don't match. Your password has not been changed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
listFunc() {
|
||||
@ -466,8 +492,7 @@ Debugging Options:
|
||||
|
||||
|
||||
Options:
|
||||
-a, admin Web interface options
|
||||
Add '-h' for more info on Web Interface usage
|
||||
setpassword set the password for the web interface
|
||||
-c, chronometer Calculates stats and displays to an LCD
|
||||
Add '-h' for more info on chronometer usage
|
||||
-g, updateGravity Update the list of ad-serving domains
|
||||
@ -526,7 +551,7 @@ case "${1}" in
|
||||
"restartdns" ) ;;
|
||||
"-g" | "updateGravity" ) need_root=0;;
|
||||
"reloaddns" ) need_root=0;;
|
||||
"-a" | "admin" ) ;;
|
||||
"setpassword" ) ;;
|
||||
"checkout" ) ;;
|
||||
"updatechecker" ) ;;
|
||||
"arpflush" ) ;;
|
||||
@ -581,7 +606,7 @@ case "${1}" in
|
||||
"disable" ) piholeEnable 0 "$2";;
|
||||
"restartdns" ) restartDNS "$2";;
|
||||
"reloaddns" ) restartDNS "reload";;
|
||||
"-a" | "admin" ) webpageFunc "$@";;
|
||||
"setpassword" ) SetWebPassword "$@";;
|
||||
"checkout" ) piholeCheckoutFunc "$@";;
|
||||
"updatechecker" ) shift; updateCheckFunc "$@";;
|
||||
"arpflush" ) arpFunc "$@";;
|
||||
|
Reference in New Issue
Block a user