#!/bin/sh
set -e

LISTHOME="/var/list"
LISTID=38

expected_user="list $LISTID $LISTID $LISTHOME"
expected_group="list $LISTID"
actual_user=$(getent passwd list | awk -F: '{ print $1 " " $3 " " $4 " " $6 }')
actual_group=$(getent group list | awk -F: '{ print $1 " " $3 }')

if [ "$actual_user" != "$expected_user" ] || [ "$actual_group" != "$expected_group" ]; then
  cat << EOF

Error: The following requirements must be met:
- User 'list' with:
  * UID: $LISTID
  * GID: $LISTID
  * Home: $LISTHOME
- Group 'list' with:
  * GID: $LISTID

Please ensure these exist before installation.

EOF
  exit 1
fi
