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

ogBoot_ServerIP=${1:-"172.17.8.82"}
ogDhcp_ServerIP=${2:-"172.17.8.37"}
ogDhcp_Dir=${3:-"/opt/opengnsys/ogdhcp"}


cat > config_ogdhcp.json <<EOF
{
    "interfaces": ["eth0", "eth1"],
    "ogbootIP": "$ogBoot_ServerIP",
    "ogDhcpIP": "$ogDhcp_ServerIP",
    "ogDhcp_Dir": "$ogDhcp_Dir"
}
EOF
chmod 755 ogdhcp_installer.sh
./ogdhcp_installer.sh
