#!/bin/bash

# ========================================
# CONFIG VARIABLES
# ========================================

export API_KEY='CHANGEME'

# UNCOMMENT BELOW LINE TO DISABLE CONFIG SENDING
#MESHTASTIC_NO_INFO=true

# UNCOMMENT BELOW LINE TO USE BLE NODE (DO NOT USE IF USING INLINE ENV VARIABLES SHOWN ABOVE)
#MESHTASTIC_BLE=''

# UNCOMMENT BELOW LINE TO USE HTTP NODE (DO NOT USE IF USING INLINE ENV VARIABLES SHOWN ABOVE)
# MESHTASTIC_HOST='meshtastic.local'

# BASE DIR VARIABLES
BASE_DIR="${HOME}/.config/mapthemesh"
VENV_DIR="${BASE_DIR}/venv"

# ========================================
# END CONFIG VARIABLES
# ========================================


# Exit if the API_KEY is not set or is empty or is 'CHANGEME'
if [ -z "${API_KEY}" ]; then
    echo "API_KEY is not set. Please set it in the script."
    exit 1
elif [ "${API_KEY}" == '' ]; then
    echo "API_KEY is empty. Please change it in the script."
    exit 1
elif [ "${API_KEY}" == 'CHANGEME' ]; then
    echo "API_KEY is "CHANGEME". Please change it in the script."
    exit 1
fi



# PYTHON VIRTUAL ENV ACTIVATION - EDIT IF CHANGED
source "${VENV_DIR}/bin/activate"
# PYTHON VIRTUAL ENV ACTIVATION


# INLINE BLUETOOTH HTTP EXAMPLE
# =======================================
# wget -q -O - https://script.themesh.live/run.sh | MESHTASTIC_HOST='meshtastic.local' bash

# INLINE BLUETOOTH MAC ADDRESS EXAMPLE
# =======================================
# wget -q -O - https://script.themesh.live/run.sh | MESHTASTIC_BLE='00:00:DE:AD:BE:EF' bash


wget -q -O - https://script.themesh.live/run.sh | bash
