Files
tl-rtc-file/bin/ubuntu/auto-check-install-https.sh
https://blog.iamtsm.cn 55ff78d730 feat: 精简配置和部署流程(#18)
feat: 支持docker一键部署脚本
feat: 支持数据库官方镜像
feat: 支持docker默认开启数据库
feat: 优化数据库自动连接重试
doc: 更新文档
2023-08-09 18:15:37 +08:00

47 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Step 1: Check if Node.js is installed and install Node.js 18 if not
if ! command -v node &> /dev/null; then
echo "Node.js is not installed. Installing Node.js 18..."
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
fi
# Step 2: Output Node.js and npm versions
node_version=$(node -v)
npm_version=$(npm -v)
echo "Node.js version: $node_version"
echo "npm version: $npm_version"
sleep 1
# Step 3: Check if pm2 is installed and install it globally if not
if ! command -v pm2 &> /dev/null; then
echo "pm2 is not installed. Installing pm2 globally..."
sudo npm install -g pm2
fi
# Step 4: Output pm2 version
pm2_version=$(pm2 -v)
echo "pm2 version: $pm2_version"
sleep 1
# Step 5: Check if ports 9092 and 8444 are occupied
port_9092_in_use=$(sudo lsof -i :9092 | grep LISTEN | wc -l)
port_8444_in_use=$(sudo lsof -i :8444 | grep LISTEN | wc -l)
if [ "$port_9092_in_use" -gt 0 ] || [ "$port_8444_in_use" -gt 0 ]; then
echo "Port 9092 or 8444 is already in use."
exit 1
fi
# Step 6: install npm packages
echo "ready to install npm packages"
cd ../../svr/
npm install --registry=https://registry.npmmirror.com
cd ../bin/linux/
# Step 7: Run start-https.sh script to start the service
echo "ready to run auto-start-https.sh"
sleep 1
./auto-start-https.sh