-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: add node 26 support and bump current #1938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Logger Function | ||
| log() { | ||
| local message="$1" | ||
| local type="$2" | ||
| local timestamp=$(date '+%Y-%m-%d %H:%M:%S') | ||
| local color | ||
| local endcolor="\033[0m" | ||
|
|
||
| case "$type" in | ||
| "info") color="\033[38;5;79m" ;; | ||
| "success") color="\033[1;32m" ;; | ||
| "error") color="\033[1;31m" ;; | ||
| *) color="\033[1;34m" ;; | ||
| esac | ||
|
|
||
| echo -e "${color}${timestamp} - ${message}${endcolor}" | ||
| } | ||
|
|
||
| # Error handler function | ||
| handle_error() { | ||
| local exit_code=$1 | ||
| local error_message="$2" | ||
| log "Error: $error_message (Exit Code: $exit_code)" "error" | ||
| exit $exit_code | ||
| } | ||
|
|
||
| # Function to check for command availability | ||
| command_exists() { | ||
| command -v "$1" &> /dev/null | ||
| } | ||
|
|
||
| check_os() { | ||
| if ! [ -f "/etc/debian_version" ]; then | ||
| echo "Error: This script is only supported on Debian-based systems." | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| # Function to Install the script pre-requisites | ||
| install_pre_reqs() { | ||
| log "Installing pre-requisites" "info" | ||
|
|
||
| # Run 'apt update' | ||
| if ! apt update -y; then | ||
| handle_error "$?" "Failed to run 'apt update'" | ||
| fi | ||
|
|
||
| # Run 'apt install' | ||
| if ! apt install -y apt-transport-https ca-certificates curl gnupg; then | ||
| handle_error "$?" "Failed to install packages" | ||
| fi | ||
|
|
||
| if ! mkdir -p /usr/share/keyrings; then | ||
| handle_error "$?" "Makes sure the path /usr/share/keyrings exist or run ' mkdir -p /usr/share/keyrings' with sudo" | ||
| fi | ||
|
|
||
| rm -f /usr/share/keyrings/nodesource.gpg || true | ||
| rm -f /etc/apt/sources.list.d/nodesource.list || true | ||
| rm -f /etc/apt/sources.list.d/nodesource.sources || true | ||
|
|
||
| # Run 'curl' and 'gpg' to download and import the NodeSource signing key | ||
| if ! curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg; then | ||
| handle_error "$?" "Failed to download and import the NodeSource signing key" | ||
| fi | ||
|
|
||
| # Explicitly set the permissions to ensure the file is readable by all | ||
| if ! chmod 644 /usr/share/keyrings/nodesource.gpg; then | ||
| handle_error "$?" "Failed to set correct permissions on /usr/share/keyrings/nodesource.gpg" | ||
| fi | ||
| } | ||
|
|
||
| # Function to configure the Repo | ||
| configure_repo() { | ||
| local node_version=$1 | ||
|
|
||
| arch=$(dpkg --print-architecture) | ||
| if [ "$arch" != "amd64" ] && [ "$arch" != "arm64" ]; then | ||
| handle_error "1" "Unsupported architecture: $arch. Only amd64, arm64 are supported. Contact Nodesource for an extended support version https://nodesource.com/pages/contact-us.html." | ||
| fi | ||
|
|
||
| cat <<EOF | tee /etc/apt/sources.list.d/nodesource.sources > /dev/null | ||
| Types: deb | ||
| URIs: https://deb.nodesource.com/node_$node_version | ||
| Suites: nodistro | ||
| Components: main | ||
| Architectures: $arch | ||
| Signed-By: /usr/share/keyrings/nodesource.gpg | ||
| EOF | ||
|
|
||
| # N|solid Config | ||
| echo "Package: nsolid" | tee /etc/apt/preferences.d/nsolid > /dev/null | ||
| echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nsolid > /dev/null | ||
| echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nsolid > /dev/null | ||
|
|
||
| # Nodejs Config | ||
| echo "Package: nodejs" | tee /etc/apt/preferences.d/nodejs > /dev/null | ||
| echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nodejs > /dev/null | ||
| echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nodejs > /dev/null | ||
|
|
||
| # Run 'apt update' | ||
| if ! apt update -y; then | ||
| handle_error "$?" "Failed to run 'apt update'" | ||
| else | ||
| log "Repository configured successfully." | ||
| log "To install Node.js, run: apt install nodejs -y" "info" | ||
| log "You can use N|solid Runtime as a node.js alternative" "info" | ||
| log "To install N|solid Runtime, run: apt install nsolid -y \n" "success" | ||
| fi | ||
| } | ||
|
|
||
| # Define Node.js version | ||
| NODE_VERSION="26.x" | ||
|
|
||
| # Check OS | ||
| check_os | ||
|
|
||
| # Main execution | ||
| install_pre_reqs || handle_error $? "Failed installing pre-requisites" | ||
| configure_repo "$NODE_VERSION" || handle_error $? "Failed configuring repository" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,7 +111,7 @@ EOF | |
| } | ||
|
|
||
| # Define Node.js version | ||
| NODE_VERSION="25.x" | ||
| NODE_VERSION="26.x" | ||
|
|
||
| # Check OS | ||
| check_os | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Logger Function | ||
| log() { | ||
| local message="$1" | ||
| local type="$2" | ||
| local timestamp=$(date '+%Y-%m-%d %H:%M:%S') | ||
| local color | ||
| local endcolor="\033[0m" | ||
|
|
||
| case "$type" in | ||
| "info") color="\033[38;5;79m" ;; | ||
| "success") color="\033[1;32m" ;; | ||
| "error") color="\033[1;31m" ;; | ||
| *) color="\033[1;34m" ;; | ||
| esac | ||
|
|
||
| echo -e "${color}${timestamp} - ${message}${endcolor}" | ||
| } | ||
|
|
||
| # Error handler function | ||
| handle_error() { | ||
| local exit_code=$1 | ||
| local error_message="$2" | ||
| log "Error: $error_message (Exit Code: $exit_code)" "error" | ||
| exit $exit_code | ||
| } | ||
|
|
||
| # Function to check for command availability | ||
| command_exists() { | ||
| command -v "$1" &> /dev/null | ||
| } | ||
|
|
||
| # Check if we are on an RPM-based system | ||
| if ! [ -f /etc/redhat-release ] && ! grep -q "Amazon Linux" /etc/system-release 2>/dev/null; then | ||
| handle_error 1 "This script is intended for RPM-based systems. Please run it on an RPM-based system." | ||
| fi | ||
|
|
||
| log "Cleaning up old repositories..." "info" | ||
| rm -f /etc/yum.repos.d/nodesource*.repo | ||
| log "Old repositories removed" "info" | ||
|
|
||
| # Define Node.js version | ||
| NODE_VERSION="26.x" | ||
|
|
||
| # Get system architecture | ||
| SYS_ARCH=$(uname -m) | ||
|
|
||
| # Validate system architecture | ||
| case "$SYS_ARCH" in | ||
| aarch64|x86_64) log "Supported architecture: $SYS_ARCH" "info" ;; | ||
| *) handle_error 1 "Unsupported architecture: $SYS_ARCH. Only aarch64 and x86_64 are supported." ;; | ||
| esac | ||
|
|
||
| # Repository content for Node.js | ||
| NODEJS_REPO_CONTENT="[nodesource-nodejs] | ||
| name=Node.js Packages for Linux RPM based distros - $SYS_ARCH | ||
| baseurl=https://rpm.nodesource.com/pub_${NODE_VERSION}/nodistro/nodejs/$SYS_ARCH | ||
| priority=9 | ||
| enabled=1 | ||
| gpgcheck=1 | ||
| gpgkey=https://rpm.nodesource.com/gpgkey/ns-operations-public.key | ||
| module_hotfixes=1" | ||
|
|
||
| # Write Node.js repository content | ||
| echo "$NODEJS_REPO_CONTENT" | tee /etc/yum.repos.d/nodesource-nodejs.repo > /dev/null | ||
|
|
||
| # Check if Node.js version is an LTS version | ||
| if [[ "$NODE_VERSION" == "20.x" ]] || [[ "$NODE_VERSION" == "22.x" ]] || [[ "$NODE_VERSION" == "24.x" ]]; then | ||
| # Repository content for N|Solid | ||
| NSOLID_REPO_CONTENT="[nodesource-nsolid] | ||
| name=N|Solid Packages for Linux RPM based distros - $SYS_ARCH | ||
| baseurl=https://rpm.nodesource.com/pub_${NODE_VERSION}/nodistro/nsolid/$SYS_ARCH | ||
| priority=9 | ||
| enabled=1 | ||
| gpgcheck=1 | ||
| gpgkey=https://rpm.nodesource.com/gpgkey/ns-operations-public.key | ||
| module_hotfixes=1" | ||
|
|
||
| # Write N|Solid repository content | ||
| echo "$NSOLID_REPO_CONTENT" | tee /etc/yum.repos.d/nodesource-nsolid.repo > /dev/null | ||
| log "Added N|Solid repository for LTS version: $NODE_VERSION" "info" | ||
| fi | ||
|
|
||
| # Check for availability of dnf, yum or microdnf | ||
| if command_exists dnf; then | ||
| log "dnf available, updating..." "info" | ||
| dnf makecache --disablerepo="*" --enablerepo="nodesource-nodejs" | ||
|
|
||
| # Update N|Solid repository if it's LTS | ||
| if [[ "$NODE_VERSION" == "20.x" ]] || [[ "$NODE_VERSION" == "22.x" ]] || [[ "$NODE_VERSION" == "24.x" ]]; then | ||
| dnf makecache --disablerepo="*" --enablerepo="nodesource-nsolid" | ||
| log "Repository is configured and updated." "info" | ||
| log "You can use N|solid Runtime as a node.js alternative" "info" | ||
| log "To install N|solid Runtime, run: dnf install nsolid -y" "success" | ||
| else | ||
| log "Repository is configured and updated." "info" | ||
| fi | ||
|
|
||
| log "Run 'dnf install nodejs -y' to complete the installation." "info" | ||
| exit 0 | ||
| elif command_exists yum; then | ||
| log "yum available, updating..." "info" | ||
| yum makecache --disablerepo="*" --enablerepo="nodesource-nodejs" | ||
|
|
||
| # Update N|Solid repository if it's LTS | ||
| if [[ "$NODE_VERSION" == "20.x" ]] || [[ "$NODE_VERSION" == "22.x" ]] || [[ "$NODE_VERSION" == "24.x" ]]; then | ||
| yum makecache --disablerepo="*" --enablerepo="nodesource-nsolid" | ||
| log "Repository is configured and updated." "info" | ||
| log "You can use N|solid Runtime as a node.js alternative" "info" | ||
| log "Run 'yum install nsolid -y' to complete the installation." "success" | ||
| else | ||
| log "Repository is configured and updated." "info" | ||
| fi | ||
|
|
||
| log "Run 'yum install nodejs -y' to complete the installation." "info" | ||
| elif command_exists microdnf; then | ||
| log "microdnf available, updating..." "info" | ||
| microdnf makecache --disablerepo="*" --enablerepo="nodesource-nodejs" | ||
|
|
||
| # Update N|Solid repository if it's LTS | ||
| if [[ "$NODE_VERSION" == "20.x" ]] || [[ "$NODE_VERSION" == "22.x" ]] || [[ "$NODE_VERSION" == "24.x" ]]; then | ||
| microdnf makecache --disablerepo="*" --enablerepo="nodesource-nsolid" | ||
| log "Repository is configured and updated. Run 'microdnf install nsolid -y' to complete the installation." "info" | ||
| else | ||
| log "Repository is configured and updated." "info" | ||
| fi | ||
|
|
||
| log "Run 'microdnf install nodejs -y' to complete the installation." "info" | ||
| else | ||
| handle_error 1 "Neither yum, dnf nor microdnf package manager was found. Please update your system using your package manager." | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.