-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add installation scripts
- Loading branch information
Showing
4 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,84 @@ | ||
name: 'Test Installation Scripts' | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deb: | ||
name: "NodeJS ${{ matrix.version }}(${{ matrix.os }})" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
version: [18, 20, 21] | ||
os: ["ubuntu:22.04", "debian:10"] | ||
container: | ||
image: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
shell: bash | ||
steps: | ||
- name: Update and Install Dependencies | ||
run: | | ||
apt-get update -y | ||
apt-get install curl git -y | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run Istallation Script | ||
run: ./scripts/nsolid_setup_deb.sh ${{ matrix.version }} | ||
|
||
- name: Install Nodejs | ||
run: | | ||
apt-get install nodejs -y | ||
- name: Validate Node Version | ||
run: | | ||
node -e "console.log(process.version)" | ||
NODE_VERSION=$(node -e "console.log((process.version).split('.')[0])") | ||
if [[ ${NODE_VERSION} != "v${{ matrix.version }}" ]]; then | ||
echo "Node version is not ${{ matrix.version }}. It is $NODE_VERSION" | ||
exit 1 | ||
fi | ||
rpm: | ||
name: "NodeJS ${{ matrix.version }}(${{ matrix.os }})" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
version: [18, 20, 21] | ||
os: ["fedora:36", "amazonlinux:2023"] | ||
container: | ||
image: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
shell: bash | ||
steps: | ||
- name: Update and Install Dependencies | ||
run: | | ||
yum update -y | ||
yum install git -y | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run Istallation Script | ||
run: ./scripts/nsolid_setup_rpm.sh ${{ matrix.version }} | ||
|
||
- name: Install Nodejs | ||
run: | | ||
yum install nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1 | ||
- name: Validate Node Version | ||
run: | | ||
node -e "console.log(process.version)" | ||
NODE_VERSION=$(node -e "console.log((process.version).split('.')[0])") | ||
if [[ ${NODE_VERSION} != "v${{ matrix.version }}" ]]; then | ||
echo "Node version is not ${{ matrix.version }}. It is $NODE_VERSION" | ||
exit 1 | ||
fi |
This file contains 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 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,109 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
NSOLID_VERSION=$1 | ||
|
||
################################ | ||
## Logger Function ## | ||
################################ | ||
logger() { | ||
local message="$1" | ||
local type="$2" | ||
local length=${#message} | ||
local line=$(printf "%-${length}s" | tr ' ' '-') | ||
echo "" | ||
case "$type" in | ||
"info") | ||
echo "\033[38;5;79m$line\033[0m" | ||
echo "\033[38;5;79m$message\033[0m" | ||
echo "\033[38;5;79m$line\033[0m" | ||
;; | ||
"success") | ||
echo "\033[1;32m$line\033[0m" | ||
echo "\033[1;32m$message\033[0m" | ||
echo "\033[1;32m$line\033[0m" | ||
;; | ||
"error") | ||
echo "\033[1;31m$line\033[0m" | ||
echo "\033[1;31m$message\033[0m" | ||
echo "\033[1;31m$line\033[0m" | ||
;; | ||
*) | ||
echo "\033[1;34m$line\033[0m" | ||
echo "\033[1;34m$message\033[0m" | ||
echo "\033[1;34m$line\033[0m" | ||
;; | ||
esac | ||
echo "" | ||
} | ||
|
||
|
||
################################ | ||
## Error handler function ## | ||
################################ | ||
handleError() { | ||
local exit_code=$1 | ||
local error_message="$2" | ||
logger "Error: $error_message (Exit Code: $exit_code)" "error" | ||
exit $exit_code | ||
} | ||
|
||
################################ | ||
##Function to validate version## | ||
################################ | ||
getVersion() { | ||
local NSOLID_VERSION=$1 | ||
regex='^[0-9][0-9]$' | ||
if ! expr "$NSOLID_VERSION" : "$regex" > /dev/null; then | ||
return 1 | ||
fi | ||
logger "Info: Configuring repository for N|solid $NSOLID_VERSION" "info" | ||
} | ||
|
||
################################################# | ||
##Function to Install the script pre-requisites## | ||
################################################# | ||
installPreReqs() { | ||
logger "Info: Installing pre-requisites" "info" | ||
|
||
# Run 'apt-get update' | ||
if ! apt-get update -y; then | ||
handleError "$?" "Failed to run 'apt-get update'" | ||
fi | ||
|
||
# Run 'apt-get install' | ||
if ! apt-get install -y ca-certificates curl gnupg; then | ||
handleError "$?" "Failed to install packages" | ||
fi | ||
|
||
mkdir -p /usr/share/keyrings | ||
|
||
# Run 'curl' and 'gpg' | ||
if ! curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg; then | ||
handleError "$?" "Failed to download and import the NodeSource signing key" | ||
fi | ||
} | ||
|
||
################################## | ||
##Function to configure the Repo## | ||
################################## | ||
configureRepo() { | ||
local NSOLID_VERSION=$1 | ||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NSOLID_VERSION.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list | ||
# N|solid Config | ||
echo "Package: nsolid" > /etc/apt/preferences.d/nsolid | ||
echo "Pin: origin deb.nodesource.com" >> /etc/apt/preferences.d/nsolid | ||
echo "Pin-Priority: 600" >> /etc/apt/preferences.d/nsolid | ||
# Nodejs Config | ||
echo "Package: nodejs" > /etc/apt/preferences.d/nodejs | ||
echo "Pin: origin deb.nodesource.com" >> /etc/apt/preferences.d/nodejs | ||
echo "Pin-Priority: 600" >> /etc/apt/preferences.d/nodejs | ||
# Run 'apt-get update' | ||
if ! apt-get update -y; then | ||
handleError "$?" "Failed to run 'apt-get update'" | ||
fi | ||
} | ||
|
||
getVersion $NSOLID_VERSION || handleError $? "Must define a valid N|solid version" | ||
installPreReqs || handleError $? "Failed installing pre-requisites" | ||
configureRepo $NSOLID_VERSION || handleError $? "Failed configuring repository" |
This file contains 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,75 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
NSOLID_VERSION=$1 | ||
|
||
################################ | ||
## Logger Function ## | ||
################################ | ||
logger() { | ||
local message="$1" | ||
local type="$2" | ||
local length=${#message} | ||
local line=$(printf "%-${length}s" | tr ' ' '-') | ||
echo "" | ||
case "$type" in | ||
"info") | ||
echo "\033[38;5;79m$line\033[0m" | ||
echo "\033[38;5;79m$message\033[0m" | ||
echo "\033[38;5;79m$line\033[0m" | ||
;; | ||
"success") | ||
echo "\033[1;32m$line\033[0m" | ||
echo "\033[1;32m$message\033[0m" | ||
echo "\033[1;32m$line\033[0m" | ||
;; | ||
"error") | ||
echo "\033[1;31m$line\033[0m" | ||
echo "\033[1;31m$message\033[0m" | ||
echo "\033[1;31m$line\033[0m" | ||
;; | ||
*) | ||
echo "\033[1;34m$line\033[0m" | ||
echo "\033[1;34m$message\033[0m" | ||
echo "\033[1;34m$line\033[0m" | ||
;; | ||
esac | ||
echo "" | ||
} | ||
|
||
|
||
################################ | ||
## Error handler function ## | ||
################################ | ||
handleError() { | ||
local exit_code=$1 | ||
local error_message="$2" | ||
logger "Error: $error_message (Exit Code: $exit_code)" "error" | ||
exit $exit_code | ||
} | ||
|
||
################################ | ||
##Function to validate version## | ||
################################ | ||
getVersion() { | ||
local NSOLID_VERSION=$1 | ||
regex='^[0-9][0-9]$' | ||
if ! expr "$NSOLID_VERSION" : "$regex" > /dev/null; then | ||
return 1 | ||
fi | ||
logger "Info: Configuring repository for N|solid $NSOLID_VERSION" "info" | ||
} | ||
|
||
################################## | ||
##Function to configure the Repo## | ||
################################## | ||
configureRepo() { | ||
local NSOLID_VERSION=$1 | ||
# Run 'yum install' | ||
if ! yum install https://rpm.nodesource.com/pub_$NSOLID_VERSION.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y; then | ||
handleError "$?" "Failed to run yum install https://rpm.nodesource.com/pub_$NSOLID_VERSION.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y" | ||
fi | ||
} | ||
|
||
getVersion $NSOLID_VERSION || handleError $? "Must define a valid N|solid version" | ||
configureRepo $NSOLID_VERSION || handleError $? "Failed configuring repository" |
4f746d9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A
4f746d9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LL