#!/bin/bash
if [[ -z $1 || -z $2 ]]; then
  echo "Usage: $0 USER UID"
  exit 1
fi

usr=$1
uid=$2
addgroup --gid ${uid:?} ${usr:?} --system
adduser --uid ${uid:?} --ingroup ${usr:?} ${usr:?} --disabled-password --gecos "" --system --no-create-home --shell /usr/sbin/nologin --home /nonexistent
printf "[User]\nSystemAccount=true\n" > /var/lib/AccountsService/users/${usr:?}