|
|
|
@ -7,7 +7,7 @@ println("=====================");
|
|
|
|
|
println("");
|
|
|
|
|
println("---------------------------------------");
|
|
|
|
|
println("This script is designed for Linux and basic usage.");
|
|
|
|
|
println("Tested with CentOS 7/8");
|
|
|
|
|
println("Supported OS: CentOS 7/8, Ubuntu >= 16.04 and Debian");
|
|
|
|
|
println("For advanced usage, please go to https://github.com/louislam/uptime-kuma/wiki/Installation");
|
|
|
|
|
println("---------------------------------------");
|
|
|
|
|
println("");
|
|
|
|
@ -21,8 +21,64 @@ if ("$1" != "") {
|
|
|
|
|
call("read", "-p", "Which installation method do you prefer? [DOCKER/local]: ", "type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type == "local") {
|
|
|
|
|
defaultPort = "3001";
|
|
|
|
|
|
|
|
|
|
function checkNode() {
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nodeVersion == "12") {
|
|
|
|
|
println("Warning: NodeJS " ++ nodeVersion ++ " is not tested.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deb() {
|
|
|
|
|
bash("nodeCheck=$(node -v)");
|
|
|
|
|
bash("apt --yes update");
|
|
|
|
|
|
|
|
|
|
if (nodeCheck != "") {
|
|
|
|
|
checkNode();
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// Old nodejs binary name is "nodejs"
|
|
|
|
|
bash("check=$(nodejs --version)");
|
|
|
|
|
if (check != "") {
|
|
|
|
|
println("Error: 'node' command is not found, but 'nodejs' command is found. Your NodeJS should be too old.");
|
|
|
|
|
bash("exit 1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bash("curlCheck=$(curl --version)");
|
|
|
|
|
if (curlCheck == "") {
|
|
|
|
|
println("Installing Curl");
|
|
|
|
|
bash("apt --yes install curl");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
println("Installing Node.js 14");
|
|
|
|
|
bash("curl -sL https://deb.nodesource.com/setup_14.x | bash - > log.txt");
|
|
|
|
|
bash("apt --yes install 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("apt --yes install git");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type == "local") {
|
|
|
|
|
defaultInstallPath = "/opt/uptime-kuma";
|
|
|
|
|
|
|
|
|
|
if (exists("/etc/redhat-release")) {
|
|
|
|
@ -34,7 +90,9 @@ if (type == "local") {
|
|
|
|
|
if (os == "Ubuntu") {
|
|
|
|
|
distribution = "ubuntu";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (os == "Debian") {
|
|
|
|
|
distribution = "debian";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bash("arch=$(uname -i)");
|
|
|
|
@ -63,21 +121,12 @@ if (type == "local") {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CentOS
|
|
|
|
|
if (distribution == "rhel") {
|
|
|
|
|
bash("nodeCheck=$(node -v)");
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nodeVersion == "12") {
|
|
|
|
|
println("Warning: NodeJS " ++ nodeVersion ++ " is not tested.");
|
|
|
|
|
}
|
|
|
|
|
checkNode();
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
bash("curlCheck=$(curl --version)");
|
|
|
|
@ -105,6 +154,36 @@ if (type == "local") {
|
|
|
|
|
bash("yum -y -q install git");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ubuntu
|
|
|
|
|
} else if (distribution == "ubuntu") {
|
|
|
|
|
deb();
|
|
|
|
|
|
|
|
|
|
// Debian
|
|
|
|
|
} else if (distribution == "debian") {
|
|
|
|
|
deb();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// Unknown distribution
|
|
|
|
|
error = 0;
|
|
|
|
|
|
|
|
|
|
bash("check=$(git --version)");
|
|
|
|
|
if (check == "") {
|
|
|
|
|
error = 1;
|
|
|
|
|
println("Error: git is missing");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bash("check=$(node -v)");
|
|
|
|
|
if (check == "") {
|
|
|
|
|
error = 1;
|
|
|
|
|
println("Error: node is missing");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (error > 0) {
|
|
|
|
|
println("Please install above missing software");
|
|
|
|
|
bash("exit 1");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bash("check=$(pm2 --version)");
|
|
|
|
|
if (check == "") {
|
|
|
|
|
println("Installing PM2");
|
|
|
|
@ -118,15 +197,38 @@ if (type == "local") {
|
|
|
|
|
bash("npm run setup");
|
|
|
|
|
|
|
|
|
|
bash("pm2 start npm --name uptime-kuma -- run start-server -- --port=$port");
|
|
|
|
|
bash("pm2 list");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
defaultVolume = "uptime-kuma";
|
|
|
|
|
|
|
|
|
|
bash("check=$(docker -v)");
|
|
|
|
|
if (check == "") {
|
|
|
|
|
println("Error: docker is not found!");
|
|
|
|
|
bash("exit 1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (distribution == "ubuntu") {
|
|
|
|
|
println("TODO");
|
|
|
|
|
// TODO
|
|
|
|
|
if ("$3" != "") {
|
|
|
|
|
port = "$3";
|
|
|
|
|
} else {
|
|
|
|
|
call("read", "-p", "Expose Port [$port]: ", "port");
|
|
|
|
|
|
|
|
|
|
if (port == "") {
|
|
|
|
|
port = defaultPort;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("$2" != "") {
|
|
|
|
|
volume = "$2";
|
|
|
|
|
} else {
|
|
|
|
|
call("read", "-p", "Expose Port [3001]: ", "port");
|
|
|
|
|
call("read", "-p", "Volume Name [uptime-kuma]: ", "volume");
|
|
|
|
|
call("read", "-p", "Volume Name [$defaultVolume]: ", "volume");
|
|
|
|
|
|
|
|
|
|
if (volume == "") {
|
|
|
|
|
volume = defaultVolume;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
println("Port: $port");
|
|
|
|
|
println("Volume: $volume");
|
|
|
|
|
bash("docker volume create $volume");
|
|
|
|
|
bash("docker run -d --restart=always -p $port:3001 -v $volume:/app/data --name uptime-kuma louislam/uptime-kuma:1");
|
|
|
|
|
}
|
|
|
|
|