#!/bin/sh

bookstack_dir='/var/lib/bookstack'

if ! getent group bookstack 1>/dev/null; then
	echo '* Creating group bookstack' 1>&2

	addgroup -S bookstack
fi

if ! id bookstack 2>/dev/null 1>&2; then
	echo '* Creating user bookstack' 1>&2

	adduser -DHS -G bookstack -h "$bookstack_dir" -s /bin/sh  \
		-g "added by apk for bookstack" bookstack
	passwd -u bookstack 1>/dev/null  # unlock
fi

if ! id -Gn bookstack | grep -Fq www-data; then
	echo '* Adding user bookstack to group www-data' 1>&2

	addgroup bookstack www-data
fi

exit 0
