#!/bin/bash

mkdir /usr/local/listmonk
cd /usr/local/listmonk

git init
git pull https://github.com/knadh/listmonk.git

ruf

bun --cwd=frontend i
bun --cwd=frontend/email-builder i

bun --cwd=frontend vite build
bun --cwd=frontend/email-builder vite build

mkdir frontend/dist/static/email-builder
mv frontend/email-builder/dist frontend/dist/static/email-builder

go build -C cmd -o /usr/bin/listmonk

mv config.toml.sample config.toml

cru psql
sudo -u psql initdb -U Servex -X /var/log/listmonk -W /usr/local/pgsql/data