feat: upgrade MongoDB to v8.0
This commit is contained in:
35
upgrade.sh
35
upgrade.sh
@ -47,15 +47,36 @@ for SERVICE in "${ALL_SERVICES[@]}"; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# ========== New Function to Install MongoDB ==========
|
# ========== Install MongoDB ==========
|
||||||
install_mongodb() {
|
install_mongodb() {
|
||||||
info "Checking for MongoDB..."
|
info "Checking for MongoDB..."
|
||||||
if ! command -v mongod &>/dev/null; then
|
if ! command -v mongod &>/dev/null; then
|
||||||
warn "MongoDB not found. Attempting to install from official repository..."
|
warn "MongoDB not found. Installing from official repository..."
|
||||||
|
|
||||||
|
local os_name os_version
|
||||||
|
os_name=$(grep '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"')
|
||||||
|
os_version=$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2 | tr -d '"')
|
||||||
|
|
||||||
apt-get update -qq >/dev/null
|
apt-get update -qq >/dev/null
|
||||||
apt-get install -y gnupg curl >/dev/null
|
apt-get install -y gnupg curl lsb-release >/dev/null
|
||||||
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor
|
|
||||||
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/debian bookworm/mongodb-org/7.0 main" > /etc/apt/sources.list.d/mongodb-org-7.0.list
|
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
|
||||||
|
|
||||||
|
if [[ "$os_name" == "ubuntu" ]]; then
|
||||||
|
if [[ "$os_version" == "24.04" ]]; then
|
||||||
|
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" > /etc/apt/sources.list.d/mongodb-org-8.0.list
|
||||||
|
elif [[ "$os_version" == "22.04" ]]; then
|
||||||
|
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/8.0 multiverse" > /etc/apt/sources.list.d/mongodb-org-8.0.list
|
||||||
|
else
|
||||||
|
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/8.0 multiverse" > /etc/apt/sources.list.d/mongodb-org-8.0.list
|
||||||
|
fi
|
||||||
|
elif [[ "$os_name" == "debian" && "$os_version" == "12" ]]; then
|
||||||
|
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] http://repo.mongodb.org/apt/debian bookworm/mongodb-org/8.0 main" > /etc/apt/sources.list.d/mongodb-org-8.0.list
|
||||||
|
else
|
||||||
|
error "Unsupported OS for MongoDB installation: $os_name $os_version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
apt-get update -qq >/dev/null
|
apt-get update -qq >/dev/null
|
||||||
apt-get install -y mongodb-org >/dev/null
|
apt-get install -y mongodb-org >/dev/null
|
||||||
systemctl start mongod
|
systemctl start mongod
|
||||||
@ -66,7 +87,7 @@ install_mongodb() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ========== New Function to Migrate users.json to MongoDB ==========
|
# ========== Migrate users.json to MongoDB ==========
|
||||||
migrate_users_to_mongodb() {
|
migrate_users_to_mongodb() {
|
||||||
info "Checking for user data to migrate..."
|
info "Checking for user data to migrate..."
|
||||||
if [ ! -f "$USERS_FILE" ]; then
|
if [ ! -f "$USERS_FILE" ]; then
|
||||||
@ -127,7 +148,6 @@ EOF
|
|||||||
success "users.json has been migrated and renamed to users.json.migrated."
|
success "users.json has been migrated and renamed to users.json.migrated."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# ========== Install Go and Compile Auth Binary ==========
|
# ========== Install Go and Compile Auth Binary ==========
|
||||||
install_go_and_compile_auth() {
|
install_go_and_compile_auth() {
|
||||||
info "Checking for Go and compiling authentication binary..."
|
info "Checking for Go and compiling authentication binary..."
|
||||||
@ -274,7 +294,6 @@ else
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# ========== Final Check ==========
|
# ========== Final Check ==========
|
||||||
if systemctl is-active --quiet hysteria-server.service; then
|
if systemctl is-active --quiet hysteria-server.service; then
|
||||||
success "🎉 Upgrade completed successfully!"
|
success "🎉 Upgrade completed successfully!"
|
||||||
|
|||||||
Reference in New Issue
Block a user