Refactor: EMQX + Update-Function + Improved NodeJS Crawling (#5907)
This commit is contained in:
parent
3140438b2f
commit
90b6712453
47
ct/emqx.sh
47
ct/emqx.sh
@ -20,18 +20,39 @@ color
|
|||||||
catch_errors
|
catch_errors
|
||||||
|
|
||||||
function update_script() {
|
function update_script() {
|
||||||
header_info
|
header_info
|
||||||
check_container_storage
|
check_container_storage
|
||||||
check_container_resources
|
check_container_resources
|
||||||
if [[ ! -d /var ]]; then
|
|
||||||
msg_error "No ${APP} Installation Found!"
|
RELEASE=$(curl -fsSL https://www.emqx.com/en/downloads/enterprise | grep -oP '/en/downloads/enterprise/v\K[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n1)
|
||||||
exit
|
if [[ "$RELEASE" != "$(cat ~/.emqx 2>/dev/null)" ]] || [[ ! -f ~/.emqx ]]; then
|
||||||
fi
|
msg_info "Stopping EMQX"
|
||||||
msg_info "Updating $APP LXC"
|
systemctl stop emqx
|
||||||
$STD apt-get update
|
msg_ok "Stopped EMQX"
|
||||||
$STD apt-get -y upgrade
|
|
||||||
msg_ok "Updated $APP LXC"
|
msg_info "Downloading EMQX v${RELEASE}"
|
||||||
exit
|
DEB_FILE="/tmp/emqx-enterprise-${RELEASE}-debian12-amd64.deb"
|
||||||
|
curl -fsSL -o "$DEB_FILE" "https://www.emqx.com/en/downloads/enterprise/v${RELEASE}/emqx-enterprise-${RELEASE}-debian12-amd64.deb"
|
||||||
|
msg_ok "Downloaded EMQX"
|
||||||
|
|
||||||
|
msg_info "Installing EMQX"
|
||||||
|
$STD apt-get install -y "$DEB_FILE"
|
||||||
|
msg_ok "Installed EMQX v${RELEASE}"
|
||||||
|
|
||||||
|
msg_info "Starting EMQX"
|
||||||
|
systemctl start emqx
|
||||||
|
echo "$RELEASE" >~/.emqx
|
||||||
|
msg_ok "Started EMQX"
|
||||||
|
|
||||||
|
msg_info "Cleaning Up"
|
||||||
|
rm -f "$DEB_FILE"
|
||||||
|
msg_ok "Cleanup Completed"
|
||||||
|
msg_ok "Update Successful"
|
||||||
|
else
|
||||||
|
msg_ok "No update required. EMQX is already at v${RELEASE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
start
|
start
|
||||||
@ -41,4 +62,4 @@ description
|
|||||||
msg_ok "Completed Successfully!\n"
|
msg_ok "Completed Successfully!\n"
|
||||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:18083${CL}"
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:18083${CL}"
|
||||||
|
2
frontend/public/json/emqx.json
generated
2
frontend/public/json/emqx.json
generated
@ -6,7 +6,7 @@
|
|||||||
],
|
],
|
||||||
"date_created": "2024-05-02",
|
"date_created": "2024-05-02",
|
||||||
"type": "ct",
|
"type": "ct",
|
||||||
"updateable": false,
|
"updateable": true,
|
||||||
"privileged": false,
|
"privileged": false,
|
||||||
"interface_port": 18083,
|
"interface_port": 18083,
|
||||||
"documentation": "https://docs.emqx.com/en/emqx/latest/",
|
"documentation": "https://docs.emqx.com/en/emqx/latest/",
|
||||||
|
@ -14,22 +14,38 @@ network_check
|
|||||||
update_os
|
update_os
|
||||||
|
|
||||||
msg_info "Installing dependencies"
|
msg_info "Installing dependencies"
|
||||||
$STD apt-get install -y \
|
$STD apt-get install -y ca-certificates
|
||||||
apt-transport-https \
|
|
||||||
ca-certificates \
|
|
||||||
lsb-release
|
|
||||||
msg_ok "Installed dependencies"
|
msg_ok "Installed dependencies"
|
||||||
|
|
||||||
|
msg_info "Fetching latest EMQX Enterprise version"
|
||||||
|
LATEST_VERSION=$(curl -fsSL https://www.emqx.com/en/downloads/enterprise | grep -oP '/en/downloads/enterprise/v\K[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n1)
|
||||||
|
if [[ -z "$LATEST_VERSION" ]]; then
|
||||||
|
msg_error "Failed to determine latest EMQX version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
msg_ok "Latest version: v$LATEST_VERSION"
|
||||||
|
|
||||||
|
DOWNLOAD_URL="https://www.emqx.com/en/downloads/enterprise/v$LATEST_VERSION/emqx-enterprise-${LATEST_VERSION}-debian12-amd64.deb"
|
||||||
|
DEB_FILE="/tmp/emqx-enterprise-${LATEST_VERSION}-debian12-amd64.deb"
|
||||||
|
|
||||||
|
msg_info "Downloading EMQX v$LATEST_VERSION"
|
||||||
|
$STD curl -fsSL -o "$DEB_FILE" "$DOWNLOAD_URL"
|
||||||
|
msg_ok "Downloaded EMQX"
|
||||||
|
|
||||||
msg_info "Installing EMQX"
|
msg_info "Installing EMQX"
|
||||||
curl -fsSL https://packagecloud.io/emqx/emqx/gpgkey | gpg --dearmor -o /usr/share/keyrings/emqx-archive-keyring.gpg
|
$STD apt-get install -y "$DEB_FILE"
|
||||||
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/emqx-archive-keyring.gpg] https://packagecloud.io/emqx/emqx/debian/ bookworm main" >/etc/apt/sources.list.d/emqx.list
|
echo "$LATEST_VERSION" >~/.emqx
|
||||||
$STD apt-get install -y emqx
|
|
||||||
msg_ok "Installed EMQX"
|
msg_ok "Installed EMQX"
|
||||||
|
|
||||||
|
msg_info "Starting EMQX service"
|
||||||
|
$STD systemctl enable -q --now emqx
|
||||||
|
msg_ok "Enabled EMQX service"
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
customize
|
customize
|
||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
|
rm -f "$DEB_FILE"
|
||||||
$STD apt-get autoremove
|
$STD apt-get autoremove
|
||||||
$STD apt-get autoclean
|
$STD apt-get autoclean
|
||||||
msg_ok "Cleaned"
|
msg_ok "Cleaned"
|
||||||
|
@ -54,8 +54,24 @@ function setup_nodejs() {
|
|||||||
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_VERSION}.x nodistro main" \
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_VERSION}.x nodistro main" \
|
||||||
>/etc/apt/sources.list.d/nodesource.list
|
>/etc/apt/sources.list.d/nodesource.list
|
||||||
|
|
||||||
|
sleep 2
|
||||||
if ! apt-get update >/dev/null 2>&1; then
|
if ! apt-get update >/dev/null 2>&1; then
|
||||||
msg_error "Failed to update APT repositories after adding NodeSource"
|
msg_warn "APT update failed – retrying in 5s"
|
||||||
|
sleep 5
|
||||||
|
if ! apt-get update >/dev/null 2>&1; then
|
||||||
|
msg_error "Failed to update APT repositories after adding NodeSource"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! apt-cache policy nodejs | grep -q 'Candidate:'; then
|
||||||
|
msg_error "Node.js package not found – repository might be broken or too fresh"
|
||||||
|
apt-cache policy nodejs >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! apt-get install -y nodejs >/dev/null 2>&1; then
|
||||||
|
msg_error "Failed to install Node.js ${NODE_VERSION} from NodeSource"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user