#!/bin/bash
## Site-specific setup for newly-created users.
## adduser(8) will call this script after setting up a new user.

set -euo pipefail
if [[ "$#" != 4 ]]; then
  echo "usage: $0 username uid gid home" > /dev/stderr
fi
NEW_USERNAME="${1:?}"
NEW_UID="${2:?}"
NEW_GID="${3:?}"
NEW_HOME="${4:?}"

# The groups command outputs a space-separated list of group names
IFS=' '
for group in $(groups "${NEW_USERNAME}"); do
   case "${group}" in
     a)
       [[ "${VERBOSE}" > 0 ]] && echo Removing file for a
       rm "${NEW_HOME}/not_for_a.txt"
       ;;
     b)
       [[ "${VERBOSE}" > 0 ]] && echo Removing dir for b
       rm -r "${NEW_HOME}/not_for_b/"
       ;;
     *)
       [[ "${VERBOSE}" > 1 ]] && echo No special setup required for $group
       ;;
   esac
done

# The interesting part, which you'll want to edit, are the lines that look 
# like this one:

     a)
       [[ "${VERBOSE}" > 0 ]] && echo Removing file for a
       rm "${NEW_HOME}/not_for_a.txt"
       ;;

