Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 296e7dd0a7 |
3
lan.list
3
lan.list
@@ -4,6 +4,7 @@
|
|||||||
192.168.2.57 books.photos-nas.ovh books
|
192.168.2.57 books.photos-nas.ovh books
|
||||||
192.168.2.57 change.photos-nas.ovh changedetection
|
192.168.2.57 change.photos-nas.ovh changedetection
|
||||||
192.168.2.57 chibisafe.photos-nas.ovh chibisafe
|
192.168.2.57 chibisafe.photos-nas.ovh chibisafe
|
||||||
|
192.168.2.57 dcommander.photos-nas.ovh dcommander
|
||||||
192.168.2.57 dockge.photos-nas.ovh dockge
|
192.168.2.57 dockge.photos-nas.ovh dockge
|
||||||
192.168.2.57 docspell.photos-nas.ovh docspell
|
192.168.2.57 docspell.photos-nas.ovh docspell
|
||||||
192.168.2.57 dozzle.photos-nas.ovh dozzle
|
192.168.2.57 dozzle.photos-nas.ovh dozzle
|
||||||
@@ -13,7 +14,9 @@
|
|||||||
192.168.2.57 gokapi.photos-nas.ovh gokapi
|
192.168.2.57 gokapi.photos-nas.ovh gokapi
|
||||||
192.168.2.57 gotify.photos-nas.ovh gotify
|
192.168.2.57 gotify.photos-nas.ovh gotify
|
||||||
192.168.2.57 igotify.photos-nas.ovh gotify-api
|
192.168.2.57 igotify.photos-nas.ovh gotify-api
|
||||||
|
192.168.2.57 immich.photos-nas.ovh immich
|
||||||
192.168.2.57 invidious.photos-nas.ovh invidious
|
192.168.2.57 invidious.photos-nas.ovh invidious
|
||||||
|
192.168.2.57 it-tools.photos-nas.ovh it-tools
|
||||||
192.168.2.57 maloja.photos-nas.ovh maloja
|
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-server.photos-nas.ovh maps-server
|
||||||
192.168.2.57 maps.photos-nas.ovh maps
|
192.168.2.57 maps.photos-nas.ovh maps
|
||||||
|
|||||||
54
subdomains.photos-nas.ovh.txt
Normal file
54
subdomains.photos-nas.ovh.txt
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
airdrop
|
||||||
|
asus
|
||||||
|
books
|
||||||
|
change
|
||||||
|
chibisafe
|
||||||
|
dcommander
|
||||||
|
dockge
|
||||||
|
docspell
|
||||||
|
dozzle
|
||||||
|
drive
|
||||||
|
ds916
|
||||||
|
ds923
|
||||||
|
files
|
||||||
|
git
|
||||||
|
gitea
|
||||||
|
glances
|
||||||
|
gokapi
|
||||||
|
gotify
|
||||||
|
home-assistant
|
||||||
|
homebridge
|
||||||
|
igotify
|
||||||
|
immich
|
||||||
|
invidious
|
||||||
|
it-tools
|
||||||
|
maloja
|
||||||
|
maps-server
|
||||||
|
maps
|
||||||
|
menu
|
||||||
|
musiiic
|
||||||
|
navidrome
|
||||||
|
nextcloud
|
||||||
|
notif
|
||||||
|
paperlessngx
|
||||||
|
pastebin
|
||||||
|
photos
|
||||||
|
pihole1
|
||||||
|
pihole2
|
||||||
|
pingvin
|
||||||
|
portainer
|
||||||
|
psitransfer
|
||||||
|
seafile
|
||||||
|
search
|
||||||
|
send
|
||||||
|
snippet
|
||||||
|
syno-dashboard
|
||||||
|
tautulli
|
||||||
|
test
|
||||||
|
tube
|
||||||
|
tunes
|
||||||
|
uptime
|
||||||
|
vault
|
||||||
|
wg
|
||||||
|
yacy
|
||||||
|
yatch
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Sync_pihole_lan.sh synchronise the /etc/pihole/lan.list file with your Subdomains
|
||||||
|
# v2.0
|
||||||
|
|
||||||
italic="\033[3m"
|
italic="\033[3m"
|
||||||
underline="\033[4m"
|
underline="\033[4m"
|
||||||
ita_under="\033[3;4m"
|
ita_under="\033[3;4m"
|
||||||
@@ -18,13 +21,13 @@ reset="\033[0m"
|
|||||||
absent=()
|
absent=()
|
||||||
delete=()
|
delete=()
|
||||||
domain=".photos-nas.ovh"
|
domain=".photos-nas.ovh"
|
||||||
not_required=("drive" "files" "gitea" "home-assistant" "homebridge" "portainer" "wg" "yatch")
|
not_required=("drive" "files" "gitea" "home-assistant" "homebridge" "portainer" "tunes" "wg" "yatch")
|
||||||
not_used=("ds916" "musiiic" "tunes" "notif" "pastefy")
|
not_used=("ds916" "musiiic" "notif")
|
||||||
|
|
||||||
pihole1=192.168.2.116
|
pihole1=192.168.2.116
|
||||||
pihole2=192.168.2.216
|
pihole2=192.168.2.216
|
||||||
|
|
||||||
echo -e "${greenbold}Sync_pihole_lan.sh synchronise the /etc/pihole/lan.list file with your Zones DNS ...${reset}\n"
|
echo -e "${greenbold}Sync_pihole_lan.sh synchronise the /etc/pihole/lan.list file with your Subdomains ...${reset}\n"
|
||||||
|
|
||||||
cat < /dev/null > /dev/tcp/1.1.1.1/53
|
cat < /dev/null > /dev/tcp/1.1.1.1/53
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
@@ -33,19 +36,21 @@ if [[ $? -ne 0 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sauvegarde du lan.list
|
|
||||||
|
|
||||||
echo -e "${bold}Backup ${italic}lan.list...${reset}"
|
echo -e "${bold}Backup ${italic}lan.list...${reset}"
|
||||||
|
|
||||||
|
# Sauvegarde du /etc/pihole/lan.list de chaque pihole vers lan.list.1 et lan.list.2
|
||||||
ping -q -c1 "$pihole1" &>/dev/null && ssh -p51322 root@"$pihole1" "cat /etc/pihole/lan.list" > lan.list.1 || echo -e "\n${red}Pihole1 is unreachable !'${reset}"
|
ping -q -c1 "$pihole1" &>/dev/null && ssh -p51322 root@"$pihole1" "cat /etc/pihole/lan.list" > lan.list.1 || echo -e "\n${red}Pihole1 is unreachable !'${reset}"
|
||||||
ping -q -c1 "$pihole2" &>/dev/null && ssh -p51522 root@"$pihole2" "cat /etc/pihole/lan.list" > lan.list.2 || echo -e "${red}Pihole2 is unreachable !'${reset}"
|
ping -q -c1 "$pihole2" &>/dev/null && ssh -p51522 root@"$pihole2" "cat /etc/pihole/lan.list" > lan.list.2 || echo -e "${red}Pihole2 is unreachable !'${reset}"
|
||||||
|
|
||||||
|
|
||||||
|
# Si un lan.list.bak existe, on l'archive
|
||||||
if [ -f lan.list.bak ]; then
|
if [ -f lan.list.bak ]; then
|
||||||
cp lan.list.bak /tmp/lan.list
|
cp lan.list.bak /tmp/lan.list
|
||||||
bzip2 /tmp/lan.list # lan.list.bz2
|
bzip2 /tmp/lan.list # lan.list.bz2
|
||||||
mv /tmp/lan.list.bz2 .
|
mv /tmp/lan.list.bz2 .
|
||||||
fi
|
fi
|
||||||
|
# On backup le lan.list vers lan.list.bak (sinon lan.list.1 devient lan.list)
|
||||||
if [ -f lan.list ]; then
|
if [ -f lan.list ]; then
|
||||||
cp lan.list lan.list.bak
|
cp lan.list lan.list.bak
|
||||||
elif [ -f lan.list.1 ]; then
|
elif [ -f lan.list.1 ]; then
|
||||||
@@ -102,7 +107,8 @@ fi
|
|||||||
|
|
||||||
echo -e "${bold}\nFind missing dynhost in ${italic}lan.list...${reset}"
|
echo -e "${bold}\nFind missing dynhost in ${italic}lan.list...${reset}"
|
||||||
|
|
||||||
dynhost_list=$(cat photos-nas.ovh_dns_data.txt | grep "60 IN A" | sed '1d')
|
#dynhost_list=$(cat photos-nas.ovh_dns_data.txt | grep "60 IN A" | sed '1d')
|
||||||
|
dynhost_list=$(cat subdomains.photos-nas.ovh.txt)
|
||||||
|
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
|
|
||||||
@@ -120,19 +126,25 @@ done <<< "$dynhost_list"
|
|||||||
|
|
||||||
if [ ${#absent[@]} -ge 1 ]; then
|
if [ ${#absent[@]} -ge 1 ]; then
|
||||||
|
|
||||||
echo -e "${bold}Update ${italic}lan.list...${reset}"
|
|
||||||
echo -e "${green}Not required: ${not_required[@]}${reset}"
|
echo -e "${green}Not required: ${not_required[@]}${reset}"
|
||||||
echo -e "${italic}Not used: ${not_used[@]}${reset}"
|
echo -e "${italic}Not used: ${not_used[@]}${reset}"
|
||||||
echo -e "${red}Missing: ${absent[@]}${reset}"
|
echo -e "${red}Missing: ${absent[@]}${reset}"
|
||||||
|
|
||||||
|
# On supprime /tmp/temp_file.list
|
||||||
[ -f /tmp/temp_file.list ] && rm /tmp/temp_file.list
|
[ -f /tmp/temp_file.list ] && rm /tmp/temp_file.list
|
||||||
|
|
||||||
|
# On crée un /tmp/temp_file.list avec les sous-domaines manquants
|
||||||
for val in ${absent[@]}
|
for val in ${absent[@]}
|
||||||
do
|
do
|
||||||
echo -e "192.168.2.57 ${val}.photos-nas.ovh ${val}" >> /tmp/temp_file.list
|
echo -e "192.168.2.57 ${val}.photos-nas.ovh ${val}" >> /tmp/temp_file.list
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo -e "\n${bold}Update ${italic}lan.list...${reset}"
|
||||||
|
cat /tmp/temp_file.list
|
||||||
|
|
||||||
|
# On ajoute le /tmp/temp_file.list au lan.list
|
||||||
cat /tmp/temp_file.list >> lan.list
|
cat /tmp/temp_file.list >> lan.list
|
||||||
|
# On trie le lan.list
|
||||||
cat lan.list | sort -k2 > lan.list.sorted
|
cat lan.list | sort -k2 > lan.list.sorted
|
||||||
mv lan.list.sorted lan.list
|
mv lan.list.sorted lan.list
|
||||||
|
|
||||||
@@ -142,15 +154,29 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo -e "${bold}Display ${italic}lan.list...${reset}"
|
echo -e "${bold}Display ${italic}lan.list. Please verify IP and subdomains.${reset}"
|
||||||
cat lan.list
|
cat lan.list
|
||||||
|
|
||||||
|
|
||||||
nb_dynhost=$(awk 'END { print NR }' lan.list)
|
nb_dynhost=$(awk 'END { print NR }' lan.list)
|
||||||
echo -e "$nb_dynhost dynhost !\n"
|
echo -e "$nb_dynhost dynhost !\n"
|
||||||
|
|
||||||
|
# Do you want to modify lan.list ?
|
||||||
a=$(echo -e "Do you want to export ${italic}lan.list${reset} to ${bold}pihole1${reset} ($pihole1) and ${bold}pihole2${reset} ($pihole2) ? (y/n)")
|
a=$(echo -e "Do you want to edit ${italic}lan.list${reset} ? (y/n)")
|
||||||
read -p "$a" choice
|
read -p "$a" choice
|
||||||
|
if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then
|
||||||
|
nano -l lan.list
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# On exporte lan.list vers chaque /etc/pihole/lan.list (pihole1 et pihole2)
|
||||||
|
|
||||||
|
: << 'COMMENTS'
|
||||||
|
echo "toto"
|
||||||
|
COMMENTS
|
||||||
|
|
||||||
|
b=$(echo -e "Do you want to export ${italic}lan.list${reset} to ${bold}pihole1${reset} ($pihole1) and ${bold}pihole2${reset} ($pihole2) ? (y/n)")
|
||||||
|
read -p "$b" choice
|
||||||
if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then
|
if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then
|
||||||
|
|
||||||
if ping -q -c1 "$pihole1" &>/dev/null; then
|
if ping -q -c1 "$pihole1" &>/dev/null; then
|
||||||
@@ -181,5 +207,9 @@ else
|
|||||||
echo -e "OK, let's continue..."
|
echo -e "OK, let's continue..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# On supprime les fichiers temporaires
|
||||||
[ -f /tmp/temp_file.list ] && rm /tmp/temp_file.list
|
[ -f /tmp/temp_file.list ] && rm /tmp/temp_file.list
|
||||||
[ -f lan.list.sorted ] && rm lan.list.sorted
|
[ -f lan.list.sorted ] && rm lan.list.sorted
|
||||||
|
|
||||||
|
# https://www.nas-forum.com/forum/topic/80160-multiples-dynhost-ovh/#comment-1319505612
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user