mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
更新一大堆
This commit is contained in:
@@ -1 +1 @@
|
|||||||
2026-02-12 10:39:20
|
2026-02-12 23:50:58
|
||||||
@@ -1 +1 @@
|
|||||||
f19cad7
|
6107ecc
|
||||||
@@ -767,34 +767,6 @@ restart
|
|||||||
shutdown
|
shutdown
|
||||||
```
|
```
|
||||||
|
|
||||||
## 备份与恢复命令
|
|
||||||
|
|
||||||
### backup
|
|
||||||
备份系统。
|
|
||||||
|
|
||||||
**用法:**
|
|
||||||
```bash
|
|
||||||
backup <backup_file>
|
|
||||||
```
|
|
||||||
|
|
||||||
**示例:**
|
|
||||||
```bash
|
|
||||||
backup mybackup.zip
|
|
||||||
```
|
|
||||||
|
|
||||||
### restore
|
|
||||||
恢复系统备份。
|
|
||||||
|
|
||||||
**用法:**
|
|
||||||
```bash
|
|
||||||
restore <backup_file>
|
|
||||||
```
|
|
||||||
|
|
||||||
**示例:**
|
|
||||||
```bash
|
|
||||||
restore mybackup.zip
|
|
||||||
```
|
|
||||||
|
|
||||||
## 测试命令
|
## 测试命令
|
||||||
|
|
||||||
### cuitest
|
### cuitest
|
||||||
|
|||||||
@@ -166,12 +166,6 @@ namespace CMLeonOS.shell
|
|||||||
case "grep":
|
case "grep":
|
||||||
shell.GrepFile(args);
|
shell.GrepFile(args);
|
||||||
break;
|
break;
|
||||||
case "backup":
|
|
||||||
shell.BackupSystem(args);
|
|
||||||
break;
|
|
||||||
case "restore":
|
|
||||||
shell.RestoreSystem(args);
|
|
||||||
break;
|
|
||||||
case "ftp":
|
case "ftp":
|
||||||
shell.CreateFTP();
|
shell.CreateFTP();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -278,18 +278,6 @@ namespace CMLeonOS.Commands
|
|||||||
Description = "Execute Branswe code file"
|
Description = "Execute Branswe code file"
|
||||||
},
|
},
|
||||||
new CommandInfo
|
new CommandInfo
|
||||||
{
|
|
||||||
Command = "backup",
|
|
||||||
Parameters = "<name>",
|
|
||||||
Description = "Backup system files"
|
|
||||||
},
|
|
||||||
new CommandInfo
|
|
||||||
{
|
|
||||||
Command = "restore",
|
|
||||||
Parameters = "<name>",
|
|
||||||
Description = "Restore system files"
|
|
||||||
},
|
|
||||||
new CommandInfo
|
|
||||||
{
|
{
|
||||||
Command = "grep",
|
Command = "grep",
|
||||||
Parameters = "<pattern> <file>",
|
Parameters = "<pattern> <file>",
|
||||||
|
|||||||
119
shell/Shell.cs
119
shell/Shell.cs
@@ -408,7 +408,7 @@ namespace CMLeonOS
|
|||||||
"mv", "rename", "touch", "find", "tree", "grep", "getdisk", "user",
|
"mv", "rename", "touch", "find", "tree", "grep", "getdisk", "user",
|
||||||
"cpass", "hostname", "ipconfig", "setdns", "setgateway", "nslookup",
|
"cpass", "hostname", "ipconfig", "setdns", "setgateway", "nslookup",
|
||||||
"ping", "wget", "ftp", "tcpserver", "tcpclient", "lua", "branswe",
|
"ping", "wget", "ftp", "tcpserver", "tcpclient", "lua", "branswe",
|
||||||
"beep", "backup", "restore", "env", "whoami", "uptime", "alias",
|
"beep", "env", "whoami", "uptime", "alias",
|
||||||
"unalias", "base64", "testgui"
|
"unalias", "base64", "testgui"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -936,123 +936,6 @@ namespace CMLeonOS
|
|||||||
Commands.Environment.EnvCommand.ProcessEnvCommand(args, envManager, ShowError);
|
Commands.Environment.EnvCommand.ProcessEnvCommand(args, envManager, ShowError);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BackupSystem(string args)
|
|
||||||
{
|
|
||||||
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
|
|
||||||
if (parts.Length == 0)
|
|
||||||
{
|
|
||||||
ShowError("Error: Please specify backup name");
|
|
||||||
ShowError("Usage: backup <backupname>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string backupName = parts[0];
|
|
||||||
string backupPath = $@"0:\backup\{backupName}";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Console.WriteLine($"BackupSystem: Creating backup '{backupName}'");
|
|
||||||
Console.WriteLine($"Backup path: {backupPath}");
|
|
||||||
|
|
||||||
if (Directory.Exists(backupPath))
|
|
||||||
{
|
|
||||||
ShowWarning($"Backup '{backupName}' already exists");
|
|
||||||
ShowWarning("Returning without creating new backup");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine($"BackupSystem: Creating backup directory: {backupPath}");
|
|
||||||
Directory.CreateDirectory(backupPath);
|
|
||||||
ShowSuccess($"Backup directory created");
|
|
||||||
|
|
||||||
// 备份系统文件
|
|
||||||
string sysPath = @"0:\system";
|
|
||||||
Console.WriteLine($"BackupSystem: Checking system path: {sysPath}");
|
|
||||||
Console.WriteLine($"BackupSystem: System path exists: {Directory.Exists(sysPath)}");
|
|
||||||
|
|
||||||
if (Directory.Exists(sysPath))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"BackupSystem: Copying system files to backup");
|
|
||||||
CopyDirectory(sysPath, backupPath);
|
|
||||||
Console.WriteLine($"BackupSystem: System files copied");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine($"BackupSystem: System path does not exist, skipping system backup");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 备份用户文件
|
|
||||||
string userPath = @"0:\user";
|
|
||||||
Console.WriteLine($"BackupSystem: Checking user path: {userPath}");
|
|
||||||
Console.WriteLine($"BackupSystem: User path exists: {Directory.Exists(userPath)}");
|
|
||||||
|
|
||||||
if (Directory.Exists(userPath))
|
|
||||||
{
|
|
||||||
Console.WriteLine($"BackupSystem: Copying user files to backup");
|
|
||||||
CopyDirectory(userPath, backupPath);
|
|
||||||
Console.WriteLine($"BackupSystem: User files copied");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine($"BackupSystem: User path does not exist, skipping user backup");
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowSuccess($"Backup '{backupName}' created successfully");
|
|
||||||
ShowSuccess($"Backup location: {backupPath}");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ShowError($"Error creating backup: {ex.Message}");
|
|
||||||
ShowError($"Exception type: {ex.GetType().Name}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RestoreSystem(string args)
|
|
||||||
{
|
|
||||||
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
|
|
||||||
if (parts.Length == 0)
|
|
||||||
{
|
|
||||||
ShowError("Error: Please specify backup name");
|
|
||||||
ShowError("Usage: restore <backupname>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string backupName = parts[0];
|
|
||||||
string backupPath = $@"0:\backup\{backupName}";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!Directory.Exists(backupPath))
|
|
||||||
{
|
|
||||||
ShowError($"Error: Backup '{backupName}' not found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 恢复系统文件
|
|
||||||
string sysPath = @"0:\system";
|
|
||||||
if (Directory.Exists(backupPath))
|
|
||||||
{
|
|
||||||
CopyDirectory(backupPath, sysPath, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 恢复用户文件
|
|
||||||
string userPath = @"0:\user";
|
|
||||||
if (Directory.Exists(backupPath))
|
|
||||||
{
|
|
||||||
CopyDirectory(backupPath, userPath, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowSuccess($"Backup '{backupName}' restored successfully");
|
|
||||||
ShowSuccess($"Backup location: {backupPath}");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ShowError($"Error restoring backup: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CopyDirectory(string sourcePath, string destPath, bool overwrite = false)
|
private void CopyDirectory(string sourcePath, string destPath, bool overwrite = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user