mirror of
https://github.com/TheWhiteDog9487/lag2cn.git
synced 2026-08-11 23:01:29 +08:00
当权限不足时,自动使用sudo重启自身
This commit is contained in:
@@ -32,7 +32,7 @@ jobs:
|
||||
alpine:latest /bin/sh -c '
|
||||
apk update
|
||||
apk add build-base dotnet10-sdk clang
|
||||
dotnet publish language.cs '
|
||||
dotnet publish language.cs /t:Rebuild --disable-build-servers --force '
|
||||
- name: 重命名
|
||||
if: ${{ matrix.runner == 'ubuntu-26.04-arm' }}
|
||||
run: sudo mv artifacts/language/language artifacts/language/language_arm
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
## 支持的系统
|
||||
- Debian
|
||||
- Armbian
|
||||
- Ubuntu
|
||||
- Arch Linux
|
||||
- CachyOS
|
||||
@@ -44,25 +45,27 @@ rm language_arm
|
||||
故此,如果您在使用过程中遇到问题,请在GitHub仓库打开一个新的issue,我会尽力处理
|
||||
|
||||
## 如果你想自行编译
|
||||
最低依赖项:
|
||||
- .NET 10 SDK
|
||||
- 任意C++编译器
|
||||
|
||||
推荐依赖项:
|
||||
- Alpine Linux
|
||||
所需依赖项:
|
||||
- .NET 10 SDK
|
||||
- Clang
|
||||
- build-base
|
||||
- build-base或其他等效工具集
|
||||
|
||||
推荐使用AlpineLinux进行编译,因为Alpine的系统libc就是musl,编译出的产物可以直接用而不需要管目标系统glibc的版本问题
|
||||
推荐使用Alpine Linux进行编译,因为Alpine的系统libc就是musl,编译出的产物可以直接用而不需要管目标系统glibc的版本问题
|
||||
您可以使用下面的Docker命令获得一个Alpine环境
|
||||
```shell
|
||||
docker run --rm -it -v .:/src -w /src alpine
|
||||
```
|
||||
如果您位于中国大陆境内,推荐先对apk进行换源,以加速软件包下载
|
||||
```shell
|
||||
# https://help.mirrors.cernet.edu.cn/alpine/
|
||||
printf '%s' 'https://mirrors.cernet.edu.cn/alpine/latest-stable/main
|
||||
https://mirrors.cernet.edu.cn/alpine/latest-stable/community
|
||||
' | tee /etc/apk/repositories
|
||||
```
|
||||
安装依赖项
|
||||
```shell
|
||||
apk update
|
||||
apk add clang build-base dotnet10-sdk
|
||||
apk add --no-cache clang build-base dotnet10-sdk
|
||||
```
|
||||
然后进行编译
|
||||
```shell
|
||||
|
||||
+10
-2
@@ -79,8 +79,16 @@ if (Enum.TryParse<SupportedLinuxDistributions>(OsDescription.Split(' ')[0], out
|
||||
如果是误报,请在GitHub仓库打开一个新的issue。
|
||||
".Trim();
|
||||
throw new NotSupportedException(Message); } }
|
||||
if (Environment.IsPrivilegedProcess == false){
|
||||
throw new UnauthorizedAccessException("更改语言文件需要root权限,请使用sudo重新运行本程序"); }
|
||||
if (Environment.IsPrivilegedProcess == false) {
|
||||
using var Process = new Process();
|
||||
Process.StartInfo.FileName = "sudo";
|
||||
Process.StartInfo.ArgumentList.Add(Environment.ProcessPath ?? throw new Exception("无法获取当前程序路径"));
|
||||
Console.WriteLine("更改语言文件需要root权限,当前用户权限不足");
|
||||
Console.WriteLine("正在尝试使用sudo重新运行程序");
|
||||
Console.WriteLine("如果您当前登录的用户拥有密码,请在sudo提示符中输入密码");
|
||||
Process.Start();
|
||||
Process.WaitForExit();
|
||||
Environment.Exit(Process.ExitCode); }
|
||||
|
||||
Console.WriteLine($"探测到当前系统为 {OsDescription}");
|
||||
switch (CurrentSystem){
|
||||
|
||||
Reference in New Issue
Block a user