Update install.sh (#3464)

This commit is contained in:
Louis Lam 2023-07-21 16:09:35 +08:00 committed by GitHub
parent 1d9a28e9ab
commit 9058a829a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 104 additions and 51 deletions

View File

@ -5,15 +5,15 @@
// curl -o kuma_install.sh https://raw.githubusercontent.com/louislam/uptime-kuma/master/install.sh && sudo bash kuma_install.sh // curl -o kuma_install.sh https://raw.githubusercontent.com/louislam/uptime-kuma/master/install.sh && sudo bash kuma_install.sh
println("====================="); println("=====================");
println("Uptime Kuma Installer"); println("Uptime Kuma Install Script");
println("====================="); println("=====================");
println("Supported OS: CentOS 7/8, Ubuntu >= 16.04 and Debian"); println("Supported OS: Ubuntu >= 16.04, Debian and CentOS/RHEL 7/8");
println("---------------------------------------"); println("---------------------------------------");
println("This script is designed for Linux and basic usage."); println("This script is designed for Linux and basic usage.");
println("For advanced usage, please go to https://github.com/louislam/uptime-kuma/wiki/Installation"); println("For advanced usage, please go to https://github.com/louislam/uptime-kuma/wiki/Installation");
println("---------------------------------------"); println("---------------------------------------");
println(""); println("");
println("Local - Install Uptime Kuma in your current machine with git, Node.js 14 and pm2"); println("Local - Install Uptime Kuma on your current machine with git, Node.js and pm2");
println("Docker - Install Uptime Kuma Docker container"); println("Docker - Install Uptime Kuma Docker container");
println(""); println("");
@ -29,14 +29,10 @@ function checkNode() {
bash("nodeVersion=$(node -e 'console.log(process.versions.node.split(`.`)[0])')"); bash("nodeVersion=$(node -e 'console.log(process.versions.node.split(`.`)[0])')");
println("Node Version: " ++ nodeVersion); println("Node Version: " ++ nodeVersion);
if (nodeVersion < "12") { if (nodeVersion <= "12") {
println("Error: Required Node.js 14"); println("Error: Required Node.js 14");
call("exit", "1"); call("exit", "1");
} }
if (nodeVersion == "12") {
println("Warning: NodeJS " ++ nodeVersion ++ " is not tested.");
}
} }
function deb() { function deb() {
@ -60,8 +56,8 @@ function deb() {
bash("apt --yes install curl"); bash("apt --yes install curl");
} }
println("Installing Node.js 14"); println("Installing Node.js 16");
bash("curl -sL https://deb.nodesource.com/setup_14.x | bash - > log.txt"); bash("curl -sL https://deb.nodesource.com/setup_16.x | bash - > log.txt");
bash("apt --yes install nodejs"); bash("apt --yes install nodejs");
bash("node -v"); bash("node -v");
@ -91,6 +87,10 @@ if (type == "local") {
bash("os=$(head -n1 /etc/issue | cut -f 1 -d ' ')"); bash("os=$(head -n1 /etc/issue | cut -f 1 -d ' ')");
if (os == "Ubuntu") { if (os == "Ubuntu") {
distribution = "ubuntu"; distribution = "ubuntu";
// Get ubuntu version
bash(". /etc/lsb-release");
version = DISTRIB_RELEASE;
} }
if (os == "Debian") { if (os == "Debian") {
distribution = "debian"; distribution = "debian";
@ -101,6 +101,7 @@ if (type == "local") {
println("Your OS: " ++ os); println("Your OS: " ++ os);
println("Distribution: " ++ distribution); println("Distribution: " ++ distribution);
println("Version: " ++ version);
println("Arch: " ++ arch); println("Arch: " ++ arch);
if ("$3" != "") { if ("$3" != "") {
@ -131,15 +132,32 @@ if (type == "local") {
checkNode(); checkNode();
} else { } else {
bash("dnfCheck=$(dnf --version)");
// Use yum
if (dnfCheck == "") {
bash("curlCheck=$(curl --version)"); bash("curlCheck=$(curl --version)");
if (curlCheck == "") { if (curlCheck == "") {
println("Installing Curl"); println("Installing Curl");
bash("yum -y -q install curl"); bash("yum -y -q install curl");
} }
println("Installing Node.js 14"); println("Installing Node.js 16");
bash("curl -sL https://rpm.nodesource.com/setup_14.x | bash - > log.txt"); bash("curl -sL https://rpm.nodesource.com/setup_16.x | bash - > log.txt");
bash("yum install -y -q nodejs"); bash("yum install -y -q nodejs");
} else {
bash("curlCheck=$(curl --version)");
if (curlCheck == "") {
println("Installing Curl");
bash("dnf -y install curl");
}
println("Installing Node.js 16");
bash("curl -sL https://rpm.nodesource.com/setup_16.x | bash - > log.txt");
bash("dnf install -y nodejs");
}
bash("node -v"); bash("node -v");
bash("nodeCheckAgain=$(node -v)"); bash("nodeCheckAgain=$(node -v)");
@ -193,6 +211,14 @@ if (type == "local") {
bash("pm2 startup"); bash("pm2 startup");
} }
// Check again
bash("check=$(pm2 --version)");
if (check == "") {
println("Error: pm2 is not found!");
bash("exit 1");
}
bash("mkdir -p $installPath"); bash("mkdir -p $installPath");
bash("cd $installPath"); bash("cd $installPath");
bash("git clone https://github.com/louislam/uptime-kuma.git ."); bash("git clone https://github.com/louislam/uptime-kuma.git .");

View File

@ -3,15 +3,15 @@
# The command is working on Windows PowerShell and Docker for Windows only. # The command is working on Windows PowerShell and Docker for Windows only.
# curl -o kuma_install.sh https://raw.githubusercontent.com/louislam/uptime-kuma/master/install.sh && sudo bash kuma_install.sh # curl -o kuma_install.sh https://raw.githubusercontent.com/louislam/uptime-kuma/master/install.sh && sudo bash kuma_install.sh
"echo" "-e" "=====================" "echo" "-e" "====================="
"echo" "-e" "Uptime Kuma Installer" "echo" "-e" "Uptime Kuma Install Script"
"echo" "-e" "=====================" "echo" "-e" "====================="
"echo" "-e" "Supported OS: CentOS 7/8, Ubuntu >= 16.04 and Debian" "echo" "-e" "Supported OS: Ubuntu >= 16.04, Debian and CentOS/RHEL 7/8"
"echo" "-e" "---------------------------------------" "echo" "-e" "---------------------------------------"
"echo" "-e" "This script is designed for Linux and basic usage." "echo" "-e" "This script is designed for Linux and basic usage."
"echo" "-e" "For advanced usage, please go to https://github.com/louislam/uptime-kuma/wiki/Installation" "echo" "-e" "For advanced usage, please go to https://github.com/louislam/uptime-kuma/wiki/Installation"
"echo" "-e" "---------------------------------------" "echo" "-e" "---------------------------------------"
"echo" "-e" "" "echo" "-e" ""
"echo" "-e" "Local - Install Uptime Kuma in your current machine with git, Node.js 14 and pm2" "echo" "-e" "Local - Install Uptime Kuma on your current machine with git, Node.js and pm2"
"echo" "-e" "Docker - Install Uptime Kuma Docker container" "echo" "-e" "Docker - Install Uptime Kuma Docker container"
"echo" "-e" "" "echo" "-e" ""
if [ "$1" != "" ]; then if [ "$1" != "" ]; then
@ -25,12 +25,9 @@ function checkNode {
nodeVersion=$(node -e 'console.log(process.versions.node.split(`.`)[0])') nodeVersion=$(node -e 'console.log(process.versions.node.split(`.`)[0])')
"echo" "-e" "Node Version: ""$nodeVersion" "echo" "-e" "Node Version: ""$nodeVersion"
_0="12" _0="12"
if [ $(($nodeVersion < $_0)) == 1 ]; then if [ $(($nodeVersion <= $_0)) == 1 ]; then
"echo" "-e" "Error: Required Node.js 14" "echo" "-e" "Error: Required Node.js 14"
"exit" "1" "exit" "1"
fi
if [ "$nodeVersion" == "12" ]; then
"echo" "-e" "Warning: NodeJS ""$nodeVersion"" is not tested."
fi fi
} }
function deb { function deb {
@ -50,8 +47,8 @@ fi
"echo" "-e" "Installing Curl" "echo" "-e" "Installing Curl"
apt --yes install curl apt --yes install curl
fi fi
"echo" "-e" "Installing Node.js 14" "echo" "-e" "Installing Node.js 16"
curl -sL https://deb.nodesource.com/setup_14.x | bash - > log.txt curl -sL https://deb.nodesource.com/setup_16.x | bash - > log.txt
apt --yes install nodejs apt --yes install nodejs
node -v node -v
nodeCheckAgain=$(node -v) nodeCheckAgain=$(node -v)
@ -76,6 +73,9 @@ if [ "$type" == "local" ]; then
os=$(head -n1 /etc/issue | cut -f 1 -d ' ') os=$(head -n1 /etc/issue | cut -f 1 -d ' ')
if [ "$os" == "Ubuntu" ]; then if [ "$os" == "Ubuntu" ]; then
distribution="ubuntu" distribution="ubuntu"
# Get ubuntu version
. /etc/lsb-release
version="$DISTRIB_RELEASE"
fi fi
if [ "$os" == "Debian" ]; then if [ "$os" == "Debian" ]; then
distribution="debian" distribution="debian"
@ -85,6 +85,7 @@ fi
arch=$(uname -i) arch=$(uname -i)
"echo" "-e" "Your OS: ""$os" "echo" "-e" "Your OS: ""$os"
"echo" "-e" "Distribution: ""$distribution" "echo" "-e" "Distribution: ""$distribution"
"echo" "-e" "Version: ""$version"
"echo" "-e" "Arch: ""$arch" "echo" "-e" "Arch: ""$arch"
if [ "$3" != "" ]; then if [ "$3" != "" ]; then
port="$3" port="$3"
@ -108,14 +109,27 @@ fi
if [ "$nodeCheck" != "" ]; then if [ "$nodeCheck" != "" ]; then
"checkNode" "checkNode"
else else
dnfCheck=$(dnf --version)
# Use yum
if [ "$dnfCheck" == "" ]; then
curlCheck=$(curl --version) curlCheck=$(curl --version)
if [ "$curlCheck" == "" ]; then if [ "$curlCheck" == "" ]; then
"echo" "-e" "Installing Curl" "echo" "-e" "Installing Curl"
yum -y -q install curl yum -y -q install curl
fi fi
"echo" "-e" "Installing Node.js 14" "echo" "-e" "Installing Node.js 16"
curl -sL https://rpm.nodesource.com/setup_14.x | bash - > log.txt curl -sL https://rpm.nodesource.com/setup_16.x | bash - > log.txt
yum install -y -q nodejs yum install -y -q nodejs
else
curlCheck=$(curl --version)
if [ "$curlCheck" == "" ]; then
"echo" "-e" "Installing Curl"
dnf -y install curl
fi
"echo" "-e" "Installing Node.js 16"
curl -sL https://rpm.nodesource.com/setup_16.x | bash - > log.txt
dnf install -y nodejs
fi
node -v node -v
nodeCheckAgain=$(node -v) nodeCheckAgain=$(node -v)
if [ "$nodeCheckAgain" == "" ]; then if [ "$nodeCheckAgain" == "" ]; then
@ -161,6 +175,12 @@ fi
"echo" "-e" "Installing PM2" "echo" "-e" "Installing PM2"
npm install pm2 -g && pm2 install pm2-logrotate npm install pm2 -g && pm2 install pm2-logrotate
pm2 startup pm2 startup
fi
# Check again
check=$(pm2 --version)
if [ "$check" == "" ]; then
"echo" "-e" "Error: pm2 is not found!"
exit 1
fi fi
mkdir -p $installPath mkdir -p $installPath
cd $installPath cd $installPath

View File

@ -46,11 +46,14 @@
"reset-password": "node extra/reset-password.js", "reset-password": "node extra/reset-password.js",
"remove-2fa": "node extra/remove-2fa.js", "remove-2fa": "node extra/remove-2fa.js",
"compile-install-script": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./extra/compile-install-script.ps1", "compile-install-script": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./extra/compile-install-script.ps1",
"test-install-script-rockylinux": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/rockylinux.dockerfile .",
"test-install-script-centos7": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/centos7.dockerfile .", "test-install-script-centos7": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/centos7.dockerfile .",
"test-install-script-alpine3": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/alpine3.dockerfile .", "test-install-script-alpine3": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/alpine3.dockerfile .",
"test-install-script-debian": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/debian.dockerfile .",
"test-install-script-debian-buster": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/debian-buster.dockerfile .",
"test-install-script-ubuntu": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/ubuntu.dockerfile .", "test-install-script-ubuntu": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/ubuntu.dockerfile .",
"test-install-script-ubuntu1804": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/ubuntu1804.dockerfile .",
"test-install-script-ubuntu1604": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/ubuntu1604.dockerfile .", "test-install-script-ubuntu1604": "npm run compile-install-script && docker build --progress plain -f test/test_install_script/ubuntu1604.dockerfile .",
"test-nodejs16": "docker build --progress plain -f test/ubuntu-nodejs16.dockerfile .",
"simple-dns-server": "node extra/simple-dns-server.js", "simple-dns-server": "node extra/simple-dns-server.js",
"simple-mqtt-server": "node extra/simple-mqtt-server.js", "simple-mqtt-server": "node extra/simple-mqtt-server.js",
"update-language-files": "cd extra/update-language-files && node index.js && cross-env-shell eslint ../../src/languages/$npm_config_language.js --fix", "update-language-files": "cd extra/update-language-files && node index.js && cross-env-shell eslint ../../src/languages/$npm_config_language.js --fix",

View File

@ -0,0 +1,10 @@
FROM debian:buster-slim
# Test invalid node version, these commands install nodejs 10
# RUN apt-get update
# RUN apt --yes install nodejs
# RUN ln -s /usr/bin/nodejs /usr/bin/node
# RUN node -v
COPY ./install.sh .
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0

View File

@ -1,4 +1,4 @@
FROM debian FROM debian:bookworm-slim
# Test invalid node version, these commands install nodejs 10 # Test invalid node version, these commands install nodejs 10
# RUN apt-get update # RUN apt-get update

View File

@ -1,4 +1,4 @@
FROM centos:8 FROM rockylinux:9
COPY ./install.sh . COPY ./install.sh .
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0 RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0

View File

@ -6,4 +6,5 @@ FROM ubuntu
# RUN ln -s /usr/bin/nodejs /usr/bin/node # RUN ln -s /usr/bin/nodejs /usr/bin/node
# RUN node -v # RUN node -v
RUN curl -o kuma_install.sh http://git.kuma.pet/install.sh && bash kuma_install.sh local /opt/uptime-kuma 3000 0.0.0.0 COPY ./install.sh .
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0

View File

@ -1,10 +1,9 @@
FROM ubuntu:16.04 FROM ubuntu:16.04
RUN apt-get update
RUN apt --yes install curl
# Test invalid node version, these commands install nodejs 10 # Test invalid node version, these commands install nodejs 10
#RUN apt --yes install nodejs #RUN apt --yes install nodejs
# RUN ln -s /usr/bin/nodejs /usr/bin/node # RUN ln -s /usr/bin/nodejs /usr/bin/node
# RUN node -v # RUN node -v
RUN curl -o kuma_install.sh http://git.kuma.pet/install.sh && bash kuma_install.sh local /opt/uptime-kuma 3000 0.0.0.0 COPY ./install.sh .
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0

View File

@ -0,0 +1,4 @@
FROM ubuntu:18.04
COPY ./install.sh .
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0

View File

@ -1,10 +0,0 @@
FROM ubuntu
WORKDIR /app
RUN apt update && apt --yes install git curl
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
RUN apt --yes install nodejs
RUN git clone https://github.com/louislam/uptime-kuma.git .
RUN npm run setup
# Option 1. Try it
RUN node server/server.js