# Installs at system level for autostart
# Requires sudo
# Pass the path to an appropriate .env as $1

echo "Will copy config from '$1'"

INSTALL=/etc/matrix-cadbury

ADD_SRV=cadbury.service
DEST=/etc/systemd/system

# Install as system package
cd /etc; git clone https://codeberg.org/EdTheDev/matrix-cadbury.git

# Add initial config
cp $1 $INSTALL/.env

# Install as systemd service
mkdir -p $DEST
rm -f $DEST/$ADD_SRV
cp $INSTALL/service/$ADD_SRV $DEST/
ls -al $DEST | grep $ADD_SRV

systemctl daemon-reload
systemctl enable $ADD_SRV
systemctl status $ADD_SRV
