2021-08-18 08:55:03 +02:00
|
|
|
# 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.
|
2021-08-17 17:08:35 +02:00
|
|
|
"echo" "-e" "====================="
|
|
|
|
"echo" "-e" "Uptime Kuma Installer"
|
|
|
|
"echo" "-e" "====================="
|
|
|
|
"echo" "-e" ""
|
|
|
|
"echo" "-e" "---------------------------------------"
|
|
|
|
"echo" "-e" "This script is designed for Linux and basic usage."
|
2021-08-18 08:55:03 +02:00
|
|
|
"echo" "-e" "Tested with CentOS 7/8"
|
2021-08-17 17:08:35 +02:00
|
|
|
"echo" "-e" "For advanced usage, please go to https://github.com/louislam/uptime-kuma/wiki/Installation"
|
|
|
|
"echo" "-e" "---------------------------------------"
|
|
|
|
"echo" "-e" ""
|
|
|
|
"echo" "-e" "Local - Install Uptime Kuma in your current machine with git, Node.js 14 and pm2"
|
|
|
|
"echo" "-e" "Docker - Install Uptime Kuma Docker container"
|
|
|
|
"echo" "-e" ""
|
|
|
|
if [ "$1" != "" ]; then
|
|
|
|
type="$1"
|
|
|
|
else
|
|
|
|
"read" "-p" "Which installation method do you prefer? [DOCKER/local]: " "type"
|
|
|
|
fi
|
|
|
|
if [ "$type" == "local" ]; then
|
2021-08-18 08:55:03 +02:00
|
|
|
defaultPort="3001"
|
|
|
|
defaultInstallPath="/opt/uptime-kuma"
|
2021-08-17 17:08:35 +02:00
|
|
|
if [ -e "/etc/redhat-release" ]; then
|
|
|
|
os=$("cat" "/etc/redhat-release")
|
2021-08-18 08:55:03 +02:00
|
|
|
distribution="rhel"
|
|
|
|
else
|
|
|
|
if [ -e "/etc/issue" ]; then
|
|
|
|
os=$(head -n1 /etc/issue | cut -f 1 -d ' ')
|
|
|
|
if [ "$os" == "Ubuntu" ]; then
|
|
|
|
distribution="ubuntu"
|
|
|
|
fi
|
2021-08-17 17:08:35 +02:00
|
|
|
fi
|
2021-08-18 08:55:03 +02:00
|
|
|
fi
|
2021-08-17 17:08:35 +02:00
|
|
|
arch=$(uname -i)
|
|
|
|
"echo" "-e" "Your OS: ""$os"
|
|
|
|
"echo" "-e" "Distribution: ""$distribution"
|
|
|
|
"echo" "-e" "Arch: ""$arch"
|
2021-08-18 08:55:03 +02:00
|
|
|
if [ "$3" != "" ]; then
|
|
|
|
port="$3"
|
|
|
|
else
|
|
|
|
"read" "-p" "Listening Port [$port]: " "port"
|
|
|
|
if [ "$port" == "" ]; then
|
|
|
|
port="$defaultPort"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ "$2" != "" ]; then
|
|
|
|
installPath="$2"
|
|
|
|
else
|
|
|
|
"read" "-p" "Installation Path [$installPath]: " "installPath"
|
|
|
|
if [ "$installPath" == "" ]; then
|
|
|
|
installPath="$defaultInstallPath"
|
|
|
|
fi
|
|
|
|
fi
|
2021-08-17 17:08:35 +02:00
|
|
|
if [ "$distribution" == "rhel" ]; then
|
2021-08-18 08:55:03 +02:00
|
|
|
nodeCheck=$(node -v)
|
|
|
|
if [ "$nodeCheck" != "" ]; then
|
2021-08-17 17:08:35 +02:00
|
|
|
nodeVersion=$(node -e 'console.log(process.versions.node.split(`.`)[0])')
|
|
|
|
"echo" "-e" "Node Version: ""$nodeVersion"
|
|
|
|
_0="12"
|
|
|
|
if [ $(($nodeVersion < $_0)) == 1 ]; then
|
|
|
|
"echo" "-e" "Error: Required Node.js 14"
|
2021-08-18 08:55:03 +02:00
|
|
|
"exit" "1"
|
|
|
|
fi
|
|
|
|
if [ "$nodeVersion" == "12" ]; then
|
|
|
|
"echo" "-e" "Warning: NodeJS ""$nodeVersion"" is not tested."
|
2021-08-17 17:08:35 +02:00
|
|
|
fi
|
|
|
|
else
|
2021-08-18 08:55:03 +02:00
|
|
|
curlCheck=$(curl --version)
|
|
|
|
if [ "$curlCheck" == "" ]; then
|
|
|
|
"echo" "-e" "Installing Curl"
|
|
|
|
yum -y -q install curl
|
|
|
|
fi
|
|
|
|
"echo" "-e" "Installing Node.js 14"
|
|
|
|
curl -sL https://rpm.nodesource.com/setup_14.x | bash - > log.txt
|
|
|
|
yum install -y -q nodejs
|
|
|
|
node -v
|
|
|
|
nodeCheckAgain=$(node -v)
|
|
|
|
if [ "$nodeCheckAgain" == "" ]; then
|
|
|
|
"echo" "-e" "Error during Node.js installation"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-08-17 17:08:35 +02:00
|
|
|
fi
|
2021-08-18 08:55:03 +02:00
|
|
|
check=$(git --version)
|
|
|
|
if [ "$check" == "" ]; then
|
|
|
|
"echo" "-e" "Installing Git"
|
|
|
|
yum -y -q install git
|
|
|
|
fi
|
|
|
|
check=$(pm2 --version)
|
|
|
|
if [ "$check" == "" ]; then
|
|
|
|
"echo" "-e" "Installing PM2"
|
|
|
|
npm install pm2 -g
|
|
|
|
pm2 startup
|
|
|
|
fi
|
|
|
|
mkdir -p $installPath
|
|
|
|
cd $installPath
|
|
|
|
git clone https://github.com/louislam/uptime-kuma.git .
|
|
|
|
npm run setup
|
|
|
|
pm2 start npm --name uptime-kuma -- run start-server -- --port=$port
|
|
|
|
pm2 list
|
|
|
|
fi
|
|
|
|
if [ "$distribution" == "ubuntu" ]; then
|
|
|
|
"echo" "-e" "TODO"
|
|
|
|
# TODO
|
2021-08-17 17:08:35 +02:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
"read" "-p" "Expose Port [3001]: " "port"
|
|
|
|
"read" "-p" "Volume Name [uptime-kuma]: " "volume"
|
|
|
|
fi
|