mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new & opt.
- new: support suspend and WOL #172 - opt.: `execWithPwd` when cancel - opt.: extentions
This commit is contained in:
@@ -18,6 +18,7 @@ enum ShellFunc {
|
||||
process,
|
||||
shutdown,
|
||||
reboot,
|
||||
suspend,
|
||||
;
|
||||
|
||||
String get flag {
|
||||
@@ -32,6 +33,8 @@ enum ShellFunc {
|
||||
return 'sd';
|
||||
case ShellFunc.reboot:
|
||||
return 'r';
|
||||
case ShellFunc.suspend:
|
||||
return 'sp';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,10 +54,12 @@ enum ShellFunc {
|
||||
return 'ShutDown';
|
||||
case ShellFunc.reboot:
|
||||
return 'Reboot';
|
||||
case ShellFunc.suspend:
|
||||
return 'Suspend';
|
||||
}
|
||||
}
|
||||
|
||||
String get cmd {
|
||||
String get _cmd {
|
||||
switch (this) {
|
||||
case ShellFunc.status:
|
||||
return '''
|
||||
@@ -96,6 +101,13 @@ if [ "\$userId" = "0" ]; then
|
||||
\treboot
|
||||
else
|
||||
\tsudo -S reboot
|
||||
fi''';
|
||||
case ShellFunc.suspend:
|
||||
return '''
|
||||
if [ "\$userId" = "0" ]; then
|
||||
\tsystemctl suspend
|
||||
else
|
||||
\tsudo -S systemctl suspend
|
||||
fi''';
|
||||
}
|
||||
}
|
||||
@@ -123,7 +135,7 @@ userId=\$(id -u)
|
||||
for (final func in values) {
|
||||
sb.write('''
|
||||
${func.name}() {
|
||||
${func.cmd.split('\n').map((e) => '\t$e').join('\n')}
|
||||
${func._cmd.split('\n').map((e) => '\t$e').join('\n')}
|
||||
}
|
||||
|
||||
''');
|
||||
|
||||
Reference in New Issue
Block a user