-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·51 lines (43 loc) · 1.44 KB
/
install.sh
File metadata and controls
executable file
·51 lines (43 loc) · 1.44 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# install.sh
# implement local ad blocking using systemd-resolved, or update existing
# Copyright 2024 (c) Brady Etz, https://github.com/b-etz/systemd-adblock
_conf_dst="/etc/systemd/resolved.conf.d"
_logs_dst="/etc/adhosts/logs"
_sh_dst="/usr/local/bin"
_serv_dst="/etc/systemd/system"
_timer_dst="/etc/systemd/system"
# Install systemd-resolved if not already present
if [ -n "$(command -v resolvectl)" ]; then
:
elif [ -n "$(command -v apt)" ]; then
apt install -y systemd-resolved
elif [ -n "$(command -v dnf)" ]; then
dnf install -y systemd-resolved
else
echo "ERROR: Please install systemd-resolved using your package manager, then run install.sh again!! Exiting.";
exit 1;
fi
# Update or create the drop-in for systemd-resolved
mkdir -p "$_conf_dst"
cp -f 70-adblock.conf "$_conf_dst"
# Create or replace the default hosts list (localhost)
mkdir -p "$_logs_dst"
cp -f .hosts /etc
# Create or replace the adblock list retrieval script
mkdir -p "$_sh_dst"
cp -f adhosts.sh "$_sh_dst"
chmod 0744 "${_sh_dst}/adhosts.sh"
mkdir -p "$_timer_dst"
cp -f adhosts.timer "$_timer_dst"
mkdir -p "$_serv_dst"
cp -f adhosts.service "$_serv_dst"
# Generate ad hosting domains in /etc/hosts immediately
systemctl daemon-reload
systemctl start adhosts.service
# Enable and restart systemd-resolved and the daily systemd.timer
systemctl enable --now adhosts.timer
systemctl enable systemd-resolved
systemctl restart systemd-resolved
exit 0
#EOF