mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
opt.: refactor AppShellFunc
This commit is contained in:
@@ -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 && "
|
||||
|
||||
Reference in New Issue
Block a user