Merge pull request #269 from ReturnFI/beta
Streamlined Installation & CI Improvements
This commit is contained in:
67
.github/workflows/release.yml
vendored
67
.github/workflows/release.yml
vendored
@ -6,33 +6,84 @@ on:
|
||||
- 'VERSION'
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
build-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.22.x'
|
||||
cache-dependency-path: core/scripts/auth/go.sum
|
||||
|
||||
- name: Read version from VERSION file
|
||||
run: |
|
||||
version=$(cat VERSION)
|
||||
echo "version=${version}" >> $GITHUB_OUTPUT
|
||||
id: get_version
|
||||
run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Initialize Go module
|
||||
working-directory: ./core/scripts/auth
|
||||
run: |
|
||||
go mod init hysteria_auth
|
||||
go mod tidy
|
||||
|
||||
- name: Build and Package for linux-amd64
|
||||
id: package_amd64
|
||||
run: |
|
||||
(cd core/scripts/auth && GOOS=linux GOARCH=amd64 go build -o user_auth .)
|
||||
zip_name="Blitz-amd64.zip"
|
||||
zip -r "$zip_name" . \
|
||||
-x ".git/*" \
|
||||
".github/*" \
|
||||
".gitignore" \
|
||||
"CONTRIBUTING.md" \
|
||||
"LICENSE" \
|
||||
"README*.md" \
|
||||
"SECURITY.md" \
|
||||
"changelog" \
|
||||
"core/scripts/auth/go.*" \
|
||||
"core/scripts/auth/user_auth.go"
|
||||
rm core/scripts/auth/user_auth
|
||||
echo "zip_name=$zip_name" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
- name: Build and Package for linux-arm64
|
||||
id: package_arm64
|
||||
run: |
|
||||
(cd core/scripts/auth && GOOS=linux GOARCH=arm64 go build -o user_auth .)
|
||||
zip_name="Blitz-arm64.zip"
|
||||
zip -r "$zip_name" . \
|
||||
-x ".git/*" \
|
||||
".github/*" \
|
||||
".gitignore" \
|
||||
"CONTRIBUTING.md" \
|
||||
"LICENSE" \
|
||||
"README*.md" \
|
||||
"SECURITY.md" \
|
||||
"changelog" \
|
||||
"core/scripts/auth/go.*" \
|
||||
"core/scripts/auth/user_auth.go"
|
||||
rm core/scripts/auth/user_auth
|
||||
echo "zip_name=$zip_name" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
- name: Read changelog for release description
|
||||
id: get_changelog
|
||||
run: |
|
||||
changelog=$(cat changelog)
|
||||
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$changelog" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
id: get_changelog
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.get_version.outputs.version }}
|
||||
name: "${{ steps.get_version.outputs.version }}"
|
||||
body: ${{ steps.get_changelog.outputs.changelog }}
|
||||
files: |
|
||||
${{ steps.package_amd64.outputs.zip_name }}
|
||||
${{ steps.package_arm64.outputs.zip_name }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
15
changelog
15
changelog
@ -1,12 +1,13 @@
|
||||
### 🚀 **\[2.0.0] – Major Release: MongoDB Migration**
|
||||
### 🚀 **\[2.1.0] – Streamlined Installation & CI Improvements**
|
||||
|
||||
*Released: 2025-09-10*
|
||||
*Released: 2025-09-11*
|
||||
|
||||
#### 💾 Core Update
|
||||
#### ⚙️ CI/CD
|
||||
|
||||
* 📦 **User management migrated from `users.json` → MongoDB**
|
||||
* ⚡ Improved **scalability, performance, and reliability** for large deployments
|
||||
* 🛠️ Added **build step** to release workflow
|
||||
* 🧹 Removed unnecessary **auth binary compilation** from core install script
|
||||
|
||||
#### ⚠️ Breaking Change
|
||||
#### 📦 Installation & Upgrade
|
||||
|
||||
* Previous JSON-based `users.json` file is no longer used
|
||||
* 🔄 **Refactored install script** to use release artifacts instead of `git clone`
|
||||
* ⬆️ **Refactored upgrade script** to pull release artifacts for faster, more reliable updates
|
||||
|
||||
@ -5,28 +5,6 @@ source /etc/hysteria/core/scripts/utils.sh
|
||||
source /etc/hysteria/core/scripts/scheduler.sh
|
||||
define_colors
|
||||
|
||||
compile_auth_binary() {
|
||||
echo "Compiling authentication binary..."
|
||||
local auth_dir="/etc/hysteria/core/scripts/auth"
|
||||
|
||||
if [ -f "$auth_dir/user_auth.go" ]; then
|
||||
(
|
||||
cd "$auth_dir" || exit 1
|
||||
go mod init hysteria-auth >/dev/null 2>&1
|
||||
go mod tidy >/dev/null 2>&1
|
||||
if go build -o user_auth .; then
|
||||
chmod +x user_auth
|
||||
echo "Authentication binary compiled successfully."
|
||||
else
|
||||
echo -e "${red}Error:${NC} Failed to compile the authentication binary."
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
else
|
||||
echo -e "${red}Error:${NC} Go source file not found at $auth_dir/user_auth.go"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_hysteria() {
|
||||
local port=$1
|
||||
@ -36,8 +14,6 @@ install_hysteria() {
|
||||
|
||||
mkdir -p /etc/hysteria && cd /etc/hysteria/
|
||||
|
||||
compile_auth_binary
|
||||
|
||||
echo "Generating CA key and certificate..."
|
||||
openssl ecparam -genkey -name prime256v1 -out ca.key >/dev/null 2>&1
|
||||
openssl req -new -x509 -days 36500 -key ca.key -out ca.crt -subj "/CN=$sni" >/dev/null 2>&1
|
||||
|
||||
60
install.sh
60
install.sh
@ -119,7 +119,7 @@ install_mongodb() {
|
||||
}
|
||||
|
||||
install_packages() {
|
||||
local REQUIRED_PACKAGES=("jq" "curl" "pwgen" "python3" "python3-pip" "python3-venv" "git" "bc" "zip" "cron" "lsof" "golang-go" "gnupg" "lsb-release")
|
||||
local REQUIRED_PACKAGES=("jq" "curl" "pwgen" "python3" "python3-pip" "python3-venv" "bc" "zip" "lsof" "gnupg" "lsb-release")
|
||||
local MISSING_PACKAGES=()
|
||||
|
||||
log_info "Checking required packages..."
|
||||
@ -153,27 +153,63 @@ install_packages() {
|
||||
install_mongodb
|
||||
}
|
||||
|
||||
clone_repository() {
|
||||
log_info "Cloning Blitz repository..."
|
||||
|
||||
download_and_extract_release() {
|
||||
log_info "Downloading and extracting Blitz panel..."
|
||||
|
||||
if [ -d "/etc/hysteria" ]; then
|
||||
log_warning "Directory /etc/hysteria already exists."
|
||||
read -p "Do you want to remove it and clone again? (y/n): " -n 1 -r
|
||||
read -p "Do you want to remove it and install again? (y/n): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
rm -rf /etc/hysteria
|
||||
else
|
||||
log_info "Using existing directory."
|
||||
log_info "Skipping download. Using existing directory."
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if git clone https://github.com/ReturnFI/Blitz /etc/hysteria &> /dev/null; then
|
||||
log_success "Repository cloned successfully"
|
||||
|
||||
local arch
|
||||
case $(uname -m) in
|
||||
x86_64) arch="amd64" ;;
|
||||
aarch64) arch="arm64" ;;
|
||||
*)
|
||||
log_error "Unsupported architecture: $(uname -m)"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
log_info "Detected architecture: $arch"
|
||||
|
||||
local zip_name="Blitz-${arch}.zip"
|
||||
local download_url="https://github.com/ReturnFI/Blitz/releases/latest/download/${zip_name}"
|
||||
local temp_zip="/tmp/${zip_name}"
|
||||
|
||||
log_info "Downloading from ${download_url}..."
|
||||
if curl -sL -o "$temp_zip" "$download_url"; then
|
||||
log_success "Download complete."
|
||||
else
|
||||
log_error "Failed to clone repository"
|
||||
log_error "Failed to download the release asset. Please check the URL and your connection."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Extracting to /etc/hysteria..."
|
||||
mkdir -p /etc/hysteria
|
||||
if unzip -q "$temp_zip" -d /etc/hysteria; then
|
||||
log_success "Extracted successfully."
|
||||
else
|
||||
log_error "Failed to extract the archive."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm "$temp_zip"
|
||||
log_info "Cleaned up temporary file."
|
||||
|
||||
local auth_binary="/etc/hysteria/core/scripts/auth/user_auth"
|
||||
if [ -f "$auth_binary" ]; then
|
||||
chmod +x "$auth_binary"
|
||||
log_success "Set execute permission for auth binary."
|
||||
else
|
||||
log_warning "Auth binary not found at $auth_binary. The installation might be incomplete."
|
||||
fi
|
||||
}
|
||||
|
||||
setup_python_env() {
|
||||
@ -227,7 +263,7 @@ main() {
|
||||
check_root
|
||||
check_os_version
|
||||
install_packages
|
||||
clone_repository
|
||||
download_and_extract_release
|
||||
setup_python_env
|
||||
add_alias
|
||||
|
||||
@ -239,4 +275,4 @@ main() {
|
||||
run_menu
|
||||
}
|
||||
|
||||
main
|
||||
main
|
||||
97
upgrade.sh
97
upgrade.sh
@ -6,9 +6,6 @@ trap 'echo -e "\n❌ An error occurred. Aborting."; exit 1' ERR
|
||||
# ========== Variables ==========
|
||||
HYSTERIA_INSTALL_DIR="/etc/hysteria"
|
||||
HYSTERIA_VENV_DIR="$HYSTERIA_INSTALL_DIR/hysteria2_venv"
|
||||
AUTH_BINARY_DIR="$HYSTERIA_INSTALL_DIR/core/scripts/auth"
|
||||
REPO_URL="https://github.com/ReturnFI/Blitz"
|
||||
REPO_BRANCH="main"
|
||||
GEOSITE_URL="https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/release/geosite.dat"
|
||||
GEOIP_URL="https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/release/geoip.dat"
|
||||
MIGRATE_SCRIPT_PATH="$HYSTERIA_INSTALL_DIR/core/scripts/db/migrate_users.py"
|
||||
@ -81,6 +78,44 @@ migrate_json_to_mongo() {
|
||||
fi
|
||||
}
|
||||
|
||||
download_and_extract_latest_release() {
|
||||
local arch
|
||||
case $(uname -m) in
|
||||
x86_64) arch="amd64" ;;
|
||||
aarch64) arch="arm64" ;;
|
||||
*)
|
||||
error "Unsupported architecture: $(uname -m)"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
info "Detected architecture: $arch"
|
||||
|
||||
local zip_name="Blitz-${arch}.zip"
|
||||
local download_url="https://github.com/ReturnFI/Blitz/releases/latest/download/${zip_name}"
|
||||
local temp_zip="/tmp/${zip_name}"
|
||||
|
||||
info "Downloading latest release from ${download_url}..."
|
||||
if ! curl -sL -o "$temp_zip" "$download_url"; then
|
||||
error "Failed to download the release asset. Please check the URL and your connection."
|
||||
exit 1
|
||||
fi
|
||||
success "Download complete."
|
||||
|
||||
info "Removing old installation directory..."
|
||||
rm -rf "$HYSTERIA_INSTALL_DIR"
|
||||
mkdir -p "$HYSTERIA_INSTALL_DIR"
|
||||
|
||||
info "Extracting to ${HYSTERIA_INSTALL_DIR}..."
|
||||
if ! unzip -q "$temp_zip" -d "$HYSTERIA_INSTALL_DIR"; then
|
||||
error "Failed to extract the archive."
|
||||
exit 1
|
||||
fi
|
||||
success "Extracted successfully."
|
||||
|
||||
rm "$temp_zip"
|
||||
info "Cleaned up temporary file."
|
||||
}
|
||||
|
||||
# ========== Capture Active Services ==========
|
||||
declare -a ACTIVE_SERVICES_BEFORE_UPGRADE=()
|
||||
ALL_SERVICES=(
|
||||
@ -106,36 +141,6 @@ done
|
||||
# ========== Install MongoDB Prerequisite ==========
|
||||
install_mongodb
|
||||
|
||||
# ========== Install Go and Compile Auth Binary ==========
|
||||
install_go_and_compile_auth() {
|
||||
info "Checking for Go and compiling authentication binary..."
|
||||
if ! command -v go &>/dev/null; then
|
||||
warn "Go is not installed. Attempting to install..."
|
||||
apt-get install -y golang-go
|
||||
success "Go installed successfully."
|
||||
else
|
||||
success "Go is already installed."
|
||||
fi
|
||||
|
||||
if [[ -f "$AUTH_BINARY_DIR/user_auth.go" ]]; then
|
||||
info "Found auth binary source. Compiling..."
|
||||
(
|
||||
cd "$AUTH_BINARY_DIR"
|
||||
go mod init hysteria_auth >/dev/null 2>&1
|
||||
go mod tidy >/dev/null 2>&1
|
||||
if go build -o user_auth .; then
|
||||
chmod +x user_auth
|
||||
success "Authentication binary compiled successfully."
|
||||
else
|
||||
error "Failed to compile the authentication binary."
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
else
|
||||
warn "Authentication binary source not found. Skipping compilation."
|
||||
fi
|
||||
}
|
||||
|
||||
# ========== Backup Files ==========
|
||||
cd /root
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
@ -165,12 +170,8 @@ for FILE in "${FILES[@]}"; do
|
||||
fi
|
||||
done
|
||||
|
||||
# ========== Replace Installation ==========
|
||||
info "Removing old hysteria directory..."
|
||||
rm -rf "$HYSTERIA_INSTALL_DIR"
|
||||
|
||||
info "Cloning Blitz repository (branch: $REPO_BRANCH)..."
|
||||
git clone -q -b "$REPO_BRANCH" "$REPO_URL" "$HYSTERIA_INSTALL_DIR"
|
||||
# ========== Download and Replace Installation ==========
|
||||
download_and_extract_latest_release
|
||||
|
||||
# ========== Download Geo Data ==========
|
||||
info "Downloading geosite.dat and geoip.dat..."
|
||||
@ -202,10 +203,14 @@ fi
|
||||
|
||||
# ========== Permissions ==========
|
||||
info "Setting ownership and permissions..."
|
||||
chown hysteria:hysteria "$HYSTERIA_INSTALL_DIR/ca.key" "$HYSTERIA_INSTALL_DIR/ca.crt"
|
||||
chmod 640 "$HYSTERIA_INSTALL_DIR/ca.key" "$HYSTERIA_INSTALL_DIR/ca.crt"
|
||||
chown -R hysteria:hysteria "$HYSTERIA_INSTALL_DIR/core/scripts/telegrambot"
|
||||
if id -u hysteria >/dev/null 2>&1; then
|
||||
chown hysteria:hysteria "$HYSTERIA_INSTALL_DIR/ca.key" "$HYSTERIA_INSTALL_DIR/ca.crt" 2>/dev/null || true
|
||||
chmod 640 "$HYSTERIA_INSTALL_DIR/ca.key" "$HYSTERIA_INSTALL_DIR/ca.crt" 2>/dev/null || true
|
||||
chown -R hysteria:hysteria "$HYSTERIA_INSTALL_DIR/core/scripts/telegrambot" 2>/dev/null || true
|
||||
fi
|
||||
chmod +x "$HYSTERIA_INSTALL_DIR/core/scripts/hysteria2/kick.py"
|
||||
chmod +x "$HYSTERIA_INSTALL_DIR/core/scripts/auth/user_auth"
|
||||
success "Permissions updated."
|
||||
|
||||
# ========== Virtual Environment ==========
|
||||
info "Setting up virtual environment and installing dependencies..."
|
||||
@ -219,9 +224,6 @@ success "Python environment ready."
|
||||
# ========== Data Migration ==========
|
||||
migrate_json_to_mongo
|
||||
|
||||
# ========== Compile Go Binary ==========
|
||||
install_go_and_compile_auth
|
||||
|
||||
# ========== Systemd Services ==========
|
||||
info "Ensuring systemd services are configured..."
|
||||
if source "$HYSTERIA_INSTALL_DIR/core/scripts/scheduler.sh"; then
|
||||
@ -261,6 +263,7 @@ else
|
||||
fi
|
||||
|
||||
# ========== Launch Menu ==========
|
||||
# sleep 10
|
||||
info "Upgrade process finished. Launching menu..."
|
||||
cd "$HYSTERIA_INSTALL_DIR"
|
||||
chmod +x menu.sh
|
||||
./menu.sh
|
||||
./menu.sh
|
||||
Reference in New Issue
Block a user