#!/bin/bash
cd ~
if curl --silent --fail  https://netboot.delutis.org/gate/$(hostname).yml > /dev/null;
 then
  echo Downloading $(hostname).yml
  curl --silent -o config.yml https://netboot.delutis.org/gate/$(hostname).yml
 else
  rm config.yml
fi;

if [ ! -f config.yml ]
 then
  if curl --silent --fail  https://netboot.delutis.org/gate/default.yml > /dev/null;
   then
    echo Downloading Default.yml
    curl --silent -o config.yml https://netboot.delutis.org/gate/default.yml
   else
    :
  fi
fi

if [ ! -f config.yml ]
 then
  exit
 else
  docker run -v ./config.yml:/config.yml -p 25565:25565 -t --rm ghcr.io/minekube/gate:latest
fi
