-##### use systemd-resolved for glibc resolutions
-
-pi libnss-resolve
-
-if [[ ! -L /etc/nsswitch.conf ]]; then
- sudo mkdir -p /etc/resolved-nsswitch
- sudo mv /etc/nsswitch.conf /etc/resolved-nsswitch
- sudo ln -sf /etc/resolved-nsswitch/nsswitch.conf /etc
-fi
-
-f=/etc/basic-nsswitch/nsswitch.conf
-if [[ ! -e $f ]]; then
- sudo mkdir -p ${f%/*}
- sudo cp /etc/nsswitch.conf $f
- sudo sed -i --follow-symlinks 's/^ *hosts:.*/hosts: files dns myhostname/' $f
-fi
-case $HOSTNAME in
- bk)
- sudo sed -i --follow-symlinks 's/^ *hosts:.*/hosts: files dns myhostname/' /etc/nsswitch.conf
- soff systemd-resolved
- ln -sf 127.0.0.1-resolv/stub-resolv.conf /etc/resolv.conf
- sgo bind9
- # cautious measure to make sure bind is up
- sleep 1
- ;;
- *)
- # default is
- # files mdns4_minimal [NOTFOUND=return] dns myhostname
- # mdns4 is needed for my printer and for bbb webrtc, not sure exactly why.
- # https://www.freedesktop.org/software/systemd/man/nss-resolve.html#
- # seems more important than some potential use case.
- # Interestingly, t9/t10 man page says use files before resolve, debian 10 says the opposite.
- # removing files makes hostname -f not actually give the fully qualified domain name.
- sudo sed -i --follow-symlinks 's/^ *hosts:.*/hosts: files resolve [!UNAVAIL=return] mdns4_minimal [NOTFOUND=return] myhostname/' /etc/resolved-nsswitch/nsswitch.conf
- ;;
-esac
-
-f=/etc/apparmor.d/abstractions/nameservice
-if [[ -e $f ]] && ! grep -q /etc/resolved-nsswitch/nsswitch.conf $f; then
- sudo sed -i '/\/etc\/nsswitch.conf/a /etc/resolved-nsswitch/nsswitch.conf r,' $f
- sudo sed -i '/\/etc\/nsswitch.conf/a /etc/basic-nsswitch/nsswitch.conf r,' $f
- if sytemctl is-enabled apparmor; then
- m ser reload apparmor
- fi
-fi
-