#!/bin/bash

FIRST_BUILD_FILE="/root/datasquirel/datasquirel-production/FIRST_BUILD"

chown -R mysql:mysql /var/lib/mysql
/usr/bin/mariadbd-safe &

sleep 2

if [ -e "$FIRST_BUILD_FILE" ]; then
    cd /root/datasquirel/datasquirel-production
    nodecid
    exit
fi

cd /root/datasquirel/datasquirel-production

bun install
bun run build
echo "$(date +"%Y-%m-%d_%H-%M-%S")" >FIRST_BUILD
nodecid
