diff --git a/src/c#/GeneralUpdate.Bowl/Applications/Linux/install.sh b/src/c#/GeneralUpdate.Bowl/Applications/Linux/install.sh index 95ac8851..09ea9afa 100644 --- a/src/c#/GeneralUpdate.Bowl/Applications/Linux/install.sh +++ b/src/c#/GeneralUpdate.Bowl/Applications/Linux/install.sh @@ -1,8 +1,11 @@ #!/bin/bash +# 获取脚本的实际名称 +SCRIPT_NAME=$(basename "\$0") + # 检查是否提供了参数 if [ "$#" -ne 1 ]; then - echo "Usage: install_package.sh " + echo "Usage: $SCRIPT_NAME " exit 1 fi @@ -11,19 +14,19 @@ PACKAGE_FILE=\$1 # 检查文件类型并安装 if [[ "$PACKAGE_FILE" == *.rpm ]]; then if command -v rpm &> /dev/null; then - sudo rpm -ivh "$PACKAGE_FILE" + sudo rpm -ivh "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using rpm"; exit 1; } elif command -v dnf &> /dev/null; then - sudo dnf install -y "$PACKAGE_FILE" + sudo dnf install -y "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using dnf"; exit 1; } elif command -v yum &> /dev/null; then - sudo yum install -y "$PACKAGE_FILE" + sudo yum install -y "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using yum"; exit 1; } else echo "RPM package manager not found." exit 1 fi elif [[ "$PACKAGE_FILE" == *.deb ]]; then if command -v dpkg &> /dev/null; then - sudo dpkg -i "$PACKAGE_FILE" - sudo apt-get install -f -y # 修复依赖问题 + sudo dpkg -i "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using dpkg"; exit 1; } + sudo apt-get install -f -y || { echo "Failed to fix dependencies"; exit 1; } else echo "DEB package manager not found." exit 1 diff --git a/src/c#/GeneralUpdate.Bowl/Strategys/LinuxStrategy.cs b/src/c#/GeneralUpdate.Bowl/Strategys/LinuxStrategy.cs index 00426604..64f300c5 100644 --- a/src/c#/GeneralUpdate.Bowl/Strategys/LinuxStrategy.cs +++ b/src/c#/GeneralUpdate.Bowl/Strategys/LinuxStrategy.cs @@ -27,11 +27,13 @@ public override void Launch() private void Install() { - //TODO: 安装路径需要调整 + string scriptPath = "./install.sh"; + string packageFile = GetPacketName(); + ProcessStartInfo processStartInfo = new ProcessStartInfo() { FileName = "/bin/bash", - Arguments = $"install.sh {GetPacketName()}", + Arguments = $"{scriptPath} {packageFile}", RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, diff --git a/src/c#/GeneralUpdate.Bowl/Strategys/WindowStrategy.cs b/src/c#/GeneralUpdate.Bowl/Strategys/WindowStrategy.cs index b8bc35b4..da32bcd6 100644 --- a/src/c#/GeneralUpdate.Bowl/Strategys/WindowStrategy.cs +++ b/src/c#/GeneralUpdate.Bowl/Strategys/WindowStrategy.cs @@ -1,5 +1,4 @@ -using System.IO; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; namespace GeneralUpdate.Bowl.Strategys;