1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| #!/bin/sh
REPO="wozulong/fuclaude" DOWNLOAD_DIR="./fuclaude_update" TARGET_DIR="./fuclaude" ZIP_PASSWORD="linux.do" PORT="YOUR_PORT" PASSWORD="YOUR_PASSWORD"
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/$REPO/releases/latest") DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | jq -r '.assets[] | select(.name | contains("freebsd-amd64")) | .browser_download_url')
if [ -z "$DOWNLOAD_URL" ]; then echo "无法获取下载链接,请检查仓库和资产名称。" exit 1 fi
mkdir -p "$DOWNLOAD_DIR"
curl -L -o "$DOWNLOAD_DIR/fuclaude.zip" "$DOWNLOAD_URL"
if [ $? -ne 0 ]; then echo "下载失败,请检查网络连接或下载链接。" exit 1 fi
unzip -P "$ZIP_PASSWORD" -o "$DOWNLOAD_DIR/fuclaude.zip" -d "$DOWNLOAD_DIR"
if [ $? -ne 0 ]; then echo "解压失败,请检查压缩包密码。" exit 1 fi
EXTRACTED_DIR=$(find "$DOWNLOAD_DIR" -mindepth 1 -maxdepth 1 -type d)
if [ ! -d "$EXTRACTED_DIR" ]; then echo "解压后的文件夹不存在,请检查压缩包内容。" exit 1 fi
cp -r "$EXTRACTED_DIR"/* "$TARGET_DIR"
if [ $? -ne 0 ]; then echo "复制文件失败,请检查目标目录路径和权限。" exit 1 fi
sed -i '' 's/"bind": "127.0.0.1:8181"/"bind": "0.0.0.0:'"$PORT"'"/; s/"signup_enabled": *false/"signup_enabled": true/; s/"show_session_key": *false/"show_session_key": true/; s/"site_password": *"[^"]*"/"site_password": "'"$PASSWORD"'"/' "$TARGET_DIR/config.json"
if [ $? -ne 0 ]; then echo "编辑 config.json 文件失败,请检查文件路径和权限。" exit 1 fi
rm -rf "$DOWNLOAD_DIR"
echo "更新成功!"
|