#!/bin/bash
set -x
URL_REPO="https://ognproject.evlt.uma.es/gitea/opengnsys/ogboot.git"
BRANCH=${OGBOOT_BRANCH:-"main"}
DOWNLOADDIR=${OGBOOT_DOWNLOADDIR:-"/tmp/ogboot"}
apt install -y git vim python3
git config --global http.sslVerify false
git clone -b $BRANCH $URL_REPO $DOWNLOADDIR
cd $DOWNLOADDIR/installer

ogCore_ServerIP=${1:-"172.17.8.82"}
ogBoot_ServerIP=${2:-"172.17.8.37"}
ogBoot_Dir=${3:-"/opt/opengnsys/ogboot"}
ogLive_Default=${4:-"https://ognproject.evlt.uma.es/oglive/ogLive-noble-6.8.0-31-generic-amd64-r20241128.62778c9_20241129.iso"}
ogBootSambaUser=${5:-"opengnsys"}
ogBootSambaPass=${6:-"og"}

cat > config.json <<EOF
{
    "ogCore_ServerIP": "$ogCore_ServerIP",
    "ogBoot_ServerIP": "$ogBoot_ServerIP",
    "ogBoot_Dir": "$ogBoot_Dir",
    "ogLive_Default": "$ogLive_Default",
    "ogBootSambaUser": "$ogBootSambaUser",
    "ogBootSambaPass": "$ogBootSambaPass"
}
EOF
python3 ogboot_installer.py
