From 21d30dee53c301a77c9f876194596b7e5c91cfe7 Mon Sep 17 00:00:00 2001 From: WJQSERVER Date: Mon, 10 Feb 2025 23:25:16 +0800 Subject: [PATCH] update deploy bash --- README.md | 6 +++ deploy/config.toml | 2 +- deploy/install-dev.sh | 90 +++++++++++++++++++++---------------------- deploy/install.sh | 42 ++++++++++---------- 4 files changed, 71 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index bd615e4..4c9f587 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,12 @@ docker run -p 7210:8080 -v ./ghproxy/log/run:/data/ghproxy/log -v ./ghproxy/log/ wget -O install.sh https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/deploy/install.sh && chmod +x install.sh &&./install.sh ``` +Dev一键部署脚本: + +```bash +wget -O install-dev.sh https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/dev/deploy/install-dev.sh && chmod +x install-dev.sh && ./install-dev.sh +``` + ## 配置说明 ### 外部配置文件 diff --git a/deploy/config.toml b/deploy/config.toml index 7f0dd82..c217b5d 100644 --- a/deploy/config.toml +++ b/deploy/config.toml @@ -2,7 +2,7 @@ host = "127.0.0.1" port = 8080 sizeLimit = 125 # MB -enableH2C = false +enableH2C = "on" debug = false [pages] diff --git a/deploy/install-dev.sh b/deploy/install-dev.sh index 8cb9cff..03d6030 100644 --- a/deploy/install-dev.sh +++ b/deploy/install-dev.sh @@ -73,8 +73,51 @@ if [ -z "$ghproxy_dir" ]; then ghproxy_dir="/usr/local/ghproxy" fi -make_systemd_service() { +# 创建目录 +mkdir -p ${ghproxy_dir} +mkdir -p ${ghproxy_dir}/config +mkdir -p ${ghproxy_dir}/log +mkdir -p ${ghproxy_dir}/pages + +# 获取最新版本号 +VERSION=$(curl -s https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/dev/DEV-VERSION) +wget -q -O ${ghproxy_dir}/VERSION https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/dev/DEV-VERSION + +# 下载ghproxy +wget -q -O ${ghproxy_dir}/ghproxy-linux-$ARCH.tar.gz https://github.com/WJQSERVER-STUDIO/ghproxy/releases/download/$VERSION/ghproxy-linux-$ARCH.tar.gz +install tar +tar -zxvf ${ghproxy_dir}/ghproxy-linux-$ARCH.tar.gz -C ${ghproxy_dir} +chmod +x ${ghproxy_dir}/ghproxy + +# 下载pages +wget -q -O ${ghproxy_dir}/pages/index.html https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/dev/pages/index.html +wget -q -O ${ghproxy_dir}/pages/favicon.ico https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/dev/pages/favicon.ico + + +# 下载配置文件 +if [ -f ${ghproxy_dir}/config/config.toml ]; then + echo "配置文件已存在, 跳过下载" + echo "[WARNING] 请检查配置文件是否正确,DEV版本升级时请注意配置文件兼容性" + sleep 2 +else + wget -q -O ${ghproxy_dir}/config/config.toml https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/dev/deploy/config.toml +fi + +# 替换 port = 8080 +sed -i "s/port = 8080/port = $PORT/g" ${ghproxy_dir}/config/config.toml +sed -i 's/host = "127.0.0.1"/host = "'"$IP"'"/g' ${ghproxy_dir}/config/config.toml +sed -i "s|staticDir = \"/usr/local/ghproxy/pages\"|staticDir = \"${ghproxy_dir}/pages\"|g" ${ghproxy_dir}/config/config.toml +sed -i "s|logFilePath = \"/usr/local/ghproxy/log/ghproxy.log\"|logFilePath = \"${ghproxy_dir}/log/ghproxy.log\"|g" ${ghproxy_dir}/config/config.toml +sed -i "s|blacklistFile = \"/usr/local/ghproxy/config/blacklist.json\"|blacklistFile = \"${ghproxy_dir}/config/blacklist.json\"|g" ${ghproxy_dir}/config/config.toml +sed -i "s|whitelistFile = \"/usr/local/ghproxy/config/whitelist.json\"|whitelistFile = \"${ghproxy_dir}/config/whitelist.json\"|g" ${ghproxy_dir}/config/config.toml + +# 下载systemd服务文件 +if [ "$ghproxy_dir" = "/usr/local/ghproxy" ]; then + wget -q -O /etc/systemd/system/ghproxy.service https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/dev/deploy/ghproxy.service +else + cat < /etc/systemd/system/ghproxy.service + [Unit] Description=Github Proxy Service After=network.target @@ -91,51 +134,6 @@ WantedBy=multi-user.target EOF -} - -# 创建目录 -mkdir -p ${ghproxy_dir} -mkdir -p ${ghproxy_dir}/config -mkdir -p ${ghproxy_dir}/log -mkdir -p ${ghproxy_dir}/pages - -# 获取最新版本号 -VERSION=$(curl -s https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/DEV-VERSION) -wget -q -O ${ghproxy_dir}/VERSION https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/DEV-VERSION - -# 下载ghproxy -wget -q -O ${ghproxy_dir}/ghproxy https://github.com/WJQSERVER-STUDIO/ghproxy/releases/download/$VERSION/ghproxy-linux-$ARCH.tar.gz -install tar -tar -zxvf ${ghproxy_dir}/ghproxy-linux-$ARCH.tar.gz -C ${ghproxy_dir} -chmod +x ${ghproxy_dir}/ghproxy - -# 下载pages -wget -q -O ${ghproxy_dir}/pages/index.html https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/pages/index.html -wget -q -O ${ghproxy_dir}/pages/favicon.ico https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/pages/favicon.ico - - -# 下载配置文件 -if [ -f ${ghproxy_dir}/config/config.toml ]; then - echo "配置文件已存在, 跳过下载" - echo "[WARNING] 请检查配置文件是否正确,DEV版本升级时请注意配置文件兼容性" - sleep 2 -else - wget -q -O ${ghproxy_dir}/config/config.toml https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/deploy/config.toml -fi - -# 替换 port = 8080 -sed -i "s/port = 8080/port = $PORT/g" ${ghproxy_dir}/config/config.toml -sed -i 's/host = "127.0.0.1"/host = "'"$IP"'"/g' ${ghproxy_dir}/config/config.toml -sed -i "s|staticDir = \"/usr/local/ghproxy/pages\"|staticDir = \"${ghproxy_dir}/pages\"|g" ${ghproxy_dir}/config/config.toml -sed -i "s|logFilePath = \"/usr/local/ghproxy/log/ghproxy.log\"|logFilePath = \"${ghproxy_dir}/log/ghproxy.log\"|g" ${ghproxy_dir}/config/config.toml -sed -i "s|blacklistFile = \"/usr/local/ghproxy/config/blacklist.json\"|blacklistFile = \"${ghproxy_dir}/config/blacklist.json\"|g" ${ghproxy_dir}/config/config.toml -sed -i "s|whitelistFile = \"/usr/local/ghproxy/config/whitelist.json\"|whitelistFile = \"${ghproxy_dir}/config/whitelist.json\"|g" ${ghproxy_dir}/config/config.toml - -# 下载systemd服务文件 -if [ "$ghproxy_dir" = "/usr/local/ghproxy" ]; then - wget -q -O /etc/systemd/system/ghproxy.service https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/deploy/ghproxy.service -else - make_systemd_service() fi # 启动ghproxy diff --git a/deploy/install.sh b/deploy/install.sh index f56a2d4..b054299 100644 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -73,26 +73,6 @@ if [ -z "$ghproxy_dir" ]; then ghproxy_dir="/usr/local/ghproxy" fi -make_systemd_service() { - cat < /etc/systemd/system/ghproxy.service -[Unit] -Description=Github Proxy Service -After=network.target - -[Service] -ExecStart=/bin/bash -c '$ghproxy_dir/ghproxy -cfg $ghproxy_dir/config/config.toml > $ghproxy_dir/log/run.log 2>&1' -WorkingDirectory=$ghproxy_dir -Restart=always -User=root -Group=root - -[Install] -WantedBy=multi-user.target - -EOF - -} - # 创建目录 mkdir -p ${ghproxy_dir} mkdir -p ${ghproxy_dir}/config @@ -104,7 +84,7 @@ VERSION=$(curl -s https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/mai wget -q -O ${ghproxy_dir}/VERSION https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/VERSION # 下载ghproxy -wget -q -O ${ghproxy_dir}/ghproxy https://github.com/WJQSERVER-STUDIO/ghproxy/releases/download/${VERSION}/ghproxy-linux-${ARCH}.tar.gz +wget -q -O ${ghproxy_dir}/ghproxy-linux-$ARCH.tar.gz https://github.com/WJQSERVER-STUDIO/ghproxy/releases/download/${VERSION}/ghproxy-linux-${ARCH}.tar.gz install tar tar -zxvf ${ghproxy_dir}/ghproxy-linux-$ARCH.tar.gz -C ${ghproxy_dir} chmod +x ${ghproxy_dir}/ghproxy @@ -135,7 +115,25 @@ sed -i "s|whitelistFile = \"/usr/local/ghproxy/config/whitelist.json\"|whitelist if [ "$ghproxy_dir" = "/usr/local/ghproxy" ]; then wget -q -O /etc/systemd/system/ghproxy.service https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/main/deploy/ghproxy.service else - make_systemd_service() + + cat < /etc/systemd/system/ghproxy.service + +[Unit] +Description=Github Proxy Service +After=network.target + +[Service] +ExecStart=/bin/bash -c '$ghproxy_dir/ghproxy -cfg $ghproxy_dir/config/config.toml > $ghproxy_dir/log/run.log 2>&1' +WorkingDirectory=$ghproxy_dir +Restart=always +User=root +Group=root + +[Install] +WantedBy=multi-user.target + +EOF + fi # 启动ghproxy