wip: implementing install script

This commit is contained in:
LouisLam
2021-08-17 23:08:35 +08:00
parent 29a89df524
commit d218661f3d
5 changed files with 134 additions and 2 deletions

View File

@@ -1 +1,2 @@
docker run -it --rm -v ${pwd}:/app louislam/batsh /usr/bin/batsh bash --output ./install.sh ./extra/install.batsh
# Must enable File Sharing in Docker Desktop
docker run -it --rm -v ${pwd}:/app louislam/batsh /usr/bin/batsh bash --output ./install.sh ./extra/install.batsh

69
extra/install.batsh Normal file
View File

@@ -0,0 +1,69 @@
println("=====================");
println("Uptime Kuma Installer");
println("=====================");
println("");
println("---------------------------------------");
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("---------------------------------------");
println("");
println("Local - Install Uptime Kuma in your current machine with git, Node.js 14 and pm2");
println("Docker - Install Uptime Kuma Docker container");
println("");
if ("$1" != "") {
type = "$1";
} else {
call("read", "-p", "Which installation method do you prefer? [DOCKER/local]: ", "type");
}
if (type == "local") {
if ("$1" != "") {
port = "$3";
} else {
call("read", "-p", "Listening Port [3001]: ", "port");
}
if (exists("/etc/redhat-release")) {
os = call("cat", "/etc/redhat-release");
distribution = "rhel";
}
bash("arch=$(uname -i)");
println("Your OS: " ++ os);
println("Distribution: " ++ distribution);
println("Arch: " ++ arch);
if (distribution == "rhel") {
bash("nodePath=$(command -v node)");
if (nodePath != "") {
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");
}
} else {
}
call("yum", "install", "git", "-y");
}
} else {
call("read", "-p", "Expose Port [3001]: ", "port");
call("read", "-p", "Volume Name [uptime-kuma]: ", "volume");
}