#!/bin/bash

if [ "$(uname)" == "Darwin" ]; then
    FIRST_IP=$(ipconfig getifaddr en0)
elif [ "$(uname)" == "Linux" ]; then
    FIRST_IP=$(hostname -I | cut -d' ' -f1)
fi

# Only export env variable if it's not empty
if [ ! -z $FIRST_IP ]; then
    export SERVER_IP=$FIRST_IP
fi

if [[ ! " $@ " =~ ( --version | -v | --help | -h ) ]]; then
    if [ -x "$(command -v casa_data_autoupdate)" ]; then
        casa_data_autoupdate
    fi
fi

carta_backend "$@"
