#!/usr/bin/env bash
# This code is included in /hive/bin/custom function

[[ -z $CUSTOM_TEMPLATE ]] && echo -e "${YELLOW}CUSTOM_TEMPLATE is empty${NOCOLOR}" && return 1
[[ -z $CUSTOM_URL ]] && echo -e "${YELLOW}CUSTOM_URL is empty${NOCOLOR}" && return 1

TEMPLATE=$CUSTOM_TEMPLATE
wallet="${TEMPLATE%%.*}"
worker="${TEMPLATE#*.}" 

conf="--node 66.23.193.243:9800"
conf+=" --safe-power --proto minerlab"
conf+=" --wallet $wallet"
conf+=" --worker $worker"
conf+=" ${CUSTOM_USER_CONFIG}"

#echo "$CUSTOM_URL">/tmp/npt_url

[[ -z $CUSTOM_CONFIG_FILENAME ]] && echo -e "${RED}No CUSTOM_CONFIG_FILENAME is set${NOCOLOR}" && return 1
echo "$conf" > $CUSTOM_CONFIG_FILENAME
