-
Notifications
You must be signed in to change notification settings - Fork 0
/
hosts_update.sh
27 lines (27 loc) · 977 Bytes
/
hosts_update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root!" 1>&2
exit 1
fi
URLS=(
"https://raw.githubusercontent.com/KodoPengin/GameIndustry-hosts-Template/refs/heads/master/Main-Template/hosts"
"https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
# Add more URLs as needed
# see f.e.: https://awesome-privacy.xyz/networking/host-block-lists or https://filterlists.com/ or https://pluralistic.net/2022/04/28/shut-yer-pi-hole/#largest-boycott-in-world-history
)
TEMP_FILE=$(mktemp)
for URL in "${URLS[@]}"; do
echo "Fetching data from $URL..."
curl -s "$URL" >> "$TEMP_FILE"
if [ $? -ne 0 ]; then
echo "Failed to fetch data from $URL" 1>&2
fi
done
if [ -s "$TEMP_FILE" ]; then
echo "Appending fetched data to /etc/hosts..."
sudo cat "$TEMP_FILE" >> /etc/hosts
echo "secure hosts-file created successfully!"
else
echo "No data fetched; /etc/hosts not modified."
fi
rm "$TEMP_FILE"