1st commit
This commit is contained in:
41
lan.list
Normal file
41
lan.list
Normal file
@@ -0,0 +1,41 @@
|
||||
192.168.2.1 asus.photos-nas.ovh asus
|
||||
192.168.2.1 www.asusrouter.com et12
|
||||
192.168.2.57 airdrop.photos-nas.ovh airdrop
|
||||
192.168.2.57 books.photos-nas.ovh books
|
||||
192.168.2.57 change.photos-nas.ovh changedetection
|
||||
192.168.2.57 chibisafe.photos-nas.ovh chibisafe
|
||||
192.168.2.57 dockge.photos-nas.ovh dockge
|
||||
192.168.2.57 docspell.photos-nas.ovh docspell
|
||||
192.168.2.57 dozzle.photos-nas.ovh dozzle
|
||||
192.168.2.57 ds923.photos-nas.ovh dsm
|
||||
192.168.2.57 glances.photos-nas.ovh glances
|
||||
192.168.2.57 gokapi.photos-nas.ovh gokapi
|
||||
192.168.2.57 gotify.photos-nas.ovh gotify
|
||||
192.168.2.57 igotify.photos-nas.ovh gotify-api
|
||||
192.168.2.57 invidious.photos-nas.ovh invidious
|
||||
192.168.2.57 maloja.photos-nas.ovh maloja
|
||||
192.168.2.57 maps-server.photos-nas.ovh maps-server
|
||||
192.168.2.57 maps.photos-nas.ovh maps
|
||||
192.168.2.57 menu.photos-nas.ovh heimdall
|
||||
192.168.2.57 navidrome.photos-nas.ovh navidrome
|
||||
192.168.2.57 nextcloud.photos-nas.ovh nextcloud
|
||||
192.168.2.57 notif.photos-nas.ovh nfty
|
||||
192.168.2.57 paperlessngx.photos-nas.ovh paperlessngx
|
||||
192.168.2.57 pastebin.photos-nas.ovh pastebin
|
||||
192.168.2.57 pastefy.photos-nas.ovh pastefy
|
||||
192.168.2.57 photos.photos-nas.ovh photos
|
||||
192.168.2.57 pingvin.photos-nas.ovh pingvin
|
||||
192.168.2.57 psitransfer.photos-nas.ovh psitransfer
|
||||
192.168.2.57 seafile.photos-nas.ovh seafile
|
||||
192.168.2.57 search.photos-nas.ovh searxng
|
||||
192.168.2.57 send.photos-nas.ovh send
|
||||
192.168.2.57 snippet.photos-nas.ovh snippet
|
||||
192.168.2.57 syno-dashboard.photos-nas.ovh syno-dashboard
|
||||
192.168.2.57 tautulli.photos-nas.ovh tautulli
|
||||
192.168.2.57 test.photos-nas.ovh test
|
||||
192.168.2.57 tube.photos-nas.ovh tube
|
||||
192.168.2.57 uptime.photos-nas.ovh uptime-kuma
|
||||
192.168.2.57 vault.photos-nas.ovh vaultwarten
|
||||
192.168.2.57 yacy.photos-nas.ovh yacy
|
||||
192.168.2.116 pihole1.photos-nas.ovh dietpi1
|
||||
192.168.2.216 pihole2.photos-nas.ovh dietpi2
|
||||
23
lan_1.list
Normal file
23
lan_1.list
Normal file
@@ -0,0 +1,23 @@
|
||||
192.168.2.57 navidrome.photos-nas.ovh navidrome
|
||||
192.168.2.57 ds923.photos-nas.ovh dsm
|
||||
192.168.2.57 maloja.photos-nas.ovh maloja
|
||||
192.168.2.57 photos.photos-nas.ovh photos
|
||||
192.168.2.57 change.photos-nas.ovh changedetection
|
||||
192.168.2.57 search.photos-nas.ovh searxng
|
||||
192.168.2.57 vault.photos-nas.ovh vaultwarten
|
||||
192.168.2.57 menu.photos-nas.ovh heimdall
|
||||
192.168.2.57 notif.photos-nas.ovh nfty
|
||||
192.168.2.57 uptime.photos-nas.ovh uptime-kuma
|
||||
192.168.2.57 dozzle.photos-nas.ovh dozzle
|
||||
192.168.2.57 gotify.photos-nas.ovh gotify
|
||||
192.168.2.57 igotify.photos-nas.ovh gotify-api
|
||||
192.168.2.57 tautulli.photos-nas.ovh tautulli
|
||||
192.168.2.57 glances.photos-nas.ovh glances
|
||||
192.168.2.57 test.photos-nas.ovh test
|
||||
192.168.2.57 paperlessngx.photos-nas.ovh paperlessngx
|
||||
192.168.2.57 docspell.photos-nas.ovh docspell
|
||||
192.168.2.1 asus.photos-nas.ovh asus
|
||||
192.168.2.1 www.asusrouter.com et12
|
||||
192.168.2.116 pihole1.photos-nas.ovh dietpi1
|
||||
192.168.2.216 pihole2.photos-nas.ovh dietpi2
|
||||
|
||||
23
lan_2.list
Normal file
23
lan_2.list
Normal file
@@ -0,0 +1,23 @@
|
||||
192.168.2.57 navidrome.photos-nas.ovh navidrome
|
||||
192.168.2.57 ds923.photos-nas.ovh dsm
|
||||
192.168.2.57 maloja.photos-nas.ovh maloja
|
||||
192.168.2.57 photos.photos-nas.ovh photos
|
||||
192.168.2.57 change.photos-nas.ovh changedetection
|
||||
192.168.2.57 search.photos-nas.ovh searxng
|
||||
192.168.2.57 vault.photos-nas.ovh vaultwarten
|
||||
192.168.2.57 menu.photos-nas.ovh heimdall
|
||||
192.168.2.57 notif.photos-nas.ovh nfty
|
||||
192.168.2.57 uptime.photos-nas.ovh uptime-kuma
|
||||
192.168.2.57 dozzle.photos-nas.ovh dozzle
|
||||
192.168.2.57 gotify.photos-nas.ovh gotify
|
||||
192.168.2.57 igotify.photos-nas.ovh gotify-api
|
||||
192.168.2.57 tautulli.photos-nas.ovh tautulli
|
||||
192.168.2.57 glances.photos-nas.ovh glances
|
||||
192.168.2.57 paperlessngx.photos-nas.ovh paperlessngx
|
||||
192.168.2.57 docspell.photos-nas.ovh docspell
|
||||
192.168.2.57 test.photos-nas.ovh test
|
||||
192.168.2.1 asus.photos-nas.ovh asus
|
||||
192.168.2.1 www.asusrouter.com et12
|
||||
192.168.2.116 pihole1.photos-nas.ovh dietpi1
|
||||
192.168.2.216 pihole2.photos-nas.ovh dietpi2
|
||||
|
||||
128
sync_pihole_lan.sh
Executable file
128
sync_pihole_lan.sh
Executable file
@@ -0,0 +1,128 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
italic="\033[3m"
|
||||
underline="\033[4m"
|
||||
ita_under="\033[3;4m"
|
||||
bgd="\033[1;4;31m"
|
||||
red="\033[1;31m"
|
||||
bold="\033[1m"
|
||||
bold_ita="\033[1;3m"
|
||||
box="\033[1;41m"
|
||||
redbold="\033[1;31m"
|
||||
redbox="\033[1;41m"
|
||||
green="\033[0;32m"
|
||||
reset="\033[0m"
|
||||
|
||||
|
||||
echo -e "${bold}Backup ${italic}lan.list...${reset}"
|
||||
|
||||
ssh -p51322 root@192.168.2.116 "gzip -c cat /etc/pihole/lan.list" > lan.list.1.gz
|
||||
echo "--"
|
||||
ssh -p51522 root@192.168.2.216 "cat /etc/pihole/lan.list" > lan.list.2.gz
|
||||
|
||||
cp lan.list.bak /tmp/lan.list
|
||||
bzip2 /tmp/lan.list # lan.list.bz2
|
||||
mv /tmp/lan.list.bz2 .
|
||||
|
||||
cp lan.list lan.list.bak
|
||||
|
||||
nb_dynhost=$(awk 'END { print NR }' lan.list)
|
||||
echo "$nb_dynhost dynhost found !"
|
||||
|
||||
# nano /etc/pihole/lan.list
|
||||
|
||||
#ssh -p51322 root@192.168.2.116 "cat /etc/pihole/lan.list" > /Users/bruno/Documents/Scripts/pihole/lan_1.list
|
||||
#ssh -p51522 root@192.168.2.216 "cat /etc/pihole/lan.list" > /Users/bruno/Documents/Scripts/pihole/lan_2.list
|
||||
|
||||
|
||||
# Zones DNS -> photos-nas.ovh -> Historique des zones
|
||||
|
||||
absent=()
|
||||
not_required=("drive" "files" "gitea" "home-assistant" "homebridge" "portainer" "wg" "yatch")
|
||||
not_used=("ds916" "musiiic" "tunes")
|
||||
dynhost_list=$(cat photos-nas.ovh_dns_data.txt | grep "60 IN A" | sed '1d')
|
||||
|
||||
while IFS= read -r line; do
|
||||
|
||||
dynhost=$(echo "${line}" | awk '{print $1}')
|
||||
grep -q $dynhost lan.list
|
||||
if [ $? != 0 ]; then
|
||||
if [[ " ${not_required[*]} " != *"$dynhost"* ]] && [[ " ${not_used[*]} " != *"$dynhost"* ]]; then
|
||||
absent+=(${dynhost})
|
||||
fi
|
||||
fi
|
||||
|
||||
done <<< "$dynhost_list"
|
||||
|
||||
echo
|
||||
echo -e "${bold}Update ${italic}lan.list...${reset}"
|
||||
echo -e "${green}Not required: ${not_required[@]}${reset}"
|
||||
#echo
|
||||
echo -e "${italic}Not used: ${not_used[@]}${reset}"
|
||||
#echo
|
||||
echo -e "${red}Absent: ${absent[@]}${reset}"
|
||||
#echo
|
||||
|
||||
if [ ${#absent[@]} -ge 1 ]; then
|
||||
|
||||
[ -f temp_file.list ] && rm temp_file.list
|
||||
|
||||
for val in ${absent[@]}
|
||||
do
|
||||
echo -e "192.168.2.57 ${val}.photos-nas.ovh ${val}" >> temp_file.list
|
||||
done
|
||||
|
||||
cat temp_file.list >> lan.list
|
||||
fi
|
||||
|
||||
cat lan.list | sort -k2 > lan.list.sorted
|
||||
mv lan.list.sorted lan.list
|
||||
|
||||
echo
|
||||
echo -e "${red}Display ${italic}lan.list...${reset}"
|
||||
cat lan.list
|
||||
|
||||
nb_dynhost=$(awk 'END { print NR }' lan.list)
|
||||
echo "$nb_dynhost dynhost !"
|
||||
|
||||
[ ${#absent[@]} -eq 0 ] && echo -e "\n${green}No new dynhost !${reset}"
|
||||
a=$(echo -e "Do you want to export ${italic}lan.list${reset} to ${bold}pihole1${reset} and ${bold}pihole2${reset} ? (y/n)")
|
||||
read -p "$a" choice
|
||||
if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then
|
||||
|
||||
#curl -Is https://google.com | head -1 | grep 200 1>/dev/null
|
||||
#curl -Is https://1.1.1.1 | head -1 | grep 302 1>/dev/null
|
||||
cat < /dev/null > /dev/tcp/1.1.1.1/53
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo -e "\n${red}No Internet connection !${reset}"
|
||||
echo -e "Exit !"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#echo "Export to pihole1..."
|
||||
#cat lan.list | ssh -p51322 root@192.168.2.116 'cat > /etc/pihole/lan.list && pihole restartdns'
|
||||
#[ $? != 0 ] && echo -e "${red}Error during transfer to pihole1 (192.168.2.116)${reset}" || echo -e "${green}Ok${reset}"
|
||||
echo "Export to pihole1..."
|
||||
cat lan.list | ssh -p51322 root@192.168.2.116 'cat > /etc/pihole/lan.list'
|
||||
[ $? != 0 ] && echo -e "${red}Error during transfer to pihole1 (192.168.2.116)${reset}" || echo -e "${green}Ok${reset}"
|
||||
|
||||
echo "Restarting dns on pihole1..."
|
||||
ssh -p51322 root@192.168.2.116 'pihole restartdns'
|
||||
[ $? != 0 ] && echo -e "${red}Error during restarting dns on pihole1 (192.168.2.116)${reset}" || echo -e "${green}Ok${reset}"
|
||||
|
||||
echo "Export to pihole2..."
|
||||
cat lan.list | ssh -p51522 root@192.168.2.216 'cat > /etc/pihole/lan.list'
|
||||
[ $? != 0 ] && echo -e "${red}Error during transfer to pihole2 (192.168.2.216)${reset}" || echo -e "${green}Ok${reset}"
|
||||
|
||||
echo "Restarting dns on pihole2..."
|
||||
ssh -p51522 root@192.168.2.216 'pihole restartdns'
|
||||
[ $? != 0 ] && echo -e "${red}Error during restarting dns on pihole2 (192.168.2.216)${reset}" || echo -e "${green}Ok${reset}"
|
||||
fi
|
||||
|
||||
[ -f temp_file.list ] && rm temp_file.list
|
||||
[ -f lan.list.sorted ] && rm lan.list.sorted
|
||||
|
||||
|
||||
#cat ~/Documents/Scripts/pihole/lan.list
|
||||
|
||||
# dockge syno-dashboard yacy
|
||||
88
update_pihole.sh
Executable file
88
update_pihole.sh
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Verify pihole version (run pihole -v) and send a notfication to Gotify
|
||||
|
||||
italic="\033[3m"
|
||||
underline="\033[4m"
|
||||
ita_under="\033[3;4m"
|
||||
bgd="\033[1;4;31m"
|
||||
red="\033[1;31m"
|
||||
green="\033[1;32m"
|
||||
bold="\033[1m"
|
||||
box="\033[1;41m"
|
||||
reset="\033[0m"
|
||||
|
||||
command -v pihole >/dev/null 2>&1 || { echo -e "${bold}pihole${reset} is not installed. Aborting..." >&2; exit 1; }
|
||||
|
||||
curl -Is https://www.apple.com | head -1 | grep 200 1>/dev/null
|
||||
if [[ $? -eq 1 ]]; then
|
||||
echo -e "\n${red}No Internet connection !${reset}"
|
||||
echo -e "Exit !"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dotenv () {
|
||||
set -a
|
||||
# shellcheck disable=SC1091
|
||||
[ -f ".env" ] && . ".env" || echo -e "${red}\nNo .env file found ! No token for gotify.${reset}"
|
||||
set +a
|
||||
}
|
||||
|
||||
dotenv
|
||||
|
||||
gotify_server="https://gotify.photos-nas.ovh"
|
||||
host=$(hostname)
|
||||
available=false
|
||||
msg=
|
||||
infos=
|
||||
|
||||
echo -e "${box}Find Pi-hole update on $host${reset}\n"
|
||||
|
||||
upd=$(pihole -v)
|
||||
#upd=$(cat 'update_pihole.txt')
|
||||
|
||||
printf " \e[1m%-10s \e[1m%-10s \e[1m%-10s \n" "Pi-hole" "Current" "Last"
|
||||
|
||||
while IFS= read -r line; do
|
||||
|
||||
app=$(echo "${line}" | awk '{print $1}')
|
||||
current=$(echo "${line}" | awk '{print $4}')
|
||||
last=$(echo "${line}" | awk '{print $6}' | sed 's/.$//')
|
||||
|
||||
if [ "$current" != "$last" ]; then
|
||||
printf " \e[1;31m%-10s\e[0m \e[1;31m%-10s\e[0m \e[1;31m%-10s\e[0m \n" "${app}" "${current}" "${last}"
|
||||
msg+="**${app}: current:${current} last:${last}**\n"
|
||||
available=true
|
||||
infos+="https://github.com/pi-hole/${app}/releases/tag/${last}\n"
|
||||
else
|
||||
printf " \e[1;32m%-10s\e[0m \e[1;32m%-10s\e[0m \e[1;32m%-10s\e[0m \n" "${app}" "${current}" "${last}"
|
||||
msg+="${app}: current:${current} last:${last}\n"
|
||||
fi
|
||||
|
||||
done <<< "$upd"
|
||||
|
||||
echo -e "\n$infos"
|
||||
|
||||
if [ "$available" = true ];then
|
||||
|
||||
if [ ! -t 0 ]; then
|
||||
# "I'm on a TTY, this is interactive."
|
||||
a=$(echo -e "\nPlease run ${italic}pihole -up${reset} to update ! (y/n)")
|
||||
read -p "$a" choice
|
||||
if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then
|
||||
pihole -up
|
||||
fi
|
||||
|
||||
else
|
||||
echo -e "Sending notification to $gotify_server ..."
|
||||
TITLE="Pi-hole on $host update"
|
||||
MESSAGE="**A new version of Pi-hole is available:**\n\n $msg\n\n $infos\n\n Please run *pihole -up* on $host to update !"
|
||||
PRIORITY=8
|
||||
URL="$gotify_server/message?token=$token&?format=markdown"
|
||||
|
||||
curl -s -S --output /dev/null --data '{"message": "'"${MESSAGE}"'", "title": "'"${TITLE}"'", "priority":'"${PRIORITY}"', "extras": {"client::display": {"contentType": "text/markdown"}}}' -H 'Content-Type: application/json' "$URL"
|
||||
fi
|
||||
|
||||
else
|
||||
echo -e "\nNo available update !"
|
||||
fi
|
||||
Reference in New Issue
Block a user