mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 20:52:33 +02:00
binary setup script fix
This commit is contained in:
parent
2657b1f726
commit
581894c05b
2 changed files with 17 additions and 21 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
1. Install `make` and `wget` if not already
|
1. Install `bash`, `make` and `wget` if not already
|
||||||
|
|
||||||
2. Run setup script
|
2. Run setup script
|
||||||
|
|
||||||
|
@ -19,12 +19,6 @@
|
||||||
export SETUP_CODEMIRROR=0
|
export SETUP_CODEMIRROR=0
|
||||||
```
|
```
|
||||||
|
|
||||||
Setup:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
wget -qO- https://6uo.me/go-proxy-setup-binary | sudo bash
|
|
||||||
```
|
|
||||||
|
|
||||||
What it does:
|
What it does:
|
||||||
|
|
||||||
- Download source file and binary into /opt/go-proxy/$VERSION
|
- Download source file and binary into /opt/go-proxy/$VERSION
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
REPO_URL=https://github.com/yusing/go-proxy
|
REPO_URL=https://github.com/yusing/go-proxy
|
||||||
BIN_URL="${REPO_URL}/releases/download/${VERSION}/go-proxy"
|
BIN_URL="${REPO_URL}/releases/download/${VERSION}/go-proxy"
|
||||||
SRC_URL="${REPO_URL}/archive/refs/tags/${VERSION}.tar.gz"
|
SRC_URL="${REPO_URL}/archive/refs/tags/${VERSION}.tar.gz"
|
||||||
APP_ROOT="/opt/go-proxy/${VERSION}"
|
APP_ROOT="/opt/go-proxy/${VERSION}"
|
||||||
|
LOG_FILE="/tmp/go-proxy-setup.log"
|
||||||
|
|
||||||
if [ -z "$VERSION" ] || [ "$VERSION" = "latest" ]; then
|
if [ -z "$VERSION" ] || [ "$VERSION" = "latest" ]; then
|
||||||
VERSION_URL="${REPO_URL}/raw/main/version.txt"
|
VERSION_URL="${REPO_URL}/raw/main/version.txt"
|
||||||
|
@ -30,28 +31,28 @@ fi
|
||||||
dl_source() {
|
dl_source() {
|
||||||
cd /tmp
|
cd /tmp
|
||||||
echo "Downloading go-proxy source ${VERSION}"
|
echo "Downloading go-proxy source ${VERSION}"
|
||||||
wget -c "${SRC_URL}" -O go-proxy.tar.gz 2>&1
|
wget -c "${SRC_URL}" -O go-proxy.tar.gz &> $LOG_FILE
|
||||||
echo "Done"
|
|
||||||
if [ $? -gt 0 ]; then
|
if [ $? -gt 0 ]; then
|
||||||
echo "Source download failed, check your internet connection and version number"
|
echo "Source download failed, check your internet connection and version number"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "Done"
|
||||||
echo "Extracting go-proxy source ${VERSION}"
|
echo "Extracting go-proxy source ${VERSION}"
|
||||||
tar xzf go-proxy.tar.gz 2>&1
|
tar xzf go-proxy.tar.gz &> $LOG_FILE
|
||||||
if [ $? -gt 0 ]; then
|
if [ $? -gt 0 ]; then
|
||||||
echo "failed to untar go-proxy.tar.gz"
|
echo "failed to untar go-proxy.tar.gz"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
rm go-proxy.tar.gz
|
rm go-proxy.tar.gz
|
||||||
mkdir -p $(dirname $APP_ROOT)
|
mkdir -p "$(dirname "${APP_ROOT}")"
|
||||||
mv "go-proxy-${VERSION}" $APP_ROOT
|
mv "go-proxy-${VERSION}" "$APP_ROOT"
|
||||||
cd $APP_ROOT
|
cd "$APP_ROOT"
|
||||||
echo "Done"
|
echo "Done"
|
||||||
}
|
}
|
||||||
dl_binary() {
|
dl_binary() {
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
echo "Downloading go-proxy binary ${VERSION}"
|
echo "Downloading go-proxy binary ${VERSION}"
|
||||||
wget -c "${BIN_URL}" -O bin/go-proxy 2>&1
|
wget -c "${BIN_URL}" -O bin/go-proxy &> $LOG_FILE
|
||||||
if [ $? -gt 0 ]; then
|
if [ $? -gt 0 ]; then
|
||||||
echo "Binary download failed, check your internet connection and version number"
|
echo "Binary download failed, check your internet connection and version number"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -60,14 +61,14 @@ dl_binary() {
|
||||||
echo "Done"
|
echo "Done"
|
||||||
}
|
}
|
||||||
setup() {
|
setup() {
|
||||||
make setup
|
make setup &> $LOG_FILE
|
||||||
if [ $? -gt 0 ]; then
|
if [ $? -gt 0 ]; then
|
||||||
echo "make setup failed"
|
echo "make setup failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# SETUP_CODEMIRROR = 1
|
# SETUP_CODEMIRROR = 1
|
||||||
if [ "$SETUP_CODEMIRROR" != "0" ]; then
|
if [ "$SETUP_CODEMIRROR" != "0" ]; then
|
||||||
make setup-codemirror || echo "make setup-codemirror failed, ignored"
|
make setup-codemirror &> $LOG_FILE || echo "make setup-codemirror failed, ignored"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,12 +83,12 @@ if ! command -v systemctl is-system-running > /dev/null 2>&1; then
|
||||||
echo "systemctl not found, skipping systemd setup"
|
echo "systemctl not found, skipping systemd setup"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
systemctl-failed() {
|
systemctl_failed() {
|
||||||
echo "Failed to enable and start go-proxy"
|
echo "Failed to enable and start go-proxy"
|
||||||
systemctl status go-proxy
|
systemctl status go-proxy
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
mkdir -p /etc/systemd/system
|
echo "Setting up systemd service"
|
||||||
cat <<EOF > /etc/systemd/system/go-proxy.service
|
cat <<EOF > /etc/systemd/system/go-proxy.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=go-proxy reverse proxy
|
Description=go-proxy reverse proxy
|
||||||
|
@ -107,6 +108,7 @@ TimeoutStopSec=5s
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
systemctl daemon-reload || systemctl-failed
|
systemctl daemon-reload &>$LOG_FILE || systemctl_failed
|
||||||
systemctl enable --now go-proxy || systemctl-failed
|
systemctl enable --now go-proxy &>$LOG_FILE || systemctl_failed
|
||||||
|
echo "Done"
|
||||||
echo "Setup complete"
|
echo "Setup complete"
|
Loading…
Add table
Reference in a new issue