-
-
Save slmingol/018b4331fce2b836a3039c649cc2a4b3 to your computer and use it in GitHub Desktop.
pihole-timeout.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Simple script to change admin login timeout in pihole version 5.17 and up. | |
# Note that some versions of pihole used 'loginpage.php' instead of 'login.php' | |
# make the script executeable by typing: | |
# chmod +x pihole-timeout.sh | |
# run it by typing: | |
# sudo ./pihole-timeout.sh | |
# Check if user is using sudo or is root: | |
if [[ $(/usr/bin/id -u) -ne 0 ]]; then | |
echo "" | |
echo -e "Please run script with \033[0;1msudo "$0"\033[0m or as root." | |
echo "" | |
exit $? | |
fi | |
# Allow custom user input, defaulting to 30: | |
read -p "Enter admin login timeout in days (default is 7): " -i 30 -e timeoutdays | |
# Set up variables with old and new lines (and variables for timeout) | |
origpassstring='time() + 60 \* 60 \* 24 \* 7' # original string in password.php | |
newpassstring="time() + 60 \* 60 \* 24 \* $timeoutdays" # replacement string for password.php | |
origloginstring="Remember me for 7 days" # original string in login.php | |
newloginstring="Remember me for $timeoutdays days" # replacement string for login.php | |
# do the replacements and save a backup with the extension .bak | |
sed -i.bak 's/'"$origpassstring"'/'"$newpassstring"'/g' /var/www/html/admin/scripts/pi-hole/php/password.php | |
sed -i.bak 's/'"$origloginstring"'/'"$newloginstring"'/g' /var/www/html/admin/login.php | |
echo "User will remain logged in for" $timeoutdays "days." # visual feedback | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment