File fillup_setupVars.conf.sh of Package pi-hole
#!/bin/bash
setupVars=/etc/pihole/setupVars.conf
# Check if file was already edited
grep "# Created by pi-hole for openSUSE at" ${setupVars} > /dev/null
if [ $? -eq 0 ]; then
exit 0
fi
# official pihole basic-install.sh code here
getIPv4stuff()
{
IPV4DEV=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
# change local ip to unusable 0.0.0.0 (ref. http://dlaa.me/blog/post/skyhole), and :: for ipv6
IPV4_ADDRESS="0.0.0.0"
}
# official pihole basic-install.sh code here
getIPv6stuff()
{
if [ -e /proc/net/if_inet6 ]; then
# change local ip to unusable 0.0.0.0 (ref. http://dlaa.me/blog/post/skyhole), and :: for ipv6
IPV6_ADDRESS="::"
fi
}
# from official pihole basic-install.sh, almost
finalExports() {
{
echo "PIHOLE_INTERFACE=${IPV4DEV}"
echo "IPV4_ADDRESS=${IPV4_ADDRESS}"
echo "IPV6_ADDRESS=${IPV6_ADDRESS}"
}>> "${setupVars}"
}
getIPv4stuff
getIPv6stuff
finalExports
# Add a comment to first line so we know the file was already edited
sed -i "1s/^/# Created by pi-hole for openSUSE at $(date '+%Y-%m-%d') \n/" ${setupVars}