mirror of
https://github.com/unraid/webgui.git
synced 2026-05-07 04:41:03 -05:00
Merge pull request #2193 from unraid/feat-safe-mode-go-script
feat: safe mode go script handling
This commit is contained in:
@@ -430,6 +430,11 @@ foreach (glob("$path/*.ini") as $file) {
|
||||
if ($all || $ini != "users") file_put_contents("/$diag/system/vars.txt",preg_replace(["/\n/","/^Array/"],["\r\n",$ini],anonymize(print_r(parse_ini_file($file,true),true),1)),FILE_APPEND);
|
||||
}
|
||||
|
||||
// check for safe mode
|
||||
if (_var($var,'safeMode') == 'yes') {
|
||||
file_put_contents("/$diag/system/safemode.txt", "Unraid safe mode enabled\r\n");
|
||||
}
|
||||
|
||||
// Create loads.txt
|
||||
$cpuload = run("uptime")." Cores: ".run("nproc")."\r\n".(string)@file_get_contents("$path/cpuload.ini")."\r\n";
|
||||
$loadTxt = [];
|
||||
@@ -497,12 +502,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.../' {} \\;");
|
||||
|
||||
+12
-5
@@ -243,9 +243,16 @@ 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
|
||||
else
|
||||
log "Starting emhttp"
|
||||
/usr/local/sbin/emhttp
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user