Added auto-intall of xmrig support for Windows OS (gross).
This commit is contained in:
+63
-13
@@ -13,6 +13,7 @@ import signal
|
|||||||
import platform
|
import platform
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import tarfile
|
import tarfile
|
||||||
|
import zipfile
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, Optional, Tuple
|
from typing import Dict, Optional, Tuple
|
||||||
@@ -43,6 +44,8 @@ class MoneroMiner:
|
|||||||
return 'arm64'
|
return 'arm64'
|
||||||
elif machine in ['x86_64', 'amd64', 'x64']:
|
elif machine in ['x86_64', 'amd64', 'x64']:
|
||||||
return 'x64'
|
return 'x64'
|
||||||
|
elif machine in ['i386', 'i686', 'x86']:
|
||||||
|
return 'x86'
|
||||||
else:
|
else:
|
||||||
return machine
|
return machine
|
||||||
|
|
||||||
@@ -82,6 +85,13 @@ class MoneroMiner:
|
|||||||
patterns = ['linux-static-x64.tar.gz', 'linux-x64.tar.gz', 'linux-x86_64.tar.gz']
|
patterns = ['linux-static-x64.tar.gz', 'linux-x64.tar.gz', 'linux-x86_64.tar.gz']
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
elif os_type == 'windows':
|
||||||
|
if arch == 'x64':
|
||||||
|
patterns = ['msvc-win64.zip', 'win64.zip', 'windows-x64.zip']
|
||||||
|
elif arch == 'x86':
|
||||||
|
patterns = ['msvc-win32.zip', 'win32.zip', 'windows-x86.zip']
|
||||||
|
else:
|
||||||
|
return None
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -102,10 +112,11 @@ class MoneroMiner:
|
|||||||
]
|
]
|
||||||
|
|
||||||
for path in local_paths:
|
for path in local_paths:
|
||||||
if os.path.exists(path) and os.access(path, os.X_OK):
|
if os.path.exists(path) and os.access(path, os.X_OK if os.name != 'nt' else os.F_OK):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Check in system PATH
|
# Check in system PATH (Unix-like systems)
|
||||||
|
if os.name != 'nt':
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(['which', 'xmrig'],
|
result = subprocess.run(['which', 'xmrig'],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
@@ -115,6 +126,17 @@ class MoneroMiner:
|
|||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
# Windows - check with 'where' command
|
||||||
|
try:
|
||||||
|
result = subprocess.run(['where', 'xmrig.exe'],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
timeout=5)
|
||||||
|
if result.returncode == 0:
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -126,8 +148,8 @@ class MoneroMiner:
|
|||||||
print(f"\nDetected OS: {os_type}")
|
print(f"\nDetected OS: {os_type}")
|
||||||
print(f"Detected Architecture: {arch}")
|
print(f"Detected Architecture: {arch}")
|
||||||
|
|
||||||
if os_type not in ['macos', 'linux']:
|
if os_type not in ['macos', 'linux', 'windows']:
|
||||||
print(f"\nAutomatic installation is currently only supported for macOS and Linux.")
|
print(f"\nAutomatic installation is not supported for this OS.")
|
||||||
print(f"Please install XMRig manually from: https://github.com/xmrig/xmrig/releases")
|
print(f"Please install XMRig manually from: https://github.com/xmrig/xmrig/releases")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -151,7 +173,7 @@ class MoneroMiner:
|
|||||||
print(f"\nCould not find a compatible XMRig release for {os_type} {arch}")
|
print(f"\nCould not find a compatible XMRig release for {os_type} {arch}")
|
||||||
print(f"Available files:")
|
print(f"Available files:")
|
||||||
for asset in assets:
|
for asset in assets:
|
||||||
if asset.endswith('.tar.gz'):
|
if asset.endswith(('.tar.gz', '.zip')):
|
||||||
print(f" - {asset}")
|
print(f" - {asset}")
|
||||||
print("\nPlease download manually from: https://github.com/xmrig/xmrig/releases")
|
print("\nPlease download manually from: https://github.com/xmrig/xmrig/releases")
|
||||||
return False
|
return False
|
||||||
@@ -163,12 +185,14 @@ class MoneroMiner:
|
|||||||
print(f"\nReady to download: {filename}")
|
print(f"\nReady to download: {filename}")
|
||||||
print(f"URL: {download_url}")
|
print(f"URL: {download_url}")
|
||||||
|
|
||||||
# Prompt user
|
# Prompt user (default to Yes)
|
||||||
while True:
|
while True:
|
||||||
response = input("\nDownload and install XMRig? (Y/N): ").strip().upper()
|
response = input("\nDownload and install XMRig? (Y/N) [Y]: ").strip().upper()
|
||||||
|
if response == '':
|
||||||
|
response = 'Y'
|
||||||
if response in ['Y', 'N']:
|
if response in ['Y', 'N']:
|
||||||
break
|
break
|
||||||
print("Please enter Y or N")
|
print("Please enter Y or N (or press ENTER for Yes)")
|
||||||
|
|
||||||
if response == 'N':
|
if response == 'N':
|
||||||
print("Installation cancelled.")
|
print("Installation cancelled.")
|
||||||
@@ -226,6 +250,31 @@ class MoneroMiner:
|
|||||||
# Extract
|
# Extract
|
||||||
print("Extracting archive...")
|
print("Extracting archive...")
|
||||||
try:
|
try:
|
||||||
|
is_zip = filename.endswith('.zip')
|
||||||
|
|
||||||
|
if is_zip:
|
||||||
|
# Windows ZIP file
|
||||||
|
with zipfile.ZipFile(local_filename, 'r') as zip_ref:
|
||||||
|
# Find the xmrig.exe binary in the archive
|
||||||
|
xmrig_found = False
|
||||||
|
for member in zip_ref.namelist():
|
||||||
|
if member.endswith('xmrig.exe') or member == 'xmrig.exe':
|
||||||
|
# Extract to script directory with name 'xmrig.exe'
|
||||||
|
with zip_ref.open(member) as source:
|
||||||
|
target_path = os.path.join(self.script_dir, 'xmrig.exe')
|
||||||
|
with open(target_path, 'wb') as target:
|
||||||
|
target.write(source.read())
|
||||||
|
xmrig_found = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if not xmrig_found:
|
||||||
|
print("Could not find xmrig.exe in the archive")
|
||||||
|
return False
|
||||||
|
|
||||||
|
xmrig_path = os.path.join(self.script_dir, 'xmrig.exe')
|
||||||
|
print(f"XMRig installed successfully at: {xmrig_path}")
|
||||||
|
else:
|
||||||
|
# Unix TAR.GZ file
|
||||||
with tarfile.open(local_filename, 'r:gz') as tar:
|
with tarfile.open(local_filename, 'r:gz') as tar:
|
||||||
# Find the xmrig binary in the archive
|
# Find the xmrig binary in the archive
|
||||||
for member in tar.getmembers():
|
for member in tar.getmembers():
|
||||||
@@ -236,7 +285,7 @@ class MoneroMiner:
|
|||||||
|
|
||||||
xmrig_path = os.path.join(self.script_dir, 'xmrig')
|
xmrig_path = os.path.join(self.script_dir, 'xmrig')
|
||||||
|
|
||||||
# Make executable
|
# Make executable (Unix-like systems)
|
||||||
os.chmod(xmrig_path, 0o755)
|
os.chmod(xmrig_path, 0o755)
|
||||||
print(f"XMRig installed successfully at: {xmrig_path}")
|
print(f"XMRig installed successfully at: {xmrig_path}")
|
||||||
|
|
||||||
@@ -281,11 +330,12 @@ class MoneroMiner:
|
|||||||
# Get wallet address from user
|
# Get wallet address from user
|
||||||
wallet_address = self.prompt_wallet_address()
|
wallet_address = self.prompt_wallet_address()
|
||||||
|
|
||||||
# Determine xmrig path - use ./xmrig for both macOS and Linux
|
# Determine xmrig path based on OS
|
||||||
if os_type in ['macos', 'linux']:
|
if os_type == 'windows':
|
||||||
miner_executable = "./xmrig"
|
miner_executable = "xmrig.exe"
|
||||||
else:
|
else:
|
||||||
miner_executable = "xmrig.exe" # Windows
|
# macOS and Linux
|
||||||
|
miner_executable = "./xmrig"
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
"wallet_address": wallet_address,
|
"wallet_address": wallet_address,
|
||||||
|
|||||||
Reference in New Issue
Block a user