|
|
|
@ -1,9 +1,13 @@
|
|
|
|
|
// install.sh is generated by ./extra/install.batsh, do not modify it directly.
|
|
|
|
|
// "npm run compile-install-script" to compile install.sh
|
|
|
|
|
// The command is working on Windows PowerShell and Docker for Windows only.
|
|
|
|
|
println("=====================");
|
|
|
|
|
println("Uptime Kuma Installer");
|
|
|
|
|
println("=====================");
|
|
|
|
|
println("");
|
|
|
|
|
println("---------------------------------------");
|
|
|
|
|
println("This script is designed for Linux and basic usage.");
|
|
|
|
|
println("Tested with CentOS 7/8");
|
|
|
|
|
println("For advanced usage, please go to https://github.com/louislam/uptime-kuma/wiki/Installation");
|
|
|
|
|
println("---------------------------------------");
|
|
|
|
|
println("");
|
|
|
|
@ -18,16 +22,19 @@ if ("$1" != "") {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type == "local") {
|
|
|
|
|
|
|
|
|
|
if ("$1" != "") {
|
|
|
|
|
port = "$3";
|
|
|
|
|
} else {
|
|
|
|
|
call("read", "-p", "Listening Port [3001]: ", "port");
|
|
|
|
|
}
|
|
|
|
|
defaultPort = "3001";
|
|
|
|
|
defaultInstallPath = "/opt/uptime-kuma";
|
|
|
|
|
|
|
|
|
|
if (exists("/etc/redhat-release")) {
|
|
|
|
|
os = call("cat", "/etc/redhat-release");
|
|
|
|
|
distribution = "rhel";
|
|
|
|
|
|
|
|
|
|
} else if (exists("/etc/issue")) {
|
|
|
|
|
bash("os=$(head -n1 /etc/issue | cut -f 1 -d ' ')");
|
|
|
|
|
if (os == "Ubuntu") {
|
|
|
|
|
distribution = "ubuntu";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bash("arch=$(uname -i)");
|
|
|
|
@ -36,33 +43,89 @@ if (type == "local") {
|
|
|
|
|
println("Distribution: " ++ distribution);
|
|
|
|
|
println("Arch: " ++ arch);
|
|
|
|
|
|
|
|
|
|
if ("$3" != "") {
|
|
|
|
|
port = "$3";
|
|
|
|
|
} else {
|
|
|
|
|
call("read", "-p", "Listening Port [$port]: ", "port");
|
|
|
|
|
|
|
|
|
|
if (port == "") {
|
|
|
|
|
port = defaultPort;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("$2" != "") {
|
|
|
|
|
installPath = "$2";
|
|
|
|
|
} else {
|
|
|
|
|
call("read", "-p", "Installation Path [$installPath]: ", "installPath");
|
|
|
|
|
|
|
|
|
|
if (installPath == "") {
|
|
|
|
|
installPath = defaultInstallPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (distribution == "rhel") {
|
|
|
|
|
bash("nodePath=$(command -v node)");
|
|
|
|
|
bash("nodeCheck=$(node -v)");
|
|
|
|
|
|
|
|
|
|
if (nodePath != "") {
|
|
|
|
|
if (nodeCheck != "") {
|
|
|
|
|
bash("nodeVersion=$(node -e 'console.log(process.versions.node.split(`.`)[0])')");
|
|
|
|
|
println("Node Version: " ++ nodeVersion);
|
|
|
|
|
|
|
|
|
|
if (nodeVersion < "12") {
|
|
|
|
|
println("Error: Required Node.js 14");
|
|
|
|
|
call("exit", "1");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (nodeVersion == "12") {
|
|
|
|
|
println("Warning: NodeJS " ++ nodeVersion ++ " is not tested.");
|
|
|
|
|
}
|
|
|
|
|
println("OK");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nodeVersion == "12") {
|
|
|
|
|
println("Warning: NodeJS " ++ nodeVersion ++ " is not tested.");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
bash("curlCheck=$(curl --version)");
|
|
|
|
|
if (curlCheck == "") {
|
|
|
|
|
println("Installing Curl");
|
|
|
|
|
bash("yum -y -q install curl");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
println("Installing Node.js 14");
|
|
|
|
|
bash("curl -sL https://rpm.nodesource.com/setup_14.x | bash - > log.txt");
|
|
|
|
|
bash("yum install -y -q nodejs");
|
|
|
|
|
bash("node -v");
|
|
|
|
|
|
|
|
|
|
bash("nodeCheckAgain=$(node -v)");
|
|
|
|
|
|
|
|
|
|
if (nodeCheckAgain == "") {
|
|
|
|
|
println("Error during Node.js installation");
|
|
|
|
|
bash("exit 1");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bash("check=$(git --version)");
|
|
|
|
|
if (check == "") {
|
|
|
|
|
println("Installing Git");
|
|
|
|
|
bash("yum -y -q install git");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bash("check=$(pm2 --version)");
|
|
|
|
|
if (check == "") {
|
|
|
|
|
println("Installing PM2");
|
|
|
|
|
bash("npm install pm2 -g");
|
|
|
|
|
bash("pm2 startup");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bash("mkdir -p $installPath");
|
|
|
|
|
bash("cd $installPath");
|
|
|
|
|
bash("git clone https://github.com/louislam/uptime-kuma.git .");
|
|
|
|
|
bash("npm run setup");
|
|
|
|
|
|
|
|
|
|
call("yum", "install", "git", "-y");
|
|
|
|
|
bash("pm2 start npm --name uptime-kuma -- run start-server -- --port=$port");
|
|
|
|
|
bash("pm2 list");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (distribution == "ubuntu") {
|
|
|
|
|
println("TODO");
|
|
|
|
|
// TODO
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
call("read", "-p", "Expose Port [3001]: ", "port");
|
|
|
|
|
call("read", "-p", "Volume Name [uptime-kuma]: ", "volume");
|
|
|
|
|