mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-03 17:06:36 +08:00
1
This commit is contained in:
+93
-93
@@ -1,93 +1,93 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
if [[ "$ARCH" != "x86_64" ]]; then
|
if [[ "$ARCH" != "x86_64" ]]; then
|
||||||
echo "❌ 不支持的架构: $ARCH,仅支持 x86_64。"
|
echo "❌ 不支持的架构: $ARCH,仅支持 x86_64。"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 固定gost下载地址
|
# 固定gost下载地址
|
||||||
DOWNLOAD_URL="https://raw.githubusercontent.com/bqlpfy/forward-panel/refs/heads/main/gost"
|
DOWNLOAD_URL="https://raw.githubusercontent.com/bqlpfy/forward-panel/refs/heads/main/gost"
|
||||||
|
|
||||||
while getopts "a:p:s:" opt; do
|
while getopts "a:p:s:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
a) SERVER_ADDR="$OPTARG" ;;
|
a) SERVER_ADDR="$OPTARG" ;;
|
||||||
p) PORT="$OPTARG" ;;
|
p) PORT="$OPTARG" ;;
|
||||||
s) SECRET="$OPTARG" ;;
|
s) SECRET="$OPTARG" ;;
|
||||||
*) echo "无效参数"; exit 1 ;;
|
*) echo "无效参数"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "$SERVER_ADDR" || -z "$PORT" || -z "$SECRET" ]]; then
|
if [[ -z "$SERVER_ADDR" || -z "$PORT" || -z "$SECRET" ]]; then
|
||||||
echo "用法: $0 -a 服务器地址 -p 端口 -s 密钥"
|
echo "用法: $0 -a 服务器地址 -p 端口 -s 密钥"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
INSTALL_DIR="/etc/gost"
|
INSTALL_DIR="/etc/gost"
|
||||||
mkdir -p "$INSTALL_DIR"
|
mkdir -p "$INSTALL_DIR"
|
||||||
|
|
||||||
|
|
||||||
for FILE in gost config.json gost.json; do
|
for FILE in gost config.json gost.json; do
|
||||||
if [[ -f "$INSTALL_DIR/$FILE" ]]; then
|
if [[ -f "$INSTALL_DIR/$FILE" ]]; then
|
||||||
echo "删除已有文件: $INSTALL_DIR/$FILE"
|
echo "删除已有文件: $INSTALL_DIR/$FILE"
|
||||||
rm -f "$INSTALL_DIR/$FILE"
|
rm -f "$INSTALL_DIR/$FILE"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# 下载gost可执行文件
|
# 下载gost可执行文件
|
||||||
curl -L "$DOWNLOAD_URL" -o "$INSTALL_DIR/gost"
|
curl -L "$DOWNLOAD_URL" -o "$INSTALL_DIR/gost"
|
||||||
chmod +x "$INSTALL_DIR/gost"
|
chmod +x "$INSTALL_DIR/gost"
|
||||||
|
|
||||||
|
|
||||||
cat > "$INSTALL_DIR/config.json" <<EOF
|
cat > "$INSTALL_DIR/config.json" <<EOF
|
||||||
{
|
{
|
||||||
"addr": "$SERVER_ADDR",
|
"addr": "$SERVER_ADDR",
|
||||||
"secret": "$SECRET"
|
"secret": "$SECRET"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
cat > "$INSTALL_DIR/gost.json" <<EOF
|
cat > "$INSTALL_DIR/gost.json" <<EOF
|
||||||
{
|
{
|
||||||
"services": [
|
"services": [
|
||||||
{
|
{
|
||||||
"name": "web_api",
|
"name": "web_api",
|
||||||
"addr": ":$PORT",
|
"addr": ":$PORT",
|
||||||
"handler": {
|
"handler": {
|
||||||
"type": "api",
|
"type": "api",
|
||||||
"auth": {
|
"auth": {
|
||||||
"username": "$SECRET",
|
"username": "$SECRET",
|
||||||
"password": "$SECRET"
|
"password": "$SECRET"
|
||||||
},
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pathPrefix": "/api"
|
"pathPrefix": "/api"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat > /etc/systemd/system/gost.service <<EOF
|
cat > /etc/systemd/system/gost.service <<EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Gost Proxy Service
|
Description=Gost Proxy Service
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
WorkingDirectory=$INSTALL_DIR
|
WorkingDirectory=$INSTALL_DIR
|
||||||
ExecStart=$INSTALL_DIR/gost
|
ExecStart=$INSTALL_DIR/gost
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
systemctl daemon-reexec
|
systemctl daemon-reexec
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable gost
|
systemctl enable gost
|
||||||
systemctl restart gost
|
systemctl restart gost
|
||||||
|
|
||||||
echo "安装完成,配置文件位于 $INSTALL_DIR,并设置为开机启动。"
|
echo "安装完成,配置文件位于 $INSTALL_DIR,并设置为开机启动。"
|
||||||
|
|||||||
Reference in New Issue
Block a user