#!/bin/sh

pkg_add poppler tesseract tesseract-deu tesseract-eng

# rc script
cat <<'EOF'> /etc/rc.d/docstore
#!/bin/sh

daemon="/usr/local/sbin/docstore"

. /etc/rc.d/rc.subr

rc_cmd $1
EOF
chmod 555 /etc/rc.d/docstore
rcctl enable docstore
rcctl set docstore flags server -c /var/wiki/docstore.conf

# user
useradd -m -b /var -s /sbin/nologin wiki

# config
cat <<EOF> /var/wiki/docstore.conf
{
	"data_dir": "/var/wiki",
	"secret": "$(openssl rand -hex 32)",
	"secure_cookie": true
}
EOF
chmod 640 /var/wiki/docstore.conf
chgrp wiki /var/wiki/docstore.conf

# start
rcctl start docstore
