-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from x100111010/dev2
Add HiveOS Build and Deployment Workflow to deploy.yaml
- Loading branch information
Showing
6 changed files
with
154 additions
and
12 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
|
||
# Extract the dynamic part (assuming 'nproc' command is your dynamic part) | ||
DYNAMIC_PART=$(echo "$CUSTOM_USER_CONFIG" | grep -oP '\$\((nproc.*)\)') | ||
|
||
if [ ! -z "$DYNAMIC_PART" ]; then | ||
EVALUATED_DYNAMIC_PART=$(eval echo "$DYNAMIC_PART") | ||
eval echo "$DYNAMIC_PART" > /dev/null 2>&1 | ||
|
||
if [ $? -eq 0 ]; then | ||
SAFE_DYNAMIC_PART=$(printf '%s\n' "$DYNAMIC_PART" | sed 's:[][\/.^$*]:\\&:g') | ||
MODIFIED_CONFIG=$(echo "$CUSTOM_USER_CONFIG" | sed "s/$SAFE_DYNAMIC_PART/$EVALUATED_DYNAMIC_PART/") | ||
conf="$MODIFIED_CONFIG" | ||
echo "Modified config after removing executed command: $conf" | ||
else | ||
echo "Error in executing dynamic part. No modifications made." | ||
conf="$CUSTOM_USER_CONFIG" | ||
fi | ||
else | ||
echo "No dynamic part found. No modifications made." | ||
conf="$CUSTOM_USER_CONFIG" | ||
fi | ||
|
||
echo "$conf" | ||
echo "$conf" > "$CUSTOM_CONFIG_FILENAME" | ||
|
||
echo "Wrote config to $CUSTOM_CONFIG_FILENAME" | ||
echo "The contents of the config file are:" | ||
cat "$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,5 @@ | ||
MINER_NAME=spectre-miner | ||
MINER_LOG_BASENAME=/var/log/miner/$MINER_NAME/$MINER_NAME | ||
CUSTOM_LOG_BASENAME=/var/log/miner/custom/custom | ||
CUSTOM_CONFIG_BASENAME=/hive/miners/custom/$MINER_NAME | ||
CUSTOM_CONFIG_FILENAME=$CUSTOM_CONFIG_BASENAME/config.conf |
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,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Source the configuration file | ||
source h-manifest.conf | ||
|
||
# Define the custom log directory | ||
LOG_DIR=$(dirname "$CUSTOM_LOG_BASENAME") | ||
mkdir -p "$LOG_DIR" | ||
|
||
# Check if the custom config filename is defined | ||
if [[ -z ${CUSTOM_CONFIG_FILENAME:-} ]]; then | ||
echo "The config file is not defined" | ||
exit 1 | ||
fi | ||
|
||
# Set the library path | ||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/hive/lib | ||
|
||
# Read the custom user configuration | ||
CUSTOM_USER_CONFIG=$(< "$CUSTOM_CONFIG_FILENAME") | ||
|
||
# Display the arguments | ||
echo "args: $CUSTOM_USER_CONFIG" | ||
|
||
MINER=spectre-miner | ||
|
||
# Remove the -arch argument and its value | ||
CLEAN=$(echo "$CUSTOM_USER_CONFIG" | sed -E 's/-arch [^ ]+ //') | ||
echo "args are now: $CLEAN" | ||
echo "We are using miner: $MINER" | ||
|
||
echo $(date +%s) > "/tmp/miner_start_time" | ||
/hive/miners/custom/$MINER/$MINER $CLEAN 2>&1 | tee -a ${CUSTOM_LOG_BASENAME}.log | ||
echo "Miner has exited" |
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,67 @@ | ||
#!/usr/bin/env bash | ||
source /hive/miners/custom/spectre-miner/h-manifest.conf | ||
|
||
# Reading log file content | ||
log_file="/var/log/miner/custom/custom.log" | ||
|
||
# Read the log file content | ||
log=$(<"$log_file") | ||
|
||
get_cpu_temps () { | ||
local t_core=$(cpu-temp) | ||
local l_num_cores=$1 | ||
local l_temp= | ||
for (( i=0; i < l_num_cores; i++ )); do | ||
l_temp+="$t_core " | ||
done | ||
echo $l_temp | tr " " "\n" | jq -cs '.' | ||
} | ||
|
||
get_cpu_fans () { | ||
local t_fan=0 | ||
local l_num_cores=$1 | ||
local l_fan= | ||
for (( i=0; i < l_num_cores; i++ )); do | ||
l_fan+="$t_fan " | ||
done | ||
echo $l_fan | tr " " "\n" | jq -cs '.' | ||
} | ||
|
||
get_uptime(){ | ||
local start_time=$(cat "/tmp/miner_start_time") | ||
local current_time=$(date +%s) | ||
let uptime=current_time-start_time | ||
echo $uptime | ||
} | ||
|
||
uptime=$(get_uptime) | ||
|
||
# Extract the most recent total khs value from the log | ||
total_khs=$(grep -oP "hashrate is: \K\d+.\d+" <<< "$log" | tail -n1) | ||
|
||
# Count the number of blocks submitted successfully | ||
ac=$(grep -coP "Block submitted successfully!" <<< "$log") | ||
|
||
rj=0 | ||
ver="custom" | ||
algo="spectrex" | ||
cpu_temp=$(/hive/sbin/cpu-temp) | ||
hs_units="hs" | ||
|
||
# Construct JSON stats | ||
stats=$(jq -nc \ | ||
--arg total_khs "$total_khs" \ | ||
--arg khs "$total_khs" \ | ||
--arg hs_units "$hs_units" \ | ||
--arg hs "[$total_khs]" \ | ||
--arg temp "[$cpu_temp]" \ | ||
--arg uptime "$uptime" \ | ||
--arg ver "$ver" \ | ||
--argjson ac "$ac" \ | ||
--argjson rj "$rj" \ | ||
--arg algo "$algo" \ | ||
'{$total_khs, $khs, $hs_units, $hs, $temp, $uptime, $ver, ar: [$ac, $rj], $algo }') | ||
|
||
echo "khs: $hs" | ||
echo "stats: $stats" | ||
echo "----------" |
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