Skip to content

Commit 02e1ff5

Browse files
committed
Put in check and alternative to install older Mongo for CPUs that can't support AVX
1 parent 61d2e0d commit 02e1ff5

File tree

3 files changed

+63
-11
lines changed

3 files changed

+63
-11
lines changed

ct/unifi.sh

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,40 @@ cat <<"EOF"
1616
1717
EOF
1818
}
19+
20+
function run_avx_check {
21+
if grep -q 'avx' /proc/cpuinfo; then
22+
echo "AVX is supported. Proceeding with LXC setup."
23+
else
24+
echo "AVX instructions supported on this CPU. Would you like to explore alternatives?"
25+
read -p "(y/n): " avx_response
26+
if [[ "$avx_response" =~ ^[Yy]$ ]]; then
27+
handle_avx_alternatives
28+
else
29+
echo "Exiting setup due to lack of AVX support."
30+
exit 1
31+
fi
32+
fi
33+
}
34+
35+
function handle_avx_alternatives {
36+
echo "Choose an alternative installation method:"
37+
echo "1) Install MongoDB 4.2 on LXC container"
38+
echo "2) Install UniFi on Debian 12 VM (Coming Soon!)"
39+
read -p "Enter your choice (1): " alt_choice
40+
if [[ "$alt_choice" == "1" ]]; then
41+
echo "Proceeding with MongoDB 4.2 installation on LXC..."
42+
# Set a flag for the installer script
43+
export MONGO_VERSION="4.2"
44+
else
45+
echo "Invalid choice. Only option 1 is currently available."
46+
echo "VM installation option coming soon!"
47+
exit 1
48+
fi
49+
}
50+
1951
header_info
20-
if ! grep -q -m1 'avx[^ ]*' /proc/cpuinfo; then
21-
echo "AVX instruction set is not supported on this CPU."
22-
exit
23-
fi
52+
run_avx_check
2453
echo -e "Loading..."
2554
APP="Unifi"
2655
var_disk="8"
@@ -72,4 +101,4 @@ description
72101

73102
msg_ok "Completed Successfully!\n"
74103
echo -e "${APP}${CL} should be reachable by going to the following URL.
75-
${BL}https://${IP}:8443${CL} \n"
104+
${BL}https://${IP}:8443${CL} \n"

install/unifi-install.sh

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,29 @@ $STD apt-get install -y temurin-17-jre
2929
msg_ok "Installed Eclipse Temurin JRE"
3030

3131
msg_info "Installing MongoDB"
32-
wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor >/usr/share/keyrings/mongodb-server-7.0.gpg
33-
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
34-
$STD apt-get update
35-
$STD apt-get install -y mongodb-org
32+
if [ "$MONGO_VERSION" = "4.2" ]; then
33+
# Check for libssl1.1 and install if missing
34+
if ! dpkg -l | grep -q "libssl1.1"; then
35+
msg_info "libssl1.1 not found. Installing..."
36+
wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.1_1.1.1n-0+deb10u6_amd64.deb
37+
dpkg -i libssl1.1_1.1.1n-0+deb10u6_amd64.deb
38+
apt-get install -f -y # Fix any broken dependencies
39+
msg_ok "Installed libssl1.1"
40+
else
41+
msg_ok "libssl1.1 already installed"
42+
fi
43+
# Proceed with MongoDB 4.2 installation
44+
wget -qO- https://www.mongodb.org/static/pgp/server-4.2.asc | gpg --dearmor > /usr/share/keyrings/mongodb-server-4.2.gpg
45+
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
46+
$STD apt-get update
47+
$STD apt-get install -y mongodb-org=4.2.17
48+
else
49+
# Default to MongoDB 7.0 installation
50+
wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | gpg --dearmor >/usr/share/keyrings/mongodb-server-7.0.gpg
51+
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
52+
$STD apt-get update
53+
$STD apt-get install -y mongodb-org
54+
fi
3655
msg_ok "Installed MongoDB"
3756

3857
msg_info "Installing UniFi Network Server"

json/unifi.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@
3232
},
3333
"notes": [
3434
{
35-
"text": "CPU with AVX Instruction Set required",
36-
"type": "warning"
35+
"text": "CPU with AVX Instruction Set recommended",
36+
"type": "note"
37+
},
38+
{
39+
"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.",
40+
"type": "attention"
3741
}
3842
]
3943
}

0 commit comments

Comments
 (0)