new mac sh

This commit is contained in:
yeongpin 2025-01-13 13:05:47 +08:00
parent 1f1366a0c9
commit b0ea217572

View File

@ -63,6 +63,7 @@ create_temp_dir() {
install_cursor_free_vip() { install_cursor_free_vip() {
local install_dir="/usr/local/bin" local install_dir="/usr/local/bin"
local binary_name="CursorFreeVIP_${VERSION}_${OS}" local binary_name="CursorFreeVIP_${VERSION}_${OS}"
local binary_path="${install_dir}/cursor-free-vip"
local download_url="https://github.com/yeongpin/cursor-free-vip/releases/download/v${VERSION}/${binary_name}" local download_url="https://github.com/yeongpin/cursor-free-vip/releases/download/v${VERSION}/${binary_name}"
echo -e "${CYAN} 正在下載...${NC}" echo -e "${CYAN} 正在下載...${NC}"
@ -73,14 +74,33 @@ install_cursor_free_vip() {
echo -e "${CYAN} 正在安裝...${NC}" echo -e "${CYAN} 正在安裝...${NC}"
chmod +x "${TMP_DIR}/${binary_name}" chmod +x "${TMP_DIR}/${binary_name}"
mv "${TMP_DIR}/${binary_name}" "${install_dir}/cursor-free-vip" mv "${TMP_DIR}/${binary_name}" "$binary_path"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ 安裝完成!${NC}" echo -e "${GREEN}✅ 安裝完成!${NC}"
echo -e "${CYAN} 正在啟動程序...${NC}" echo -e "${CYAN} 正在啟動程序...${NC}"
# 使用 nohup 在后台运行程序
nohup "${install_dir}/cursor-free-vip" > /dev/null 2>&1 & # 确保有执行权限
echo -e "${GREEN}✅ 程序已在後台啟動${NC}" chmod +x "$binary_path"
# 使用完整路径启动程序
if [[ "$(uname)" == "Darwin" ]]; then
# macOS
sudo -u $SUDO_USER nohup "$binary_path" > /dev/null 2>&1 &
else
# Linux
nohup "$binary_path" > /dev/null 2>&1 &
fi
# 等待一下确保程序启动
sleep 1
# 检查程序是否在运行
if pgrep -f "cursor-free-vip" > /dev/null; then
echo -e "${GREEN}✅ 程序已在後台啟動${NC}"
else
echo -e "${RED}❌ 程序啟動失敗,請手動運行 'cursor-free-vip'${NC}"
fi
else else
echo -e "${RED}❌ 安裝失敗${NC}" echo -e "${RED}❌ 安裝失敗${NC}"
exit 1 exit 1