opt.: refactor AppShellFunc

This commit is contained in:
lollipopkit
2023-08-05 15:19:37 +08:00
parent 432e3b1824
commit c406d92b82
6 changed files with 98 additions and 80 deletions

View File

@@ -7,21 +7,7 @@ const shellPath = '$serverBoxDir/mobile_app.sh';
const echoPWD = 'echo \$PWD';
enum CmdType {
net,
sys,
cpu,
uptime,
conn,
disk,
mem,
tempType,
tempVal,
host,
sysRhel,
}
const _cmdList = [
const statusCmds = [
'cat /proc/net/dev && date +%s',
'cat /etc/os-release | grep PRETTY_NAME',
'cat /proc/stat | grep cpu',
@@ -35,12 +21,6 @@ const _cmdList = [
'cat /etc/redhat-release',
];
final shellFuncStatus = AppShellFunc(
'status',
_cmdList.join('\necho $seperator\n'),
's',
);
const dockerCmds = [
'docker version',
'docker ps -a',
@@ -48,26 +28,13 @@ const dockerCmds = [
'docker image ls',
];
final shellFuncDocker = AppShellFunc(
// `dockeR` -> avoid conflict with `docker` command
// 以防止循环递归
'dockeR',
dockerCmds.join('\necho $seperator\n'),
'd',
);
final _generated = [
shellFuncStatus,
shellFuncDocker,
].generate;
final shellCmd = """
# Script for app `${BuildData.name} v1.0.${BuildData.build}`
# Delete this file while app is running will cause app crash
export LANG=en_US.utf-8
$_generated
${AppShellFuncType.shellScript}
""";
final installShellCmd = "mkdir -p $serverBoxDir && "