This commit is contained in:
lollipopkit
2023-08-07 20:02:09 +08:00
parent c1b3ff7bfd
commit 36b24bedb4
7 changed files with 55 additions and 52 deletions

View File

@@ -33,7 +33,16 @@ enum AppShellFuncType {
case AppShellFuncType.status:
return statusCmds.join(_cmdDivider);
case AppShellFuncType.docker:
return dockerCmds.join(_cmdDivider);
return '''
# If the cmd result contains "permission denied", try to use `sudo`
result=\$(docker version 2>&1)
deniedStr="permission denied"
containStr=\$(echo \$result | grep "\${deniedStr}")
if [[ \$containStr != "" ]]; then
${dockerCmds.join(_cmdDivider)}
else
${dockerCmds.map((e) => "sudo -S $e").join(_cmdDivider)}
fi''';
}
}

View File

@@ -126,7 +126,7 @@ class DockerProvider extends BusyProvider {
try {
final statsLines = statsRaw.split('\n');
statsLines.removeWhere((element) => element.isEmpty);
statsLines.removeAt(0);
if (statsLines.isNotEmpty) statsLines.removeAt(0);
for (var item in items!) {
final statsLine = statsLines.firstWhere(
(element) => element.contains(item.containerId),
@@ -148,6 +148,7 @@ class DockerProvider extends BusyProvider {
}
Future<void> _onPwd(String event, StreamSink<Uint8List> stdin) async {
print(event);
if (isRequestingPwd) return;
isRequestingPwd = true;
if (event.contains('[sudo] password for ')) {

View File

@@ -2,8 +2,8 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 426;
static const int build = 446;
static const String engine = "3.10.6";
static const String buildAt = "2023-08-06 16:29:23.492978";
static const String buildAt = "2023-08-07 18:34:12.547300";
static const int modifications = 4;
}