#!/bin/sh
groupadd wiki
useradd -g wiki wiki 
mkdir /var/lib/gowiki
chown wiki: /var/lib/gowiki
mkdir /etc/gowiki
cat <<EOF> /etc/gowiki/gowiki.conf
{
	"data_dir": "/var/lib/gowiki",
	"secret": "$(openssl rand -hex 32)"
}
EOF
cat <<EOF> /etc/systemd/system/gowiki.service
[Unit]
Description=GoWiki
After=syslog.target
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/bin/gowiki server -c /etc/gowiki/gowiki.conf
Restart=always

[Install]
WantedBy=multi-user.target
EOF
systemctl enable gowiki
cat <<EOF
copy your gowiki binary to /usr/local/bin/gowiki

then run: systemctl start gowiki
EOF
