Skip to content

Commit

Permalink
更新surge一键脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
LanYunDev committed Dec 31, 2023
1 parent 5fe1d8c commit 5ade9d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
50 changes: 22 additions & 28 deletions Surge一键脚本/surge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@
# 错误处理函数
handle_error() {
echo ""
echo "⚠️ 脚本发生错误!,请检查错误,5秒后退出..."
osascript -e 'display notification "自动处理脚本" with title "⚠️脚本发生错误❌~" sound name "Glass"'
sleep 5
echo "⚠️ 脚本发生错误!,请检查错误,正在后退出..."
exit 1
}

# 定义信号处理函数,用于响应 Ctrl+C
function handle_ctrl_c {
echo ""
echo "接收到 Ctrl+C,5秒后退出..."
if [[ ${upload_pace_pid} ]]; then
kill "${upload_pace_pid}" > /dev/null 2>&1
fi
sleep 5
exit 1
echo "接收到 Ctrl+C,正在退出..."
exit 0
}

# 设置信号处理程序,捕捉 SIGINT 信号(Ctrl+C)
Expand All @@ -28,21 +22,20 @@ trap handle_error ERR

function Wipes_Data {
user=$(whoami)
{
sudo rm -rf "/Applications/Surge" || true
sudo rm -rf "/tmp/Surge-*.zip" || true
sudo rm -rf "/Users/${user}/Library/Logs/Surge/" || true
sudo rm -rf "/Users/${user}/Library/Preferences/com.nssurge.surge-mac.plist" || true
sudo rm -rf "/Users/${user}/Library/Application Support/com.nssurge.surge-mac" || true
sudo rm -rf "/Users/${user}/Library/HTTPStorages/com.nssurge.surge-mac" || true

sudo /bin/launchctl unload /Library/LaunchDaemons/com.nssurge.surge-mac.helper.plist || true
sudo /usr/bin/killall -u root -9 com.nssurge.surge-mac.helper || true
sudo /bin/rm "/Library/LaunchDaemons/com.nssurge.surge-mac.helper.plist" || true
sudo /bin/rm "/Library/PrivilegedHelperTools/com.nssurge.surge-mac.helper" || true
sudo rm -rf "/Users/${user}/Library/Preferences/com.nssurge.surge-mac.plist" || true
sudo rm -rf "/Users/${user}/Library/Application\ Support/com.nssurge.surge-mac" || true
} > /dev/null 2>&1

sudo rm -rf "/Applications/Surge.app" || true
sudo rm -rf "/tmp/Surge-*.zip" || true
sudo rm -rf "/Users/${user}/Library/Logs/Surge/" || true
sudo rm -rf "/Users/${user}/Library/Preferences/com.nssurge.surge-mac.plist" || true
sudo rm -rf "/Users/${user}/Library/Application Support/com.nssurge.surge-mac" || true
sudo rm -rf "/Users/${user}/Library/HTTPStorages/com.nssurge.surge-mac" || true

sudo /bin/launchctl unload /Library/LaunchDaemons/com.nssurge.surge-mac.helper.plist || true
sudo /usr/bin/killall -u root -9 com.nssurge.surge-mac.helper || true
sudo /bin/rm "/Library/LaunchDaemons/com.nssurge.surge-mac.helper.plist" || true
sudo /bin/rm "/Library/PrivilegedHelperTools/com.nssurge.surge-mac.helper" || true
sudo rm -rf "/Users/${user}/Library/Preferences/com.nssurge.surge-mac.plist" || true
sudo rm -rf "/Users/${user}/Library/Application\ Support/com.nssurge.surge-mac" || true
}

# 检查是否为root用户,非root用户可能无法访问某些文件
Expand All @@ -58,7 +51,7 @@ SCRIPT_DIR=$(dirname "${SCRIPT_PATH}")
cd "${SCRIPT_DIR}" || exit 1

