Put in check and alternative to install older Mongo for CPUs that can't support AVX

This commit is contained in:
Colin Oppenheim 2024-11-17 13:43:30 -08:00
parent 61d2e0d599
commit 02e1ff561e
3 changed files with 63 additions and 11 deletions

View File

@ -16,11 +16,40 @@ cat <<"EOF"
EOF
}
function run_avx_check {
if grep -q 'avx' /proc/cpuinfo; then
echo "AVX is supported. Proceeding with LXC setup."
else
echo "AVX instructions supported on this CPU. Would you like to explore alternatives?"
read -p "(y/n): " avx_response
if [[ "$avx_response" =~ ^[Yy]$ ]]; then
handle_avx_alternatives
else
echo "Exiting setup due to lack of AVX support."
exit 1
fi
fi
}
function handle_avx_alternatives {
echo "Choose an alternative installation method:"
echo "1) Install MongoDB 4.2 on LXC container"
echo "2) Install UniFi on Debian 12 VM (Coming Soon!)"
read -p "Enter your choice (1): " alt_choice
if [[ "$alt_choice" == "1" ]]; then
echo "Proceeding with MongoDB 4.2 installation on LXC..."
# Set a flag for the installer script
export MONGO_VERSION="4.2"
else
echo "Invalid choice. Only option 1 is currently available."
echo "VM installation option coming soon!"
exit 1
fi
}
header_info
if ! grep -q -m1 'avx[^ ]*' /proc/cpuinfo; then
echo "AVX instruction set is not supported on this CPU."
exit
fi
run_avx_check
echo -e "Loading..."
APP="Unifi"
var_disk="8"
@ -72,4 +101,4 @@ description
msg_ok "Completed Successfully!\n"
echo -e "${APP}${CL} should be reachable by going to the following URL.
${BL}https://${IP}:8443${CL} \n"
${BL}https://${IP}:8443${CL} \n"

View File

@ -29,10 +29,29 @@ $STD apt-get install -y temurin-17-jre
msg_ok "Installed Eclipse Temurin JRE"
msg_info "Installing MongoDB"
wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor >/usr/share/keyrings/mongodb-server-7.0.gpg
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] http://repo.mongodb.org/apt/debian bookworm/mongodb-org/7.0 main" >/etc/apt/sources.list.d/mongodb-org-7.0.list
$STD apt-get update
$STD apt-get install -y mongodb-org
if [ "$MONGO_VERSION" = "4.2" ]; then
# Check for libssl1.1 and install if missing
if ! dpkg -l | grep -q "libssl1.1"; then
msg_info "libssl1.1 not found. Installing..."
wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.1_1.1.1n-0+deb10u6_amd64.deb
dpkg -i libssl1.1_1.1.1n-0+deb10u6_amd64.deb
apt-get install -f -y # Fix any broken dependencies
msg_ok "Installed libssl1.1"
else
msg_ok "libssl1.1 already installed"
fi
# Proceed with MongoDB 4.2 installation
wget -qO- https://www.mongodb.org/static/pgp/server-4.2.asc | gpg --dearmor > /usr/share/keyrings/mongodb-server-4.2.gpg
echo "deb [signed-by=/usr/share/keyrings/mongodb-server-4.2.gpg] https://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" >/etc/apt/sources.list.d/mongodb-org-4.2.list
$STD apt-get update
$STD apt-get install -y mongodb-org=4.2.17
else
# Default to MongoDB 7.0 installation
wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor >/usr/share/keyrings/mongodb-server-7.0.gpg
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] http://repo.mongodb.org/apt/debian bookworm/mongodb-org/7.0 main" >/etc/apt/sources.list.d/mongodb-org-7.0.list
$STD apt-get update
$STD apt-get install -y mongodb-org
fi
msg_ok "Installed MongoDB"
msg_info "Installing UniFi Network Server"

View File

@ -32,8 +32,12 @@
},
"notes": [
{
"text": "CPU with AVX Instruction Set required",
"type": "warning"
"text": "CPU with AVX Instruction Set recommended",
"type": "note"
},
{
"text": "For non-AVX CPUs, an alternative installation using MongoDB 4.2 is available. Please note this is a legacy solution that may present security risks and could become unsupported in future updates.",
"type": "attention"
}
]
}