#!/bin/sh

set -e

if [ "$1" = configure ]; then
    adduser --system \
            --quiet \
            --home /var/lib/scylla \
            --no-create-home \
            --disabled-password \
            --group scylla
    chown -R scylla:scylla /var/lib/scylla
fi

ln -sfT /etc/scylla /var/lib/scylla/conf

grep -v api_ui_dir /etc/scylla/scylla.yaml | grep -v api_doc_dir > /tmp/scylla.yaml
echo "api_ui_dir: /usr/lib/scylla/swagger-ui/dist/" >> /tmp/scylla.yaml
echo "api_doc_dir: /usr/lib/scylla/api/api-doc/" >> /tmp/scylla.yaml
mv /tmp/scylla.yaml /etc/scylla/scylla.yaml

#DEBHELPER#
