Skip to content

Commit

Permalink
Refactor install prompts for pihole-updatelists
Browse files Browse the repository at this point in the history
  • Loading branch information
mschabhuettl committed Dec 3, 2024
1 parent 7599323 commit 370e27b
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions misc/update_piblocklxc.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#!/bin/bash

# Add custom logic before the "motd_ssh" line in install/piblocklxc-install.sh
sed -i '/motd_ssh/i \
# Prompt user to decide whether to install pihole-updatelists\n\
read -r -p "Would you like to add pihole-updatelists? <Y/n> " prompt\n\
if [[ -z \"$prompt\" || ${prompt,,} =~ ^(y|yes)$ ]]; then\n\
msg_info \"Installing pihole-updatelists\"\n\
apt-get install -y php-cli php-sqlite3 php-intl php-curl sqlite3\n\
wget -O - https://raw.githubusercontent.com/jacklul/pihole-updatelists/master/install.sh | bash -s systemd\n\
sed -e \"/pihole updateGravity/ s/^#*/#/\" -i /etc/cron.d/pihole\n\
mkdir -p /etc/systemd/system/pihole-FTL.service.d\n\
echo -e \"[Service]\\nExecStartPre=-/bin/sh -c '[ -w /etc/cron.d/pihole ] && /bin/sed -e \"/pihole updateGravity/ s/^#*/#/\" -i /etc/cron.d/pihole'\" > /etc/systemd/system/pihole-FTL.service.d/override.conf\n\
mkdir -p /etc/systemd/system/pihole-updatelists.timer.d\n\
echo -e \"[Timer]\\nRandomizedDelaySec=5m\\nOnCalendar=*-*-* 03:00:00\" > /etc/systemd/system/pihole-updatelists.timer.d/override.conf\n\
systemctl daemon-reload\n\
systemctl restart pihole-FTL.service\n\
wget -O /etc/pihole-updatelists.conf https://raw.githubusercontent.com/mschabhuettl/PiBlockLXC/main/config/pihole-updatelists.conf\n\
sqlite3 /etc/pihole/gravity.db \"DELETE FROM adlist\"\n\
sqlite3 /etc/pihole/gravity.db \"DELETE FROM adlist_by_group\"\n\
sqlite3 /etc/pihole/gravity.db \"DELETE FROM domainlist\"\n\
sqlite3 /etc/pihole/gravity.db \"DELETE FROM domainlist_by_group\"\n\
pihole-updatelists\n\
fi' install/piblocklxc-install.sh

sed -i '/motd_ssh/i # Prompt user to decide whether to install pihole-updatelists' install/piblocklxc-install.sh
sed -i '/motd_ssh/i read -r -p "Would you like to add pihole-updatelists? <Y/n> " prompt' install/piblocklxc-install.sh
sed -i '/motd_ssh/i if [[ -z "$prompt" || ${prompt,,} =~ ^(y|yes)$ ]]; then' install/piblocklxc-install.sh
sed -i '/motd_ssh/i msg_info "Installing pihole-updatelists"' install/piblocklxc-install.sh
sed -i '/motd_ssh/i apt-get install -y php-cli php-sqlite3 php-intl php-curl sqlite3' install/piblocklxc-install.sh
sed -i '/motd_ssh/i wget -O - https://raw.githubusercontent.com/jacklul/pihole-updatelists/master/install.sh | bash -s systemd' install/piblocklxc-install.sh
sed -i '/motd_ssh/i sed -e "/pihole updateGravity/ s/^#*/#/" -i /etc/cron.d/pihole' install/piblocklxc-install.sh
sed -i '/motd_ssh/i mkdir -p /etc/systemd/system/pihole-FTL.service.d' install/piblocklxc-install.sh
sed -i '/motd_ssh/i echo -e "[Service]\\\\nExecStartPre=-/bin/sh -c \'[ -w /etc/cron.d/pihole ] && /bin/sed -e \\"/pihole updateGravity/ s/^#*/#\\" -i /etc/cron.d/pihole\'" > /etc/systemd/system/pihole-FTL.service.d/override.conf' install/piblocklxc-install.sh
sed -i '/motd_ssh/i mkdir -p /etc/systemd/system/pihole-updatelists.timer.d' install/piblocklxc-install.sh
sed -i '/motd_ssh/i echo -e "[Timer]\\\\nRandomizedDelaySec=5m\\\\nOnCalendar=*-*-* 03:00:00" > /etc/systemd/system/pihole-updatelists.timer.d/override.conf' install/piblocklxc-install.sh
sed -i '/motd_ssh/i systemctl daemon-reload' install/piblocklxc-install.sh
sed -i '/motd_ssh/i systemctl restart pihole-FTL.service' install/piblocklxc-install.sh
sed -i '/motd_ssh/i wget -O /etc/pihole-updatelists.conf https://raw.githubusercontent.com/mschabhuettl/PiBlockLXC/main/config/pihole-updatelists.conf' install/piblocklxc-install.sh
sed -i '/motd_ssh/i sqlite3 /etc/pihole/gravity.db "DELETE FROM adlist"' install/piblocklxc-install.sh
sed -i '/motd_ssh/i sqlite3 /etc/pihole/gravity.db "DELETE FROM adlist_by_group"' install/piblocklxc-install.sh
sed -i '/motd_ssh/i sqlite3 /etc/pihole/gravity.db "DELETE FROM domainlist"' install/piblocklxc-install.sh
sed -i '/motd_ssh/i sqlite3 /etc/pihole/gravity.db "DELETE FROM domainlist_by_group"' install/piblocklxc-install.sh
sed -i '/motd_ssh/i pihole-updatelists' install/piblocklxc-install.sh
sed -i '/motd_ssh/i fi' install/piblocklxc-install.sh

0 comments on commit 370e27b

Please sign in to comment.