#!/bin/sh
set -eu

group=paperless
config_file='/etc/paperless.conf'

#setcap 'cap_net_bind_service=+ep' /usr/share/webapps/authentik/server

if [ "${0##*.}" = 'post-upgrade' ]; then
	cat >&2 <<-EOF
	*
	* To finish Paperless upgrade run:
	*
	*     sudo -Hu paperless python3 manage.py migrate in /usr/share/webapps/paperless/src
	*
	EOF
else
	cat >&2 <<-EOF
	*
	* 1. Adjust settings in $config_file
	*
	* 2. Create database for Paperless:
	*
	*     psql -c "CREATE ROLE paperless PASSWORD 'top-secret' INHERIT LOGIN;"
	*     psql -c "CREATE DATABASE paperless OWNER paperless ENCODING 'UTF-8';"
	*
	* 3. Run:
	*
	*     sudo -Hu paperless python3 manage.py migrate in /usr/share/webapps/paperless/src
	*
	* 4. Setup admin user via:
	*
	*     sudo -Hu paperless python3 manage.py createsuperuser in /usr/share/webapps/paperless/src
	*
	EOF
fi
