Skip to content

Instantly share code, notes, and snippets.

@dwallraff
Last active January 12, 2024 20:25
Show Gist options
  • Save dwallraff/e0ddfe0c01263f58e137e25604fa3c57 to your computer and use it in GitHub Desktop.
Save dwallraff/e0ddfe0c01263f58e137e25604fa3c57 to your computer and use it in GitHub Desktop.
Setting up a Raspberry Pi-Hole using a chromebook

Setup a Pi-Hole from a Chromebook

Create the image

Setup wifi, ssh, and your username

curl -sL dwallraff.com/pihole_config | bash

Install pi-hole

curl -sSL https://install.pi-hole.net | bash

Reset the web password and add a bare root redirect

  • ssh into the pihole
pihole -a -p
echo <head><meta http-equiv="Refresh" content="0; URL=http://pihole.local/admin/"/></head> | sudo tee -a /var/www/html/index.html

Setup automatic updates (gravity/blocklists update weekly)

sudo apt install unattended-upgrades
echo unattended-upgrades unattended-upgrades/enable_auto_updates boolean true | sudo debconf-set-selections
sudo dpkg-reconfigure -f noninteractive unattended-upgrades

Add blocklists

curl -sL dwallraff.com/pihole_blocklists | bash

(Optional) Configure OLED

TBD

#! /usr/bin/env bash
#-- Dave Wallraff
# First things first, I'm the realest...
### Headless raspberry pi config files
# curl -sL dwallraff.com/pihole_blocklists | bash
# wrap in a function for curl|bash
do_stuff() {
# Install sqlite3 cli
sudo apt -y install sqlite3
# Clear old db
pihole -g -r recreate
# Array of blocklists
BLOCKLISTS=(
https://big.oisd.nl
https://v.firebog.net/hosts/AdguardDNS.txt
https://v.firebog.net/hosts/Admiral.txt
https://v.firebog.net/hosts/Easylist.txt
https://v.firebog.net/hosts/Easyprivacy.txt
https://v.firebog.net/hosts/Prigent-Ads.txt
https://v.firebog.net/hosts/Prigent-Crypto.txt
https://v.firebog.net/hosts/RPiList-Malware.txt
https://v.firebog.net/hosts/RPiList-Phishing.txt
https://raw.githubusercontent.com/hagezi/dns-blocklists/main/domains/pro.txt
)
# Array of domains to block
DOMAINS=(
debug.opendns.com
)
# loop over and add lists to the gravity DB
for list in ${BLOCKLISTS[@]}; do
sudo sqlite3 /etc/pihole/gravity.db "INSERT INTO adlist (address, enabled, comment) VALUES ('$list', 1, 'comment');"
done
# loop over and add domains to the blocklist
for domain in ${DOMAINS[@]}; do
pihole -b $domain
done
# Update blocklists
pihole -g
}
do_stuff
#! /usr/bin/env bash
#-- Dave Wallraff
# First things first, I'm the realest...
### Headless raspberry pi config files
# curl -sL dwallraff.com/pihole_config | bash
# wrap in a function for curl|bash
do_stuff() {
# Get some variables
read -rp "Enter username: " USER </dev/tty
read -srp "Enter user password: " USER_PASSWORD </dev/tty
echo # used cause read -s doesn't include a newline
ENCRYPTED_USER_PASSWORD=$(echo "$USER_PASSWORD" | openssl passwd -6 -noverify -stdin) # encrypt for use in the raspberry pi bootstrap
read -rp "Enter wifi name: " WIFI </dev/tty
read -srp "Enter wifi password: " WIFI_PASSWORD </dev/tty
# echo out the files
cat << EOF > userconf
$USER:$ENCRYPTED_USER_PASSWORD
EOF
cat << EOF > wpa_supplicant.conf
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
scan_ssid=1
ssid="$WIFI"
psk="$WIFI_PASSWORD"
}
EOF
# Needed file to enable ssh
touch ssh
# Tell me what to do cause i'm gonna forget
echo
echo "Move userconf, wpa_supplicant.conf, and ssh to the boot volume of your raspberrypi sd card"
}
do_stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment