#!/bin/bash

[ -t 1 ] && . colors

source h-manifest.conf
source $CUSTOM_CONFIG_FILENAME
HOSTNAME=$(hostname)

[[ -z $CUSTOM_LOG_BASENAME ]] && echo -e "${RED}No CUSTOM_LOG_BASENAME is set${NOCOLOR}" && exit 1
[[ -z $CUSTOM_CONFIG_FILENAME ]] && echo -e "${RED}No CUSTOM_CONFIG_FILENAME is set${NOCOLOR}" && exit 1
[[ ! -f $CUSTOM_CONFIG_FILENAME ]] && echo -e "${RED}Custom config ${YELLOW}$CUSTOM_CONFIG_FILENAME${RED} is not found${NOCOLOR}" && exit 1
CUSTOM_LOG_BASEDIR=$(dirname "${CUSTOM_LOG_BASENAME}")
[[ ! -d $CUSTOM_LOG_BASEDIR ]] && mkdir -p $CUSTOM_LOG_BASEDIR

len=$(echo $ADDRESS | awk '{print length}')

  echo -a xelishash  -o $PROXY  -u ${ADDRESS} -w $HOSTNAME --api-bind 127.0.0.1:5000 --enable-fork --log-file $MINER_LOG_BASENAME.log 
  ./rigel -a xelishash  -o $PROXY  -u ${ADDRESS} -w $HOSTNAME --api-bind 127.0.0.1:5000 --enable-fork --log-file $MINER_LOG_BASENAME.log 
