diff --git a/lib/data/model/app/shell_func.dart b/lib/data/model/app/shell_func.dart index 297a1f68d..cebd7d79c 100644 --- a/lib/data/model/app/shell_func.dart +++ b/lib/data/model/app/shell_func.dart @@ -33,17 +33,11 @@ enum ShellFunc { /// Issue #168 /// Use `sh` for compatibility - // static final installShellCmd = """ -// mkdir -p $_homeVar/$_srvBoxDir -// cat << 'EOF' > $_installShellPath -// ${ShellFunc.allScript} -// EOF -// chmod +x $_installShellPath -// """; - - static const installerMkdirs = "mkdir -p $_homeVar/$_srvBoxDir"; - static const installerShellWriter = "cat > $_installShellPath"; - static const installerPermissionModifier = "chmod +x $_installShellPath"; + static const installShellCmd = """ +mkdir -p $_homeVar/$_srvBoxDir +cat > $_installShellPath +chmod +x $_installShellPath +"""; String get flag { switch (this) { diff --git a/lib/data/model/server/server_status_update_req.dart b/lib/data/model/server/server_status_update_req.dart index b69fa2060..d9cc2a170 100644 --- a/lib/data/model/server/server_status_update_req.dart +++ b/lib/data/model/server/server_status_update_req.dart @@ -68,6 +68,11 @@ Future _getLinuxStatus(ServerStatusUpdateReq req) async { try { final cpus = OneTimeCpuStatus.parse(StatusCmdType.cpu.find(segments)); req.ss.cpu.update(cpus); + } catch (e, s) { + Loggers.parse.warning(e, s); + } + + try { req.ss.temps.parse( StatusCmdType.tempType.find(segments), StatusCmdType.tempVal.find(segments), diff --git a/lib/data/provider/server.dart b/lib/data/provider/server.dart index 75c984b34..3e79f3521 100644 --- a/lib/data/provider/server.dart +++ b/lib/data/provider/server.dart @@ -258,33 +258,6 @@ class ServerProvider extends ChangeNotifier { notifyListeners(); } - Future _writeInstallerScript(Server s) async { - /// TODO: Find a better way to judge if the write is successful - - // Issues #275 - // Can't use writeResult to judge if the write is successful - - // void ensure(String? writeResult) { - // if (writeResult == null || writeResult.isNotEmpty) { - // throw Exception("Failed to write installer script: $writeResult"); - // } - // } - - final client = s.client; - if (client == null) { - throw Exception("Invalid state: s.client cannot be null"); - } - - await client.run(ShellFunc.installerMkdirs).string; - - await client.runForOutput(ShellFunc.installerShellWriter, - action: (session) async { - session.stdin.add(ShellFunc.allScript.uint8List); - }).string; - - await client.run(ShellFunc.installerPermissionModifier).string; - } - Future _getData(ServerPrivateInfo spi) async { final sid = spi.id; final s = _servers[sid]; @@ -333,7 +306,10 @@ class ServerProvider extends ChangeNotifier { // Write script to server // by ssh try { - await _writeInstallerScript(s); + await s.client?.runForOutput(ShellFunc.installShellCmd, + action: (session) async { + session.stdin.add(ShellFunc.allScript.uint8List); + }).string; } on SSHAuthAbortError catch (e) { TryLimiter.inc(sid); s.status.err = e.toString();