forked from elichai/kaspa-miner
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hiveos_integration' into main
- Loading branch information
Showing
7 changed files
with
205 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
integrations/hiveos/createmanifest.sh $1 $2 | ||
mkdir $3 | ||
cp h-manifest.conf integrations/hiveos/*.sh $2/* $3 | ||
tar czvf $3.tgz $3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#################################################################################### | ||
### | ||
### kaspa-miner | ||
### https://github.com/tmrlvi/kaspa-miner/releases | ||
### | ||
### Hive integration: Merlin | ||
### | ||
#################################################################################### | ||
|
||
if [ "$#" -ne "2" ] | ||
then | ||
echo "No arguments supplied. Call using createmanifest.sh <VERSION_NUMBER> <MINER BINARY NAME>" | ||
exit | ||
fi | ||
cat > h-manifest.conf << EOF | ||
#################################################################################### | ||
### | ||
### kaspa-miner | ||
### https://github.com/tmrlvi/kaspa-miner/releases | ||
### | ||
### Hive integration: Merlin | ||
### | ||
#################################################################################### | ||
# The name of the miner | ||
CUSTOM_NAME=kaspa-miner | ||
# Optional version of your custom miner package | ||
CUSTOM_VERSION=$1 | ||
CUSTOM_BUILD=0 | ||
CUSTOM_MINERBIN=$2 | ||
# Full path to miner config file | ||
CUSTOM_CONFIG_FILENAME=/hive/miners/custom/$CUSTOM_NAME/config.ini | ||
# Full path to log file basename. WITHOUT EXTENSION (don't include .log at the end) | ||
# Used to truncate logs and rotate, | ||
# E.g. /var/log/miner/mysuperminer/somelogname (filename without .log at the end) | ||
CUSTOM_LOG_BASENAME=/var/log/miner/$CUSTOM_NAME | ||
WEB_PORT=3338 | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#################################################################################### | ||
### | ||
### kaspa-miner | ||
### https://github.com/tmrlvi/kaspa-miner/releases | ||
### | ||
### Hive integration: Merlin | ||
### | ||
#################################################################################### | ||
|
||
#!/usr/bin/env bash | ||
[[ -e /hive/custom ]] && . /hive/custom/kaspa-miner/h-manifest.conf | ||
[[ -e /hive/miners/custom ]] && . /hive/miners/custom/kaspa-miner/h-manifest.conf | ||
conf="" | ||
conf+=" --kaspad-address=$CUSTOM_URL --mining-address $CUSTOM_TEMPLATE" | ||
|
||
|
||
[[ ! -z $CUSTOM_USER_CONFIG ]] && conf+=" $CUSTOM_USER_CONFIG" | ||
|
||
echo "$conf" | ||
echo "$conf" > $CUSTOM_CONFIG_FILENAME | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#################################################################################### | ||
### | ||
### kaspa-miner | ||
### https://github.com/tmrlvi/kaspa-miner/releases | ||
### | ||
### Hive integration: Merlin | ||
### | ||
#################################################################################### | ||
|
||
#!/usr/bin/env bash | ||
|
||
cd `dirname $0` | ||
|
||
[ -t 1 ] && . colors | ||
|
||
. h-manifest.conf | ||
|
||
echo $CUSTOM_NAME | ||
echo $CUSTOM_LOG_BASENAME | ||
echo $CUSTOM_CONFIG_FILENAME | ||
|
||
[[ -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_MINERBIN $(< $CUSTOM_CONFIG_FILENAME) $@ 2>&1 | tee $CUSTOM_LOG_BASENAME.log | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#################################################################################### | ||
### | ||
### kaspa-miner | ||
### https://github.com/tmrlvi/kaspa-miner/releases | ||
### | ||
### Hive integration: Merlin | ||
### | ||
#################################################################################### | ||
|
||
#!/usr/bin/env bash | ||
|
||
####################### | ||
# MAIN script body | ||
####################### | ||
|
||
. /hive/miners/custom/kaspa-miner/h-manifest.conf | ||
stats_raw=`cat $CUSTOM_LOG_BASENAME.log | grep -w "hashrate" | tail -n 1 ` | ||
|
||
#Calculate miner log freshness | ||
|
||
maxDelay=120 | ||
time_now=`date +%T | awk -F: '{ print ($1 * 3600) + $2*60 + $3 }'` | ||
time_rep=`echo $stats_raw | awk -FT '{print $2}' | awk -FZ '{print $1}' | awk -F: '{ print (($1+1)*3600) + $2*60 + $3}'` | ||
diffTime=`echo $((time_now-time_rep)) | tr -d '-'` | ||
|
||
if [ "$diffTime" -lt "$maxDelay" ]; then | ||
total_hashrate=`echo $stats_raw | awk '{print $7}' | cut -d "." -f 1,2 --output-delimiter='' | sed 's/$/0/'` | ||
if [[ $stats_raw == *"Ghash"* ]]; then | ||
total_hashrate=$(($total_hashrate*1000)) | ||
fi | ||
stats=$(jq -nc \ | ||
--argjson hs "[$total_hashrate]"\ | ||
--arg ver "$CUSTOM_VERSION" \ | ||
--arg ths "$total_hashrate" \ | ||
'{ hs: $hs, hs_units: "khs", algo : "heavyhash", ver:$ver }') | ||
khs=$total_hashrate | ||
else | ||
khs=0 | ||
stats="null" | ||
fi | ||
|
||
[[ -z $khs ]] && khs=0 | ||
[[ -z $stats ]] && stats="null" |