1
0
mirror of https://gitee.com/chuangxxt/share-copilot synced 2025-06-21 17:43:25 +00:00

first commit

This commit is contained in:
luyoyu 2023-09-09 07:38:19 +08:00
parent d905ce09c0
commit bb9c824b05
8 changed files with 44 additions and 119 deletions

112
README.md
View File

@ -1,112 +0,0 @@
# shared-pilot 一个简单的web服务器
### 1.安装
```
git clone https://gitee.com/chuangxxt/share-copilot.git
```
```
cd share-copilot
```
```
bash install.sh
```
### 2.配置
##### 2.1 config.json文件说明
```js
domain//绑定域名
host //ip
port //端口-必须443
certPath//公钥路径-必须
keyPath//私钥路径-必须
github_api_url//默认不改
token//你自己的真实副驾驶token,可放多个,请求时随机使用
verification//自定义验证token
```
##### 2.2 示例
```json
{
"server": {
"domain": "example.com",
"host": "0.0.0.0",
"port": 443,
"certPath":"./example.pem",
"keyPath":"./example.pem"
},
"copilot_config":{
"github_api_url": "https://api.github.com/copilot_internal/v2/token",
"token":[
"yours_token_1",
"yours_token_2",
"yours_token_3"
]},
"verification":""
}
```
格式不能错,不确定的去这里验证 ->https://www.json.cn/
### 3.启动
```
scop r --运行
scop rb --后台运行
scop st --停止
scop v --查看状态
```
### 4.完整示例一:
config.json
```json
{
"server": {
"domain": "api.example.com",
"host": "0.0.0.0",
"port": 443,
"certPath":"./example.pem",
"keyPath":"./example.pem"
},
"copilot_config":{
"github_api_url": "https://api.github.com/copilot_internal/v2/token",
"token":[
"ghu_xMNAYLcJAPqAfiGoobrWffkJoNcGMVJtETKA",
"ghu_GZgKFwraHorAxXXUvsUclOhxiYERPsSJeNuF",
"ghu_SPUTCLvkMKoeMstPJmhSlYsYvCojhkFjGubl"
]},
"verification":"i_am_free"
}
```
运行截图
![image-20230909050657331](C:\Users\chiro\Desktop\share-copilot\demo.png)
本地host.json
```json
{"github.com":{"user":"suibian","oauth_token":"i_am_free","dev_override":{"copilot_token_url":"https://api.example.com/copilot_internal/v2/token"}}}
```
<img src="C:\Users\chiro\Desktop\share-copilot\demo2.png" alt="image-20230909050931364" style="zoom: 80%;" />
- [问题反馈](https://t.me/luyouyu)
<img src="C:\Users\chiro\Desktop\share-copilot\qrcode.jpg" alt="qrcode" style="zoom: 33%;" />

BIN
demo.png

Binary file not shown.

Before

(image error) Size: 11 KiB

BIN
demo2.png

Binary file not shown.

Before

(image error) Size: 24 KiB

View File

@ -5,31 +5,68 @@ cat > "$START_SCRIPT_PATH" <<EOF
#!/bin/bash
EXECUTABLE_DIR="$SCRIPT_DIR"
EXECUTABLE="\$EXECUTABLE_DIR/share-copilot"
VERSION_FILE="\$EXECUTABLE_DIR/version"
CONFIG_FILE="\$EXECUTABLE_DIR/config.json"
REMOTE_VERSION_URL="https://gitee.com/chuangxxt/share-copilot/raw/master/version"
# 检查是否需要更新
if [ "\$1" != "st" ]; then
if [ -f "\$VERSION_FILE" ]; then
LOCAL_VERSION=\$(cat "\$VERSION_FILE")
REMOTE_VERSION=\$(curl -sS "\$REMOTE_VERSION_URL")
if [ "\$LOCAL_VERSION" != "\$REMOTE_VERSION" ]; then
echo "A new version (\$REMOTE_VERSION) is available. Do you want to update? (y/n)"
read -r ANSWER
if [ "\$ANSWER" == "y" ]; then
echo "Updating to version \$REMOTE_VERSION..."
# 在这里执行更新操作,如 git clone
pkill -f "\$EXECUTABLE"
cp \$CONFIG_FILE /tmp/config.json.backup
rm -rf \$EXECUTABLE_DIR/*
git clone https://gitee.com/chuangxxt/share-copilot.git "\$EXECUTABLE_DIR"
mv /tmp/config.json.backup \$CONFIG_FILE
echo "Update complete."
else
echo "Skipping update."
fi
else
echo "version: (\$LOCAL_VERSION)"
fi
else
echo "Local version file not found. Checking for updates..."
# 如果本地没有版本文件,尝试下载
curl -sS "\$REMOTE_VERSION_URL" -o "\$VERSION_FILE"
fi
fi
case "\$1" in
r)
echo "run share-copilot success!"
echo "Running share-copilot..."
"\$EXECUTABLE"
;;
rb)
echo "run share-copilot in background success!"
"\$EXECUTABLE" >/dev/null 2>&1 &
echo "Running share-copilot in the background..."
"\$EXECUTABLE" >/dev/null 2>&1 &
;;
st)
echo "share-copilot was closed"
echo "Stopping share-copilot..."
pkill -f "\$EXECUTABLE"
;;
v)
if pgrep -f "\$EXECUTABLE" >/dev/null; then
echo "share-copilot is running"
else
echo "share-copilot was closed"
echo "share-copilot is not running"
fi
;;
*)
echo "command: \$0 {r|rb|st|v}"
echo "Usage: \$0 {r|rb|st|v}"
exit 1
;;
esac
exit 0
EOF
chmod +x "$START_SCRIPT_PATH"

Binary file not shown.

Before

(image error) Size: 67 KiB

Binary file not shown.

1
version Normal file
View File

@ -0,0 +1 @@
0.1

View File

@ -1 +0,0 @@
{"version":"0.1"}