# New School 99 log collector for Linux, version 1 (2026-11-26). Guide: https://newschool99.com/help/logs # It READS New School 99's own files and basic Linux graphics/system info, hides private details, # and writes ONE zip file on your Desktop (or Downloads). It sends nothing anywhere and changes nothing else. # You decide whether to post that zip in #bug-reports on the New School 99 Discord. ( set -u export LC_ALL=C ver=1 days=30 home_dir="${HOME%/}" xdg_data="${XDG_DATA_HOME:-$home_dir/.local/share}" lad="${xdg_data%/}/newschool99" ns="${NS99_HOME:-$home_dir/.newschool99}" dk="${DARKAN_HOME:-$home_dir/.darkanrs}" now_stamp=$(date "+%Y-%m-%d-%H%M") now_human=$(date "+%Y-%m-%d %H:%M") now_tz=$(date "+%z") zip_name="NS99-logs-${now_stamp}.zip" tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/ns99-logs.XXXXXX") || { echo "Could not create a temporary folder. Please send your logs by hand: https://newschool99.com/help/logs#by-hand" >&2 exit 1 } stage="$tmp_dir/stage" mkdir -p "$stage" out_partial="" cleanup() { rm -rf "$tmp_dir"; [ -n "${out_partial:-}" ] && rm -f "$out_partial"; } trap cleanup EXIT HUP INT TERM # Names read ONLY so we can hide them in every collected text file; never copied into the zip. hide_users="$tmp_dir/hide_users.txt" hide_hosts="$tmp_dir/hide_hosts.txt" hide_accts="$tmp_dir/hide_accts.txt" : > "$hide_users" : > "$hide_hosts" : > "$hide_accts" add_hide() { [ -n "${2:-}" ] && printf '%s\n' "$2" >> "$1" } add_hide "$hide_users" "${USER:-}" add_hide "$hide_users" "${LOGNAME:-}" if command -v id >/dev/null 2>&1; then uid_name=$(id -un 2>/dev/null || true) add_hide "$hide_users" "$uid_name" if [ -n "$uid_name" ]; then gecos="" if command -v getent >/dev/null 2>&1; then gecos=$(getent passwd "$uid_name" 2>/dev/null | cut -d: -f5 | cut -d, -f1 || true) elif [ -r /etc/passwd ]; then gecos=$(awk -F: -v u="$uid_name" '$1==u { split($5,a,","); print a[1]; exit }' /etc/passwd 2>/dev/null || true) fi add_hide "$hide_users" "$gecos" fi fi if command -v hostname >/dev/null 2>&1; then hn=$(hostname 2>/dev/null || true) if [ -n "$hn" ]; then add_hide "$hide_hosts" "$hn" case "$hn" in *.*) add_hide "$hide_hosts" "${hn%%.*}" ;; esac fi fi if [ -r /etc/hostname ]; then ehn=$(head -n 1 /etc/hostname 2>/dev/null | tr -d '\r\n' || true) if [ -n "$ehn" ]; then add_hide "$hide_hosts" "$ehn" case "$ehn" in *.*) add_hide "$hide_hosts" "${ehn%%.*}" ;; esac fi fi # Remembered game login name (read only to hide it; update-login.properties and prefs.xml are never copied). for uf in "$ns/update-login.properties" "$dk/update-login.properties"; do if [ -f "$uf" ] && [ -r "$uf" ]; then acct=$(awk ' /^[[:space:]]*username[[:space:]]*[=:]/ { sub(/^[[:space:]]*username[[:space:]]*[=:][[:space:]]*/, "") sub(/\r$/, "") out = "" n = length($0) for (i = 1; i <= n; i++) { c = substr($0, i, 1) if (c == "\\" && i < n) { i++ nx = substr($0, i, 1) if (nx == "t") out = out "\t" else if (nx == "n") out = out "\n" else if (nx == "r") out = out "\r" else if (nx == "f") out = out "\f" else out = out nx } else { out = out c } } print out exit } ' "$uf" 2>/dev/null || true) add_hide "$hide_accts" "$acct" fi done jpref="$home_dir/.java/.userPrefs/com/darkan/newschool99/pregame/prefs.xml" if [ -f "$jpref" ] && [ -r "$jpref" ]; then pref_acct=$(sed -n 's/.*key="username"[^>]*value="\([^"]*\)".*/\1/p' "$jpref" 2>/dev/null | head -n 1 | sed -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" -e 's/<//g' | tr -d '\r' || true) add_hide "$hide_accts" "$pref_acct" fi # Reads one file (capped at first 200 KB + last 2.5 MB), trims hs_err when asked, # and scrubs private details (paths, names, login, emails, IPs, tokens). scrub_file() { src="$1" dst="$2" mode="${3:-plain}" mkdir -p "$(dirname "$dst")" if command -v perl >/dev/null 2>&1; then NS99_HOME_DIR="$home_dir" NS99_USERS="$hide_users" NS99_HOSTS="$hide_hosts" NS99_ACCTS="$hide_accts" NS99_MODE="$mode" \ perl -e ' use strict; use warnings; my ($src, $dst) = @ARGV; my $mode = $ENV{NS99_MODE} || "plain"; my $home = $ENV{NS99_HOME_DIR} || ""; my $head_n = 200000; my $tail_n = 2500000; open(my $fh, "<:raw", $src) or exit 1; my $size = -s $fh; my $raw = ""; if (!defined $size || $size <= $head_n + $tail_n) { local $/; $raw = <$fh>; $raw = "" unless defined $raw; } else { read($fh, my $h, $head_n); seek($fh, $size - $tail_n, 0); read($fh, my $t, $tail_n); my $cut = $size - $head_n - $tail_n; $raw = $h . "\n...[cut $cut bytes]...\n" . $t; } close($fh); $raw =~ s/^\xEF\xBB\xBF//; if ($mode eq "hs" || $raw =~ /^(?:A fatal error has been detected|#\s*A fatal error|Register to memory mapping|Stack slot to memory mapping|Top of Stack|Instructions)/im) { $raw =~ s/^Environment Variables:.*?(?:\r?\n[ \t]*\r?\n|\z)/Environment Variables: (removed)\n\n/ms; $raw =~ s/^Register to memory mapping:.*?(?=^-{10,}\s+P R O C E S S|\z)/Register to memory mapping, top of stack, instructions: (removed)\n\n/ms; $raw =~ s/^(Top of Stack|Instructions|Stack slot to memory mapping):.*?(?=^\r?$)/$1: (removed)/gms; $raw =~ s{^([0-9a-f]+-[0-9a-f]+\s+\S+\s+[0-9a-f]+\s+\S+\s+\d+\s+)(/\S.*)$}{ my ($a, $p) = ($1, $2); if ($p =~ m{^/(?:usr|lib|lib64)/|New ?School ?99|newschool99|\.newschool99|darkan|/jdk|/jre|/runtime/|/java\b|/tmp/\.mount_|/tmp/lwjgl}i) { $a . $p; } else { $p =~ s{^.*/}{}; $a . $p; } }mige; } # Strip ANSI colour escapes $raw =~ s/\x1B\[[0-9;?]*[ -\/]*[@-~]//g; # Hide home folder and any /home/ path $home =~ s{/$}{}; if (length($home) > 3) { for my $sp ($home, do { my $x = $home; $x =~ s{/}{\\/}g; $x }, do { my $x = $home; $x =~ s{/}{%2F}g; $x }, do { my $x = $home; $x =~ s{ }{%20}g; $x }) { my $q = quotemeta($sp); $raw =~ s/$q/~/gi; } } my $sl = qr{(?:\\?/|%2F)}i; $raw =~ s{${sl}home${sl}+(?:(?!%2F)[^\\\/\s"'\''<>|:*?])+}{~}gi; # Hide user names, host names and remembered game login my %hide; my @pairs = ([$ENV{NS99_USERS}, ""], [$ENV{NS99_HOSTS}, ""], [$ENV{NS99_ACCTS}, ""]); for my $pair (@pairs) { my ($f, $rep) = @$pair; next unless defined $f && -r $f; open(my $hf, "<", $f) or next; while (my $line = <$hf>) { $line =~ s/^\s+|\s+$//g; next if length($line) < 3; $hide{$line} = $rep unless exists $hide{$line}; } close($hf); } for my $k (sort { length($b) <=> length($a) } keys %hide) { my $p = quotemeta($k); $p =~ s/\\ |_/[ _]/g; $raw =~ s/(?$2/g; $raw =~ s/^(\[Combat\] auto-play .+? on ).+$/$1/mg; $raw =~ s/(?/g; my $ipv4 = qr{(?"}ge; $raw =~ s/(?/gi; $raw =~ s/(?/gi; $raw =~ s/\b(\w*(?:password|passwd|token|secret)\w*|pwd|api[_-]?key|session[_-]?(?:id|key)|cookie)\b(["'\'']?\s*[=:]\s*)("[^"]*"|'\''[^'\'']*'\''|\S+)/$1$2/gi; $raw =~ s/--?\w*(?:token|password|secret|key)\w*\s+\S+//gi; $raw =~ s/\b(bearer|basic)\s+\S{8,}/$1 /gi; $raw =~ s/(--ns99-relaunch=|ns99\.launcher\.relaunch=)\S*(?: [^\s=:\\\/]+)*/$1/g; open(my $out, ">:raw", $dst) or exit 1; print $out $raw; close($out); ' "$src" "$dst" elif command -v python3 >/dev/null 2>&1; then NS99_HOME_DIR="$home_dir" NS99_USERS="$hide_users" NS99_HOSTS="$hide_hosts" NS99_ACCTS="$hide_accts" NS99_MODE="$mode" \ python3 -c ' import os, re, sys src, dst = sys.argv[1], sys.argv[2] mode = os.environ.get("NS99_MODE") or "plain" home = (os.environ.get("NS99_HOME_DIR") or "").rstrip("/") head_n, tail_n = 200000, 2500000 with open(src, "rb") as fh: fh.seek(0, os.SEEK_END) size = fh.tell() fh.seek(0) if size <= head_n + tail_n: data = fh.read() else: h = fh.read(head_n) fh.seek(size - tail_n) t = fh.read(tail_n) cut = size - head_n - tail_n data = h + f"\n...[cut {cut} bytes]...\n".encode("ascii") + t raw = data.decode("latin-1") if raw.startswith("\xef\xbb\xbf"): raw = raw[3:] hs_hdr = re.compile(r"^(?:A fatal error has been detected|#\s*A fatal error|Register to memory mapping|Stack slot to memory mapping|Top of Stack|Instructions)", re.I | re.M) if mode == "hs" or hs_hdr.search(raw): raw = re.sub(r"(?ms)^Environment Variables:.*?(?:\r?\n[ \t]*\r?\n|\Z)", "Environment Variables: (removed)\n\n", raw, count=1) raw = re.sub(r"(?ms)^Register to memory mapping:.*?(?=^-{10,}\s+P R O C E S S|\Z)", "Register to memory mapping, top of stack, instructions: (removed)\n\n", raw, count=1) raw = re.sub(r"(?ms)^(Top of Stack|Instructions|Stack slot to memory mapping):.*?(?=^\r?$|\Z)", r"\1: (removed)", raw) keep_re = re.compile(r"^/(?:usr|lib|lib64)/|New ?School ?99|newschool99|\.newschool99|darkan|/jdk|/jre|/runtime/|/java\b|/tmp/\.mount_|/tmp/lwjgl", re.I) def _scrub_map(m): a, p = m.group(1), m.group(2) return a + p if keep_re.search(p) else a + p.rsplit("/", 1)[-1] raw = re.sub(r"(?im)^([0-9a-f]+-[0-9a-f]+\s+\S+\s+[0-9a-f]+\s+\S+\s+\d+\s+)(/\S.*)$", _scrub_map, raw) raw = re.sub(r"\x1b\[[0-9;?]*[ -/]*[@-~]", "", raw) if len(home) > 3: for sp in (home, home.replace("/", "\\/"), home.replace("/", "%2F"), home.replace(" ", "%20")): raw = re.sub(re.escape(sp), "~", raw, flags=re.I) sl = r"(?:\\?/|%2F)" raw = re.sub(sl + r"home" + sl + r"+(?:(?!%2F)[^\\/\s\"\x27<>|:*?])+", "~", raw, flags=re.I) hide = {} for env_k, rep in (("NS99_USERS", ""), ("NS99_HOSTS", ""), ("NS99_ACCTS", "")): fp = os.environ.get(env_k) if not fp or not os.path.isfile(fp): continue try: with open(fp, "r", encoding="latin-1") as hf: for line in hf: line = line.strip() if len(line) >= 3 and line not in hide: hide[line] = rep except OSError: pass for k in sorted(hide.keys(), key=len, reverse=True): p = re.sub(r"\\ |_", "[ _]", re.escape(k)) raw = re.sub(r"(?\2", raw) raw = re.sub(r"(?m)^(\[Combat\] auto-play .+? on ).+$", r"\1", raw) raw = re.sub(r"(?", raw) ipv4 = r"(?", raw) raw = re.sub(r"(?i)(?", raw) raw = re.sub(r"(?i)(?", raw) raw = re.sub(r"(?i)\b(\w*(?:password|passwd|token|secret)\w*|pwd|api[_-]?key|session[_-]?(?:id|key)|cookie)\b([\"\x27]?\s*[=:]\s*)(\"[^\"]*\"|\x27[^\x27]*\x27|\S+)", r"\1\2", raw) raw = re.sub(r"(?i)--?\w*(?:token|password|secret|key)\w*\s+\S+", "", raw) raw = re.sub(r"(?i)\b(bearer|basic)\s+\S{8,}", r"\1 ", raw) raw = re.sub(r"(--ns99-relaunch=|ns99\.launcher\.relaunch=)\S*(?: [^\s=:\\/]+)*", r"\1", raw) with open(dst, "wb") as out: out.write(raw.encode("latin-1")) ' "$src" "$dst" else # Fallback when perl and python3 are absent: cap bytes and scrub with POSIX awk. sz=$(wc -c < "$src" | tr -d ' ') if [ "$sz" -le 2700000 ]; then cat "$src" else head -c 200000 "$src" printf '\n...[cut %s bytes]...\n' "$((sz - 2700000))" tail -c 2500000 "$src" fi | awk \ -v home="$home_dir" \ -v f_users="$hide_users" \ -v f_hosts="$hide_hosts" \ -v f_accts="$hide_accts" \ -v mode="$mode" ' function load_hide(fp, rep, line, i, j, t1, t2) { if (fp == "") return while ((getline line < fp) > 0) { gsub(/^[ \t\r]+|[ \t\r]+$/, "", line) if (length(line) < 3) continue if (line in seen_h) continue seen_h[line] = 1 nh++ hk[nh] = line hr[nh] = rep for (i = nh; i > 1 && length(hk[i]) > length(hk[i - 1]); i--) { t1 = hk[i]; hk[i] = hk[i - 1]; hk[i - 1] = t1 t2 = hr[i]; hr[i] = hr[i - 1]; hr[i - 1] = t2 } } close(fp) } function replace_lit_ci(s, pat, rep, pl, sl, pos, lp, out) { lp = length(pat) if (lp == 0) return s pl = tolower(pat) out = "" while (1) { sl = tolower(s) pos = index(sl, pl) if (pos == 0) return out s out = out substr(s, 1, pos - 1) rep s = substr(s, pos + lp) } } function replace_word_ci(s, key, rep, kn, lk, norm, pos, pre, post, out) { kn = tolower(key) gsub(/_/, " ", kn) lk = length(kn) if (lk == 0) return s out = "" while (1) { norm = tolower(s) gsub(/_/, " ", norm) pos = index(norm, kn) if (pos == 0) return out s pre = (pos > 1) ? substr(norm, pos - 1, 1) : "" post = (pos + lk <= length(norm)) ? substr(norm, pos + lk, 1) : "" if ((pre == "" || pre !~ /[a-z0-9]/) && (post == "" || post !~ /[a-z0-9]/)) { out = out substr(s, 1, pos - 1) rep s = substr(s, pos + lk) } else { out = out substr(s, 1, pos) s = substr(s, pos + 1) } } } function valid_ipv4(tok, a, n, i) { n = split(tok, a, ".") if (n != 4) return 0 for (i = 1; i <= 4; i++) { if (a[i] !~ /^[0-9]+$/ || length(a[i]) > 3) return 0 if (length(a[i]) > 1 && substr(a[i], 1, 1) == "0") return 0 if (a[i] + 0 > 255) return 0 } return 1 } function scrub_ipv4(s, out, rem, p, l, tok, pre, post, lowpre) { out = "" rem = s while (match(rem, /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/)) { p = RSTART; l = RLENGTH tok = substr(rem, p, l) pre = (p > 1) ? substr(rem, p - 1, 1) : (length(out) > 0 ? substr(out, length(out), 1) : "") post = substr(rem, p + l, 2) if (valid_ipv4(tok) && (pre == "" || pre !~ /[A-Za-z0-9_.]/) && (post == "" || (substr(post, 1, 1) !~ /[A-Za-z0-9_]/ && post !~ /^\.[0-9]/))) { lowpre = tolower(out substr(rem, 1, p - 1)) if (lowpre ~ /(version|value|java|jdk|jre|amd64|arm64|build|mesa|opengl|glibc|linux)[^a-z0-9_]?[^a-z0-9_]?[^a-z0-9_]?$/) { out = out substr(rem, 1, p + l - 1) } else { out = out substr(rem, 1, p - 1) "" } } else { out = out substr(rem, 1, p + l - 1) } rem = substr(rem, p + l) } return out rem } function valid_ipv6(tok, parts, n, i, cc, left, right, nl, nr, a, b) { if (index(tok, ":") == 0) return 0 if (index(tok, ":::") > 0) return 0 cc = index(tok, "::") if (cc == 0) { n = split(tok, parts, ":") if (n != 8) return 0 for (i = 1; i <= 8; i++) { if (parts[i] !~ /^[0-9a-fA-F]+$/ || length(parts[i]) > 4) return 0 } return 1 } if (index(substr(tok, cc + 2), "::") > 0) return 0 left = substr(tok, 1, cc - 1) right = substr(tok, cc + 2) if (left == "") return 0 nl = split(left, a, ":") if (nl < 1 || nl > 6) return 0 for (i = 1; i <= nl; i++) { if (a[i] !~ /^[0-9a-fA-F]+$/ || length(a[i]) > 4) return 0 } nr = 0 if (right != "") { nr = split(right, b, ":") if (nr > 6 || nl + nr > 7) return 0 for (i = 1; i <= nr; i++) { if (b[i] !~ /^[0-9a-fA-F]+$/ || length(b[i]) > 4) return 0 } } return 1 } function scrub_ipv6(s, out, rem, p, l, tok, pre, post) { out = "" rem = s while (match(rem, /[0-9a-fA-F]+:[0-9a-fA-F:]+/)) { p = RSTART; l = RLENGTH tok = substr(rem, p, l) pre = (p > 1) ? substr(rem, p - 1, 1) : (length(out) > 0 ? substr(out, length(out), 1) : "") post = (p + l <= length(rem)) ? substr(rem, p + l, 1) : "" if (valid_ipv6(tok) && (pre == "" || pre !~ /[A-Za-z0-9_:]/) && (post == "" || post !~ /[A-Za-z0-9_:]/)) { out = out substr(rem, 1, p - 1) "" } else { out = out substr(rem, 1, p + l - 1) } rem = substr(rem, p + l) } return out rem } function scrub_secrets(s, out, rem, low, p, l, pre, head, sep, val, q, rest, m2) { # Case-insensitive key=value / key: value secrets out = "" rem = s while (match(tolower(rem), /([a-z0-9_]*(password|passwd|token|secret)[a-z0-9_]*|pwd|api[_-]?key|session[_-]?(id|key)|cookie)["\047]?[ \t]*[=:][ \t]*/)) { p = RSTART; l = RLENGTH pre = (p > 1) ? substr(rem, p - 1, 1) : (length(out) > 0 ? substr(out, length(out), 1) : "") if (pre != "" && pre ~ /[A-Za-z0-9_]/) { out = out substr(rem, 1, p) rem = substr(rem, p + 1) continue } head = substr(rem, p, l) rest = substr(rem, p + l) if (substr(rest, 1, 1) == "\"" && match(rest, /^"[^"]*"/)) { out = out substr(rem, 1, p - 1) head "" rem = substr(rest, RLENGTH + 1) } else if (substr(rest, 1, 1) == "\047" && match(rest, /^\047[^\047]*\047/)) { out = out substr(rem, 1, p - 1) head "" rem = substr(rest, RLENGTH + 1) } else if (match(rest, /^[^ \t\r]+/)) { out = out substr(rem, 1, p - 1) head "" rem = substr(rest, RLENGTH + 1) } else { out = out substr(rem, 1, p + l - 1) rem = rest } } s = out rem # CLI flags --token / -password / --secret / --key out = ""; rem = s while (match(tolower(rem), /--?[a-z0-9_]*(token|password|secret|key)[a-z0-9_]*[ \t]+[^ \t\r]+/)) { p = RSTART; l = RLENGTH out = out substr(rem, 1, p - 1) "" rem = substr(rem, p + l) } s = out rem # Bearer / Basic tokens (>= 8 chars) out = ""; rem = s while (match(tolower(rem), /(bearer|basic)[ \t]+[^ \t\r][^ \t\r][^ \t\r][^ \t\r][^ \t\r][^ \t\r][^ \t\r][^ \t\r]+/)) { p = RSTART; l = RLENGTH pre = (p > 1) ? substr(rem, p - 1, 1) : (length(out) > 0 ? substr(out, length(out), 1) : "") if (pre != "" && pre ~ /[A-Za-z0-9_]/) { out = out substr(rem, 1, p) rem = substr(rem, p + 1) continue } match(substr(rem, p, l), /^[A-Za-z]+/) out = out substr(rem, 1, p - 1) substr(rem, p, RLENGTH) " " rem = substr(rem, p + l) } s = out rem # Relaunch blobs out = ""; rem = s while (match(rem, /(--ns99-relaunch=|ns99\.launcher\.relaunch=)[^ \t\r]*( [^ \t\r=:\\/]+)*/)) { p = RSTART; l = RLENGTH match(substr(rem, p, l), /^[^=]+=/) out = out substr(rem, 1, p - 1) substr(rem, p, RLENGTH) "" rem = substr(rem, p + l) } return out rem } BEGIN { esc = sprintf("%c", 27) bom = sprintf("%c%c%c", 239, 187, 191) sub(/\/+$/, "", home) nh = 0 load_hide(f_users, "") load_hide(f_hosts, "") load_hide(f_accts, "") is_hs = (mode == "hs" ? 1 : 0) skip = "" } { s = $0 if (NR == 1 && substr(s, 1, 3) == bom) s = substr(s, 4) low = tolower(s) if (!is_hs && low ~ /^(a fatal error has been detected|#[ \t]*a fatal error|register to memory mapping|stack slot to memory mapping|top of stack|instructions)/) { is_hs = 1 } if (skip == "env") { if (s ~ /^[ \t\r]*$/) { skip = ""; print "" } next } if (skip == "blk") { if (s ~ /^[ \t\r]*$/) { skip = ""; print "" } next } if (skip == "reg") { if (s ~ /^----------+[ \t]+P R O C E S S/) { skip = "" } else { next } } if (is_hs) { if (s ~ /^Environment Variables:/) { print "Environment Variables: (removed)" skip = "env" next } if (s ~ /^Register to memory mapping:/) { print "Register to memory mapping, top of stack, instructions: (removed)" print "" skip = "reg" next } if (match(s, /^(Top of Stack|Instructions|Stack slot to memory mapping):/)) { print substr(s, 1, RLENGTH) " (removed)" skip = "blk" next } if (match(s, /^[0-9a-fA-F]+-[0-9a-fA-F]+[ \t]+[^ \t]+[ \t]+[0-9a-fA-F]+[ \t]+[^ \t]+[ \t]+[0-9]+[ \t]+/)) { mp_pre = substr(s, 1, RLENGTH) mp_path = substr(s, RLENGTH + 1) if (substr(mp_path, 1, 1) == "/") { mp_low = tolower(mp_path) if (mp_low !~ /^\/(usr|lib|lib64)\/|new ?school ?99|newschool99|\.newschool99|darkan|\/jdk|\/jre|\/runtime\/|\/java([^a-z0-9_]|$)|\/tmp\/\.mount_|\/tmp\/lwjgl/) { sub(/^.*\//, "", mp_path) s = mp_pre mp_path } } } } # Strip ANSI colour escapes gsub(esc "\\[[0-9;?]*[ -/]*[@-~]", "", s) # Hide home folder and any /home/ path if (length(home) > 3) { h_esc = home; gsub(/\//, "\\/", h_esc) h_pct = home; gsub(/\//, "%2F", h_pct) h_spc = home; gsub(/ /, "%20", h_spc) s = replace_lit_ci(s, home, "~") s = replace_lit_ci(s, h_esc, "~") s = replace_lit_ci(s, h_pct, "~") s = replace_lit_ci(s, h_spc, "~") } gsub(/\/home\/[^\/"\047<>|:*? \t\r]+/, "~", s) gsub(/\\\/home\\\/[^\\\/"\047<>|:*? \t\r]+/, "~", s) gsub(/%2[Ff][Hh][Oo][Mm][Ee]%2[Ff][^%\/"\047<>|:*? \t\r]+/, "~", s) # Hide user names, host names and remembered game login for (i = 1; i <= nh; i++) { s = replace_word_ci(s, hk[i], hr[i]) } # Hide known player names, emails, IPv4/IPv6 and secrets if (index(s, "[Motion] pose update failed, ") > 0) { sub(/\[Motion\] pose update failed, .* falls back/, "[Motion] pose update failed, falls back", s) } if (s ~ /^\[Combat\] auto-play .* on /) { sub(/ on .*$/, " on ", s) } gsub(/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z][A-Za-z]+/, "", s) s = scrub_ipv4(s) s = scrub_ipv6(s) s = scrub_secrets(s) print s } ' > "$dst" fi } listing_file="$tmp_dir/listing.txt" seen_file="$tmp_dir/seen.txt" : > "$listing_file" : > "$seen_file" file_count=0 skipped_hs=0 file_mtime_human() { date -r "$1" "+%Y-%m-%d %H:%M" 2>/dev/null || printf '%s' "unknown" } file_mtime_epoch() { stat -c "%Y" "$1" 2>/dev/null || printf '0' } add_file() { src="$1" rel="$2" mode="${3:-plain}" [ -f "$src" ] && [ -r "$src" ] || return 0 grep -Fqx "$rel" "$seen_file" 2>/dev/null && return 0 if scrub_file "$src" "$stage/$rel" "$mode"; then printf '%s\n' "$rel" >> "$seen_file" kb=$(( ( $(wc -c < "$src" | tr -d ' ') + 1023 ) / 1024 )) mt=$(file_mtime_human "$src") printf ' %s (%s KB, changed %s)\n' "$rel" "$kb" "$mt" >> "$listing_file" file_count=$((file_count + 1)) fi } # Lists up to N regular files matching pattern in the given directories from the last 30 days, newest first. newest_matches() { limit="$1" pattern="$2" shift 2 list_tmp="$tmp_dir/cand.txt" : > "$list_tmp" for d in "$@"; do [ -d "$d" ] || continue find "$d" -maxdepth 1 -type f -name "$pattern" -mtime "-$days" 2>/dev/null | while IFS= read -r f; do ep=$(file_mtime_epoch "$f") printf '%s\t%s\n' "$ep" "$f" >> "$list_tmp" done done sort -rn -t ' ' -k1,1 "$list_tmp" | awk -F'\t' '!seen[$2]++ { print $2 }' | head -n "$limit" } # 1. Launcher and game logs, crash reports, memory reports and settings. newest_matches 8 "*.log" "$lad/logs" | while IFS= read -r f; do add_file "$f" "launcher-logs/$(basename "$f")" done add_file "$lad/state.json" "launcher-logs/state.json" newest_matches 6 "crash-*.txt" "$ns/logs" "$dk/logs" | while IFS= read -r f; do add_file "$f" "game-crash-reports/$(basename "$f")" done newest_matches 3 "report-*.txt" "$ns/logs" "$dk/logs" | while IFS= read -r f; do add_file "$f" "game-crash-reports/$(basename "$f")" done newest_matches 3 "crashed-run-*.log" "$ns/logs" "$dk/logs" | while IFS= read -r f; do add_file "$f" "game-crash-reports/$(basename "$f")" done newest_matches 1 "crash-history.txt" "$ns/logs" "$dk/logs" | while IFS= read -r f; do add_file "$f" "game-crash-reports/$(basename "$f")" done newest_matches 3 "memory-*.txt" "$ns/logs" "$dk/logs" | while IFS= read -r f; do add_file "$f" "memory-reports/$(basename "$f")" done newest_matches 5 ".running-*" "$ns/logs" "$dk/logs" | while IFS= read -r f; do bn=$(basename "$f") case "$bn" in *.tmp) continue ;; esac add_file "$f" "game-state/${bn#.}.txt" done for cfg_name in crash-recovery.properties graphics-tier.properties frame-rate.properties gpu-switch.properties mouselook.properties oom-restart.properties; do if [ -f "$ns/$cfg_name" ]; then add_file "$ns/$cfg_name" "game-settings/$cfg_name" elif [ -f "$dk/$cfg_name" ]; then add_file "$dk/$cfg_name" "game-settings/$cfg_name" fi done # 2. HotSpot native crash files (only New School 99's, never another Java program's). hs_added=0 hs_cand="$tmp_dir/hs_cand.txt" newest_matches 200 "hs_err_pid*.log" "$lad" "$lad/logs" "$ns" "$ns/logs" "$dk" "${TMPDIR:-/tmp}" "/tmp" > "$hs_cand" while IFS= read -r f; do [ -f "$f" ] || continue if head -c 200000 "$f" 2>/dev/null | grep -Eiq 'New School 99|newschool99|com\.darkan|jagex'; then if [ "$hs_added" -lt 4 ]; then add_file "$f" "java-crash-files/$(basename "$f")" hs hs_added=$((hs_added + 1)) fi else skipped_hs=$((skipped_hs + 1)) fi done < "$hs_cand" # 3. system.txt: distro, kernel, glibc, session type, CPU, memory, graphics, audio, FUSE, disk space (no serial/machine-id). sys_raw="$tmp_dir/system_raw.txt" distro_line="Linux" if [ -r /etc/os-release ]; then pn=$(awk -F= '/^PRETTY_NAME=/ { v=$2; gsub(/^"|"$/, "", v); print v; exit }' /etc/os-release 2>/dev/null || true) [ -n "$pn" ] && distro_line="$pn" fi kernel_line=$(uname -sr 2>/dev/null || echo "unknown") arch_name=$(uname -m 2>/dev/null || echo "unknown") glibc_line="unknown" if command -v ldd >/dev/null 2>&1; then glibc_line=$(ldd --version 2>&1 | head -n 1 || echo "unknown") fi cpu_model="unknown" if [ -r /proc/cpuinfo ]; then cpu_model=$(awk -F': ' '/^model name/ { print $2; exit }' /proc/cpuinfo 2>/dev/null | tr -s ' ' || true) [ -z "$cpu_model" ] && cpu_model="unknown" fi cpu_cores=$(nproc 2>/dev/null || echo "unknown") mem_gb="unknown" if [ -r /proc/meminfo ]; then mem_kb=$(awk '/^MemTotal:/ { print $2; exit }' /proc/meminfo 2>/dev/null || true) if [ -n "$mem_kb" ]; then mem_gb=$(awk -v k="$mem_kb" 'BEGIN { printf "%.1f GB installed", k / 1048576.0 }') fi fi disk_line=$(df -h "$home_dir" 2>/dev/null | awk 'NR==2 { print $4 " free of " $2 }' || echo "unknown") lang_val="${LANG:-unknown}" sess_type="${XDG_SESSION_TYPE:-unknown}" desktop_env="${XDG_CURRENT_DESKTOP:-unknown}" { printf '== Linux\n' printf '%s, %s, %s, language %s, clock UTC%s\n' "$distro_line" "$kernel_line" "$arch_name" "$lang_val" "$now_tz" printf 'glibc: %s\n' "$glibc_line" printf 'Desktop: %s (session: %s, DISPLAY=%s, WAYLAND_DISPLAY=%s)\n' "$desktop_env" "$sess_type" "${DISPLAY:-unset}" "${WAYLAND_DISPLAY:-unset}" printf 'CPU: %s (%s threads)\n' "$cpu_model" "$cpu_cores" printf 'Memory: %s\n' "$mem_gb" printf 'Free space on the home disk: %s\n' "$disk_line" printf '\n== Graphics\n' gpu_printed=0 if command -v glxinfo >/dev/null 2>&1 && [ -n "${DISPLAY:-}" ]; then glx_out=$(glxinfo -B 2>/dev/null | grep -E 'OpenGL vendor|OpenGL renderer|OpenGL core profile version|OpenGL version|direct rendering' || true) if [ -n "$glx_out" ]; then printf '%s\n' "$glx_out" gpu_printed=1 fi fi if command -v lspci >/dev/null 2>&1; then pci_out=$(lspci 2>/dev/null | grep -iE 'vga|3d|display' || true) if [ -n "$pci_out" ]; then printf '%s\n' "$pci_out" gpu_printed=1 fi fi [ "$gpu_printed" -eq 0 ] && printf 'unknown (glxinfo/lspci not available)\n' printf '\n== Audio & AppImage runtime\n' if command -v pactl >/dev/null 2>&1; then pactl info 2>/dev/null | grep -E '^Server Name:|^Server Version:' || printf 'pactl: unavailable\n' else printf 'pactl: not installed\n' fi if [ -e /dev/fuse ]; then printf 'FUSE: /dev/fuse present\n' else printf 'FUSE: /dev/fuse missing (use --appimage-extract-and-run or .tar.gz)\n' fi printf '\n== New School 99 install\n' printf 'Launcher data: %s (%s)\n' "$lad" "$([ -d "$lad" ] && echo present || echo missing)" printf 'Game data: %s (%s)\n' "$ns" "$([ -d "$ns" ] && echo present || echo missing)" if [ -d "$lad/versions" ]; then vers=$(ls -1 "$lad/versions" 2>/dev/null | tr '\n' ',' | sed 's/,$//; s/,/, /g') [ -n "$vers" ] && printf 'Game builds downloaded: %s\n' "$vers" fi } > "$sys_raw" scrub_file "$sys_raw" "$stage/system.txt" plain # 4. README.txt: what this is, what to do with it, what is inside and what was hidden. readme_raw="$tmp_dir/readme_raw.txt" { printf 'NEW SCHOOL 99 LOGS\n' printf 'Made %s (UTC%s) by the New School 99 Linux log tool, version %s.\n' "$now_human" "$now_tz" "$ver" printf 'Guide: https://newschool99.com/help/logs\n\n' printf 'WHAT TO DO WITH THIS FILE\n' printf '1. Open #bug-reports on the New School 99 Discord (not a member yet? join at https://newschool99.com/discord).\n' printf '2. Click New Post, give it a short title, drag this zip file in and say what you were doing when it went wrong.\n' printf 'We send nothing anywhere. This file stays on your computer until you post it.\n\n' printf 'THE SHORT VERSION\n' printf 'Linux: %s (%s, %s)\n' "$distro_line" "$kernel_line" "$arch_name" printf 'Session: %s (%s)\n' "$sess_type" "$desktop_env" printf 'Hardware: %s, %s\n\n' "$cpu_model" "$mem_gb" printf 'WHAT IS INSIDE\n' printf ' README.txt (this file)\n' printf ' system.txt (Linux distro, kernel, glibc, X11/Wayland session, CPU, memory, graphics, audio, FUSE, free disk space)\n' cat "$listing_file" if [ "$skipped_hs" -gt 0 ]; then printf ' (%s Java crash file(s) from other programs were left out.)\n' "$skipped_hs" fi printf '\nWHAT WAS HIDDEN\n' printf -- '- Your Linux user name and full name are shown as , your computer name as and your home folder as ~.\n' printf -- '- Your game login name is shown as , but only when the game has remembered it on this PC. The game never writes your password into these files.\n' printf -- '- Email addresses are shown as , IP addresses as , and passwords, tokens and keys as .\n' printf -- '- Java crash files lose their environment variables and memory dumps.\n' printf -- '- Other players named in the game log are shown as where the log line is known. Some may remain.\n\n' printf 'WHAT WAS NOT COLLECTED, AND WHAT WAS\n' printf 'Only New School 99'\''s own folders (~/.local/share/newschool99 and ~/.newschool99) were read, plus the basic\n' printf 'Linux summary in system.txt (no machine-id, no serial numbers). The crash files do list the file names of libraries\n' printf 'that were loaded into the game, but nothing else from other programs: no browser data, no documents, pictures or\n' printf 'screenshots, no passwords, no memory dumps. Nothing on your PC was changed: the only new file is this zip.\n' } > "$readme_raw" scrub_file "$readme_raw" "$stage/README.txt" plain # 5. Write the zip cleanly into the first writable destination (Desktop first, then Downloads). out_dir="" for cand in "$home_dir/Desktop" "$home_dir/Downloads" "$lad" "$ns/logs" "$home_dir"; do if [ -d "$cand" ] && [ -w "$cand" ]; then out_dir="$cand" break fi done if [ -z "$out_dir" ]; then echo "Could not find a writable folder for the zip file. Use the by-hand steps at https://newschool99.com/help/logs#by-hand" >&2 exit 1 fi out_zip="$out_dir/$zip_name" out_partial="${out_zip%.zip}.partial.zip" rm -f "$out_partial" fail_zip() { rm -f "$out_partial" echo "Could not write $out_zip." >&2 exit 1 } if command -v zip >/dev/null 2>&1; then (cd "$stage" && zip -q -r "$out_partial" .) || fail_zip elif command -v python3 >/dev/null 2>&1; then python3 -c ' import os, sys, zipfile src, dst = sys.argv[1], sys.argv[2] with zipfile.ZipFile(dst, "w", zipfile.ZIP_DEFLATED) as zf: for root, _, files in os.walk(src): for fn in sorted(files): full = os.path.join(root, fn) zf.write(full, os.path.relpath(full, src)) ' "$stage" "$out_partial" || fail_zip else echo "Neither zip nor python3 was found on this system. Use the by-hand steps at https://newschool99.com/help/logs#by-hand" >&2 exit 1 fi [ -s "$out_partial" ] || fail_zip mv -f "$out_partial" "$out_zip" || fail_zip [ -s "$out_zip" ] || { echo "Could not write $out_zip." >&2; exit 1; } out_partial="" file_count=$(wc -l < "$seen_file" | tr -d ' ') total_files=$((file_count + 2)) printf '\n' if [ "$out_dir" = "$home_dir/Desktop" ]; then printf 'Done! Your New School 99 logs are saved on your Desktop as:\n' else printf 'Done! Your New School 99 logs are saved in %s as:\n' "$out_dir" fi printf ' %s\n' "$zip_name" printf 'It holds %s files, with your private details hidden. We send nothing anywhere.\n' "$total_files" printf 'Next: open #bug-reports on our Discord, click New Post, drag that file in and say what happened.\n' if [ -n "${DISPLAY:-}${WAYLAND_DISPLAY:-}" ] && command -v xdg-open >/dev/null 2>&1; then nohup xdg-open "$out_dir" >/dev/null 2>&1