feat: safe mode go script handling

This commit is contained in:
ljm42
2025-05-09 16:42:25 -07:00
parent 1e0895b2f2
commit 31e50e5add
2 changed files with 25 additions and 9 deletions
+12 -4
View File
@@ -497,12 +497,20 @@ if (glob("/boot/config/*.conf")) {
if (glob("/boot/config/*.dat")) {
run("cp -- /boot/config/*.dat ".escapeshellarg("/$diag/config"));
}
run("cp /boot/config/go ".escapeshellarg("/$diag/config/go.txt"));
// anonymize go file
if (!$all) {
run("sed -i -e '/password/c ***line removed***' -e '/user/c ***line removed***' -e '/pass/c ***line removed***' ".escapeshellarg("/$diag/config/go.txt"));
// handle go files
foreach (['/boot/config/go', '/boot/config/go.safemode'] as $go) {
if (file_exists($go)) {
$dest = "/$diag/config/" . basename($go) . ".txt";
run("cp " . escapeshellarg($go) . " " . escapeshellarg($dest));
// anonymize go file
if (!$all) {
run("sed -i -e '/password/c ***line removed***' -e '/user/c ***line removed***' -e '/pass/c ***line removed***' " . escapeshellarg($dest));
}
}
}
// anonymize configuration files
if (!$all) {
run("find ".escapeshellarg("/$diag/config")." -name '*.cfg' -exec sed -ri 's/^((disk|flash)(Read|Write)List.*=\")[^\"]+/\\1.../' {} \\;");
+13 -5
View File
@@ -243,9 +243,17 @@ if grep -q "$GOTEST2" $CONFIG/go; then
fi
# Invoke the 'go' script
if [[ -f $CONFIG/go ]]; then
log "Starting go script"
fromdos <$CONFIG/go >/var/tmp/go
chmod +x /var/tmp/go
/var/tmp/go
GO=go
if [[ -f /boot/unraidsafemode ]] || grep -wq unraidsafemode /proc/cmdline; then
GO=go.safemode
fi
if [[ -f $CONFIG/$GO ]]; then
log "Starting $GO script"
fromdos <$CONFIG/$GO >/var/tmp/$GO
chmod +x /var/tmp/$GO
/var/tmp/$GO
fi
if [[ ! -f /var/run/emhttpd.socket ]]; then
log "Starting emhttp"
/usr/local/sbin/emhttp
fi