post_install() {
  if ! getent passwd dnsmasq &>/dev/null; then
    useradd -r -d / -c 'dnsmasq daemon' -s /bin/nologin dnsmasq >/dev/null
  fi
  dnsmasq_shell=$(getent passwd dnsmasq | cut -d: -f7)
  if [ "$dnsmasq_shell" != '/bin/nologin' ]; then
    chsh -s /bin/nologin dnsmasq &>/dev/null
  fi
}

post_upgrade() {
  post_install
}

post_remove() {
  if getent passwd dnsmasq &>/dev/null; then
    userdel dnsmasq >/dev/null
  fi
}
