#!/bin/sh -ex

useradd -r syncthing -m -d /home/syncthing

# syncthing service generates secrets on first run, so is enabled and
# started via /usr/lib/inithooks/firstboot.d/20regen-syncthing-secrets

# address https://github.com/turnkeylinux/tracker/issues/1584
cat >> /etc/sysctl.conf <<EOF
# Bump maximum receive buffer size to roughly 2.5 MB for Syncthing - as per
# https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size
net.core.rmem_max=2500000
EOF

# enabled nginx reverse proxy
rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/syncthing /etc/nginx/sites-enabled/syncthing
