Files
w12-asm-os/asmmenu.sh
w12 f57c79e0b7 asmmenu.sh aktualisiert
alles richtig angepasst
2025-05-18 16:53:42 +02:00

296 lines
8.7 KiB
Bash
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
USER_NAME=$(whoami)
XMRIG_DIR="$HOME/xmrig-mo"
XMRIG_URL="https://github.com/MoneroOcean/xmrig/releases/download/v6.22.2-mo1/xmrig-v6.22.2-mo1-lin64.tar.gz"
POOL="gulf.moneroocean.stream"
UPDATE_URL="https://gitea.ris-universe.eu/w12/w12-asm-os/raw/branch/main/asmmenu.sh"
VERSION_URL="https://gitea.ris-universe.eu/w12/w12-asm-os/raw/branch/main/version.txt"
LOCAL_VERSION="1.0.3"
function check_for_update() {
echo "ASM-Menü Version $LOCAL_VERSION"
echo "Prüfe auf Updates ..."
if [ -f /tmp/asm_lastcheck ] && [ $(date +%s) -lt $(( $(cat /tmp/asm_lastcheck) + 180 )) ]; then
echo "[i] Letzte Update-Prüfung war vor weniger als 3 Minuten. Überspringe."
return
fi
date +%s > /tmp/asm_lastcheck
LATEST=$(curl -fsSL "$VERSION_URL")
if [ $? -ne 0 ]; then
echo "[!] Update-Prüfung fehlgeschlagen (kein Internet oder URL-Fehler)"
sleep 2
return
fi
if [ "$LATEST" != "$LOCAL_VERSION" ]; then
if (whiptail --yesno "Neue ASM OS Version verfügbar ($LATEST). Jetzt aktualisieren?" 10 60); then
update_script
fi
else
echo "[✓] Du verwendest die neueste ASM OS Version ($LOCAL_VERSION)."
sleep 2
fi
}
function update_script() {
TMP_FILE="/tmp/setupmenu.sh"
echo "[*] Lade aktuelle Version von $UPDATE_URL..."
if curl -fsSL "$UPDATE_URL" -o "$TMP_FILE"; then
sudo cp "$TMP_FILE" /usr/local/bin/asm
sudo chmod +x /usr/local/bin/asm
echo "[✓] Update erfolgreich. Starte neu..."
sleep 2
exec /usr/local/bin/asm
else
echo "[!] Update fehlgeschlagen. Prüfe Internet oder URL."
sleep 2
fi
}
function setup_autologin() {
if (whiptail --yesno "Autologin aktivieren für Benutzer $USER_NAME?" 8 60); then
sudo mkdir -p /etc/systemd/system/getty@tty1.service.d
echo "[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin $USER_NAME --noclear %I \$TERM" | sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf > /dev/null
sudo systemctl daemon-reexec
sudo systemctl restart getty@tty1
echo "[✓] Autologin aktiviert."
else
sudo rm -f /etc/systemd/system/getty@tty1.service.d/override.conf
sudo systemctl daemon-reexec
sudo systemctl restart getty@tty1
echo "[✓] Autologin deaktiviert."
fi
sleep 2
}
function install_xmrig() {
mkdir -p "$XMRIG_DIR"
cd "$XMRIG_DIR"
echo "[*] Lade XMRig MoneroOcean Version..."
curl -L "$XMRIG_URL" -o xmrig.tar.gz
tar -xzf xmrig.tar.gz
rm -f xmrig.tar.gz
if [ ! -f "$XMRIG_DIR/xmrig" ]; then
echo "[!] XMRig-Binärdatei fehlt. Installation fehlgeschlagen."
sleep 2
return
fi
chmod +x "$XMRIG_DIR/xmrig"
WALLET=$(whiptail --inputbox "Gib deine Monero-Wallet-Adresse ein:" 8 60 3>&1 1>&2 2>&3)
CPU_PORT_CHOICE=$(whiptail --title "CPU-Typ auswählen" --menu "Wähle deinen CPU-Typ:" 15 60 4 \
1 "Alte CPU/GPU (Port 10032)" \
2 "Moderne CPU/GPU (Port 10128)" \
3 "CPU/GPU-Farm (Port 18192)" 3>&1 1>&2 2>&3)
case $CPU_PORT_CHOICE in
1) POOL_PORT="10032" ;;
2) POOL_PORT="10128" ;;
3) POOL_PORT="18192" ;;
*) POOL_PORT="10128" ;;
esac
TOTAL_CORES=$(nproc)
USED_CORES=$(whiptail --inputbox "Wie viele CPU-Kerne von $TOTAL_CORES sollen verwendet werden?" 8 60 "$TOTAL_CORES" 3>&1 1>&2 2>&3)
if ! [[ "$USED_CORES" =~ ^[0-9]+$ ]] || [ "$USED_CORES" -lt 1 ] || [ "$USED_CORES" -gt "$TOTAL_CORES" ]; then
echo "[!] Ungültige Eingabe verwende alle $TOTAL_CORES Kerne."
USED_CORES=$TOTAL_CORES
fi
CPU_THREADS=""
for ((i=0; i<USED_CORES; i++)); do
CPU_THREADS="$CPU_THREADS{\"index\":$i},"
done
CPU_THREADS="[${CPU_THREADS%,}]"
cat > "$XMRIG_DIR/config.json" <<EOF
{
"autosave": true,
"cpu": {
"enabled": true,
"huge-pages": true,
"hw-aes": null,
"priority": null,
"asm": true,
"threads": $CPU_THREADS
},
"pools": [
{
"url": "$POOL:$POOL_PORT",
"user": "$WALLET",
"pass": "x",
"tls": false
}
]
}
EOF
echo "[✓] XMRig wurde installiert mit Port $POOL_PORT und $USED_CORES Kern(en)."
sleep 2
}
function uninstall_xmrig() {
if [ -d "$XMRIG_DIR" ]; then
rm -rf "$XMRIG_DIR"
echo "[✓] XMRig wurde entfernt."
else
echo "[!] XMRig ist nicht installiert."
fi
sleep 2
}
function start_xmrig() {
if [ -f "$XMRIG_DIR/xmrig" ]; then
echo "[*] Starte XMRig in screen..."
cd "$XMRIG_DIR"
if ! screen -list | grep -q "miner"; then
screen -dmS miner ./xmrig
echo "[✓] XMRig läuft nun in screen-Sitzung 'miner'."
else
echo "[i] XMRig läuft bereits."
fi
else
echo "[!] XMRig ist nicht installiert."
sleep 2
fi
}
function view_miner_with_enter_to_detach() {
if screen -list | grep -q "miner"; then
echo -e "\n\e[1;32m>> Miner läuft öffne Ansicht...\e[0m"
screen -r miner &
read -p ">> ENTER drücken zum Zurückkehren..." dummy
screen -S miner -X detach
echo "[i] Miner wieder im Hintergrund."
sleep 1
else
echo "[!] Kein laufender Miner gefunden."
sleep 2
fi
}
function change_ssh_port() {
PORT=$(whiptail --inputbox "Neuen SSH-Port eingeben (z.B. 2222):" 8 60 3>&1 1>&2 2>&3)
if [[ "$PORT" =~ ^[0-9]+$ ]]; then
sudo sed -i "s/^#\?Port .*/Port $PORT/" /etc/ssh/sshd_config
sudo systemctl restart ssh
echo "[✓] SSH-Port geändert auf $PORT."
else
echo "[!] Ungültiger Port."
fi
sleep 2
}
function change_user_pass() {
NEW_USER=$(whiptail --inputbox "Neuen Benutzernamen eingeben:" 8 60 3>&1 1>&2 2>&3)
if id "$NEW_USER" &>/dev/null; then
echo "[!] Benutzer $NEW_USER existiert bereits."
else
sudo adduser "$NEW_USER"
sudo usermod -aG sudo "$NEW_USER"
echo "[✓] Neuer Benutzer $NEW_USER erstellt."
fi
sleep 2
}
function configure_wifi_nmtui() {
if ! command -v nmtui &> /dev/null; then
echo "[*] NetworkManager wird installiert..."
sudo apt update
sudo apt install -y network-manager
sudo systemctl enable NetworkManager
sudo systemctl start NetworkManager
fi
echo "[*] Starte nmtui..."
sudo nmtui
}
function shutdown_system() {
if (whiptail --yesno "System wirklich herunterfahren?" 8 60); then
echo "[*] Fahre System herunter..."
sleep 1
sudo shutdown now
fi
}
function view_miner_with_enter_to_detach() {
if screen -list | grep -q "miner"; then
clear
echo -e "\n\e[1;32m>> Miner läuft öffne Ansicht für 20 Sekunden...\e[0m"
echo -e "\e[1;33m>> Danach wird automatisch zurück ins Menü gewechselt.\e[0m"
echo
sleep 4
# Starte im Hintergrund ein Timer, der nach 20s detacht
(sleep 20 && screen -S miner -X detach) &
# screen in interaktivem Subprozess anzeigen
script -qc "screen -r miner" /dev/null
echo
clear
echo
echo "[i] Miner wieder im Hintergrund (zurück zum ASM Menü)."
sleep 4
else
echo "[!] Kein laufender Miner gefunden."
sleep 2
fi
}
function stop_miner_screen() {
if screen -list | grep -q "miner"; then
screen -S miner -X quit
echo "[✓] Miner wurde beendet."
else
echo "[!] Keine laufende Miner-Sitzung gefunden."
fi
sleep 2
}
# Hauptmenü
while true; do
check_for_update
OPTION=$(whiptail --title "ASM OS Mining Setup Menü" --menu "Wähle eine Aktion" 22 60 13 \
1 "Autologin ein-/ausschalten" \
2 "XMRig installieren (MoneroOcean)" \
3 "XMRig deinstallieren (MoneroOcean)" \
4 "XMRig manuell starten (MoneroOcean)" \
5 "Miner anzeigen 25 sec (dann zum ASM Menü)" \
6 "Miner beenden/killen (sofort ohne Anzeige)" \
7 "SSH-Port ändern" \
8 "Benutzer ändern" \
9 "Update ASM-Script" \
10 "WLAN konfigurieren" \
11 "System neustarten" \
12 "System herunterfahren" \
13 "zum Terminal" 3>&1 1>&2 2>&3)
case $OPTION in
1) setup_autologin ;;
2) install_xmrig ;;
3) uninstall_xmrig ;;
4) start_xmrig ;;
5) view_miner_with_enter_to_detach ;;
6) stop_miner_screen ;;
7) change_ssh_port ;;
8) change_user_pass ;;
9) update_script ;;
10) configure_wifi_nmtui ;;
11) sudo reboot ;;
12) shutdown_system ;;
13) break ;;
*) echo "Ungültige Auswahl";;
esac
done