echo "⚙️ 是否需要清除Surge相关内容?"
echo "⚙️ 全新安装Surge,建议输入y并回车,只进行破解,直接回车即可."
echo "⚙️ 若需要全新安装Surge,请输入y并回车,只进行破解,直接回车即可."
read -r flag
if [[ $flag == y ]]; then
echo "⚙️ 若你安装过Surge,请确保Surge卸载干净,建议用App Cleaner & Uninstaller工具"
Expand All @@ -67,10 +60,11 @@ if [[ $flag == y ]]; then
if [[ $flag != y ]]; then
exit 1
fi
Wipes_Data
Wipes_Data > /dev/null 2>&1
download_link=$(grep '| Surge 5 ' < "../readme.md" | grep 'https://dl.nssurge.com' | awk -F '[()]' '{print $2}')
download_link_bak="https://github.com/LanYunDev/InjectLib_bak/releases/download/surge/Surge-5.4.4-2548-d7d99d568f03d3a87a049d3b6148bee6.zip"
if [[ ! "${download_link}" ]]; then
download_link="https://github.com/LanYunDev/InjectLib_bak/releases/download/surge/Surge-5.4.1-2471-6362273df75c0e6bc35e4b1734c37c52.zip"
download_link="${download_link_bak}"
fi
version=$(echo "${download_link}" | awk -F '-' '{print $2 "-" $3}')

Expand All @@ -79,7 +73,7 @@ if [[ $flag == y ]]; then
if [[ $flag != n ]]; then
if ! curl -k -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" -o "/tmp/Surge-${version}.zip" "${download_link}"; then
echo "❌ 下载失败,尝试采用仓库链接🔗"
download_link="https://github.com/LanYunDev/InjectLib_bak/releases/download/surge/Surge-5.4.1-2475-4d9e12213c92f411a549d3e113ebfd18.zip"
download_link="${download_link_bak}"
version=$(echo "${download_link}" | awk -F '-' '{print $2 "-" $3}')
curl -k -L -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" -o "/tmp/Surge-${version}.zip" "${download_link}" || (echo "Surge-${version}安装失败☹️,网络原因,请检查网络." && exit 1)
fi
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ https://twitter.com/QiuChenly
| Camtasia 2023 | [2023.3.4(124306)通杀](https://www.techsmith.com/camtasia.html) |||| 通殺不要問為什麼 |
| Final Cut Pro Trial | [(10.6.10)通杀](https://secure-appldnld.apple.com/Final_Cut_Pro_X/042-60959-20231004-B5BFDED9-9530-49C9-97EB-B7B617BC5026/FinalCutProTrial.dmg) |||| 通殺不要問為什麼 |
| MacUpdater | [激活码通杀](https://www.corecode.io/downloads/macupdater_latest.dmg) |||| 通殺序列号下面找 |
| Surge 5 | [5.4.4-2545](https://dl.nssurge.com/mac/v5/Surge-5.4.4-2548-d7d99d568f03d3a87a049d3b6148bee6.zip) |||| 老有聪明人自己没搞好出问题来问我该怎么办 不是我的问题我怎么知道怎么办?你不问开发者你问我?傻逼吧你?|
| Surge 5 | [5.4.4-2548](https://dl.nssurge.com/mac/v5/Surge-5.4.4-2548-d7d99d568f03d3a87a049d3b6148bee6.zip) |||| 老有聪明人自己没搞好出问题来问我该怎么办 不是我的问题我怎么知道怎么办?你不问开发者你问我?傻逼吧你?|
| CleanShot | [4.6.2](https://updates.getcleanshot.com/v3/CleanShot-X-4.6.2.dmg) |||| 不通杀 |
| com.edrawsoft.edrawmax/com.edrawsoft.mindmaster | 自己去官网下 |||| 不通杀 |
| UlyssesMac | [MAS版本](https://apps.apple.com/us/app/ulysses-%E5%86%99%E4%BD%9C-%E7%AC%94%E8%AE%B0-%E6%97%A5%E8%AE%B0-%E5%8D%9A%E5%AE%A2/id1225570693?l=zh-Hans-CN) |||| 苹果应用商店版本,后续版本通杀 |
Expand Down

0 comments on commit 5ade9d9

Please sign in to comment.