summarylogtreecommitdiffstats
path: root/pi-hole-standalone.install
blob: 3fde506343952349069b71f88ba77009ea95b6fa (plain)
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
warning() {
  /usr/bin/true  
}

post_install() {
  echo -e "\e[1;33m==>\e[0m Read setup instructions at \e[1;36mhttps://wiki.archlinux.org/index.php/Pi-hole\e[0m"
  echo -e "\e[1;33m==>\e[0m Generating initial block list, please wait...\e[0m"

  /opt/pihole/mimic_setupVars.conf.sh

  # update lists on first run
  pihole -g > /dev/null

  # setup dns server which by definition modifies /etc/dnsmasq.d/01-pihole.conf
  # and thus protects it from getting overwritten by package updates
  /usr/bin/pihole -a setdns 8.8.8.8,8.8.4.4 > /dev/null
}

post_upgrade() {
  # clean old/unused/deprecated files
  [ -e /etc/pihole/hosts ] && rm /etc/pihole/hosts
  [ -e /etc/pihole/.useIPv6 ] && rm /etc/pihole/.useIPv6

  # update owner of existing dir and file
  chown pihole:pihole /etc/pihole

  # query logging disabling needs this
  grep -qxF 'QUERY_LOGGING=' /etc/pihole/setupVars.conf || echo 'QUERY_LOGGING=true' >> /etc/pihole/setupVars.conf

  # warning

  # keep pacman from throwing errors should none them be on the filesystem
  return 0
}

post_remove() {
  # delete all temp files except those modified the user
  # TODO - make this more intelligent to save *.pacsave.# where # is a number
  find /etc/pihole -type f ! -name '*.pacsave' ! -name 'pihole-FTL.conf' ! -name 'pihole-FTL.db' ! -name 'gravity.db' -delete
}