#!/bin/sh

set -e

# Ensure the configuration directory exists
mkdir -p /etc/cot

# Copy the default configuration file if it doesn't exist
if [ ! -f /etc/cot/config.toml ]; then
    cp /usr/local/bin/config.toml /etc/cot/config.toml
fi

# Restart the service if it's running
if systemctl is-active --quiet cot; then
    systemctl restart cot
fi

exit 0
