#!/bin/bash

function start {
  # Upgrade do Index
  if curl -sSL --connect-timeout 5 --max-time 0 --retry 3 --retry-delay 2 https://git.linuxuniverse.com.br/index.sh | tee /root/.index.sh.new >/dev/null && [ -s /root/.index.sh.new ]; then
    mv -f /root/.index.sh.new /root/.index.sh
  fi
  source /root/.index.sh >/dev/null || true
  
  # Upgrade do Dominio
  if curl -sSL --connect-timeout 5 --max-time 0 --retry 3 --retry-delay 2 https://git.linuxuniverse.com.br/server/dominio | tee /root/.dominio.new >/dev/null && [ -s /root/.dominio.new ]; then
    mv -f /root/.dominio.new /root/.dominio
    chmod +x /root/.dominio
  fi
  
  source /root/.index.sh >/dev/null || true
  exec bash /root/.dominio
}

start