post_install() {
  if ! getent group tox-bootstrapd &>/dev/null; then
    groupadd -g 199 tox-bootstrapd >/dev/null
  fi
  if ! getent passwd tox-bootstrapd &>/dev/null; then
    useradd -u 199 -g tox-bootstrapd -d /var/lib/tox-bootstrapd -s /bin/nologin -c "Tox bootstrapd" tox-bootstrapd >/dev/null
  fi
  if [[ ! -d /var/lib/tox-bootstrapd ]]; then
    install -dm750 -o 199 -g 199 /var/lib/tox-bootstrapd
  fi
  tox_bootstrapd_shell=$(getent passwd tox-bootstrapd | cut -d: -f7)
  if [ "$tox_bootstrapd_shell" != '/bin/nologin' ]; then
    chsh -s /bin/nologin tox-bootstrapd &>/dev/null
  fi
}

post_upgrade() {
  post_install
}

post_remove() {
  if getent passwd tox-bootstrapd &>/dev/null; then
    userdel tox-bootstrapd >/dev/null
  fi
  if getent group tox-bootstrapd &>/dev/null; then
    groupdel tox-bootstrapd >/dev/null
  fi
}
