#!/bin/sh

conf=/etc/conf.d/syncplay-server

if [ -r "$conf" ]; then
	exit
fi

passphrase() {
	LC_ALL=C tr -dc "$1" < /dev/urandom 2>> /dev/null | head -c "${2}"
}

touch "$conf"
chmod 640 "$conf"

cat <<EOF > "$conf"
password=$(passphrase '[:upper:]' 10)
salt=$(passphrase '[:alnum:]' 20)
command_args="--password \$password --salt \$salt"
EOF
