Skip to content

Commit

Permalink
feat: auto update shell
Browse files Browse the repository at this point in the history
feat: change client dist dir
feat: chat emoji
feat: custom websocket host
feat: update icon
feat: update layui.js
fix: socket id equel 0 error
  • Loading branch information
iamtsm committed Sep 9, 2023
1 parent a5ae9d9 commit 9f5d912
Show file tree
Hide file tree
Showing 48 changed files with 700 additions and 56 deletions.
102 changes: 102 additions & 0 deletions bin/centeros/auto-check-install-http.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash
#########################
# 提供一键部署http服务环境的脚本
# 包含api服务,socket服务
# @auther: iamtsm
# @version: v1.0.0
#########################

# Function to install Node.js 16
install_node() {
echo "======>Node.js is not installed. Installing Node.js 16..."
curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum install -y nodejs
echo "======>Node.js 16 installed"
}

# Function to install pm2 globally
install_pm2() {
echo "======>pm2 is not installed. Installing pm2 globally..."
sudo npm install -g pm2
echo "======>pm2 installed"
}

# Function to install lsof
install_lsof() {
echo "======>lsof is not installed. Installing lsof..."
sudo yum install -y lsof
echo "======>lsof installed"
}

# Wait for a command to become available
wait_for_command() {
command="$1"
while ! command -v $command &> /dev/null; do
sleep 1
done
}

# Step 1: Check if sudo is installed and install if not
if ! command -v sudo &> /dev/null; then
echo "======>sudo is not installed. Installing sudo..."
yum install -y sudo
fi

# Step 2: Check if curl is installed
if ! command -v curl &> /dev/null; then
echo "======>curl is not installed. Installing curl..."
sudo yum install -y curl
fi

# Step 3: Check if Node.js is installed and install Node.js 16 if not
if ! command -v node &> /dev/null; then
install_node
else
echo "======>Node.js is already installed"
fi

# Wait for Node.js to be installed
wait_for_command node

# Step 4: 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"

# Step 5: Check if pm2 is installed and install it globally if not
if ! command -v pm2 &> /dev/null; then
install_pm2
else
echo "======>pm2 is already installed"
fi

# Wait for pm2 to be installed
wait_for_command pm2

# Step 6: Check if lsof is installed and install if not
if ! command -v lsof &> /dev/null; then
install_lsof
else
echo "======>lsof is already installed"
fi

# Step 7: 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 8: install npm packages
echo "Ready to install npm packages"
cd ../../svr/
rm package-lock.json
npm install --registry=https://registry.npmmirror.com

# Step 9: Run start-http.sh script to start the service
echo "Ready to run auto-start-http.sh"
sleep 1
/bin/bash ./../bin/ubuntu16/auto-start-http.sh
102 changes: 102 additions & 0 deletions bin/centeros/auto-check-install-https.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash
#########################
# 提供一键部署https服务环境的脚本
# 包含api服务,socket服务
# @auther: iamtsm
# @version: v1.0.0
#########################

# Function to install Node.js 16
install_node() {
echo "======>Node.js is not installed. Installing Node.js 16..."
curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum install -y nodejs
echo "======>Node.js 16 installed"
}

# Function to install pm2 globally
install_pm2() {
echo "======>pm2 is not installed. Installing pm2 globally..."
sudo npm install -g pm2
echo "======>pm2 installed"
}

# Function to install lsof
install_lsof() {
echo "======>lsof is not installed. Installing lsof..."
sudo yum install -y lsof
echo "======>lsof installed"
}

# Wait for a command to become available
wait_for_command() {
command="$1"
while ! command -v $command &> /dev/null; do
sleep 1
done
}

# Step 1: Check if sudo is installed and install if not
if ! command -v sudo &> /dev/null; then
echo "======>sudo is not installed. Installing sudo..."
yum install -y sudo
fi

# Step 2: Check if curl is installed
if ! command -v curl &> /dev/null; then
echo "======>curl is not installed. Installing curl..."
sudo yum install -y curl
fi

# Step 3: Check if Node.js is installed and install Node.js 16 if not
if ! command -v node &> /dev/null; then
install_node
else
echo "======>Node.js is already installed"
fi

# Wait for Node.js to be installed
wait_for_command node

# Step 4: 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"

# Step 5: Check if pm2 is installed and install it globally if not
if ! command -v pm2 &> /dev/null; then
install_pm2
else
echo "======>pm2 is already installed"
fi

# Wait for pm2 to be installed
wait_for_command pm2

# Step 6: Check if lsof is installed and install if not
if ! command -v lsof &> /dev/null; then
install_lsof
else
echo "======>lsof is already installed"
fi

# Step 7: 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 8: install npm packages
echo "Ready to install npm packages"
cd ../../svr/
rm package-lock.json
npm install --registry=https://registry.npmmirror.com

# Step 9: Run start-https.sh script to start the service
echo "Ready to run auto-start-https.sh"
sleep 1
/bin/bash ./../bin/ubuntu16/auto-start-https.sh
17 changes: 17 additions & 0 deletions bin/centeros/auto-start-http.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
#########################
# 提供pm2启动管理http服务的脚本
# 包含api服务,socket服务
# @auther: iamtsm
# @version: v1.0.0
#########################

pm2 start npm --name=tl-rtc-file-api -- run http-api

sleep 1

pm2 start npm --name=tl-rtc-file-socket -- run http-socket

sleep 1

npm run build:pro
17 changes: 17 additions & 0 deletions bin/centeros/auto-start-https.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
#########################
# 提供pm2启动管理https服务的脚本
# 包含api服务,socket服务
# @auther: iamtsm
# @version: v1.0.0
#########################

pm2 start npm --name=tl-rtc-file-api -- run https-api

sleep 1

pm2 start npm --name=tl-rtc-file-socket -- run https-socket

sleep 1

npm run build:pro
13 changes: 13 additions & 0 deletions bin/centeros/auto-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
#########################
# 提供pm2删除停止服务的脚本
# 包含api服务,socket服务
# @auther: iamtsm
# @version: v1.0.0
#########################

pm2 del tl-rtc-file-api

pm2 del tl-rtc-file-socket

echo "stop and [tl-rtc-file-api] / [tl-rtc-file-socket] pm2 processes ok"
36 changes: 36 additions & 0 deletions bin/centeros/auto-update-project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
#########################
# 提供一键更新项目代码版本的脚本
# @auther: iamtsm
# @version: v1.0.0
#########################

# Check if the current directory is a Git repository
if [ -d .git ]; then
# The current directory is a Git repository, so we can pull the latest changes
echo "Current directory is a Git repository. Pulling latest changes..."
git pull
else
# The current directory is not a Git repository
echo "Current directory is not a Git repository."

# Check if Git is installed
if ! command -v git &> /dev/null; then
# Git is not installed, so let's try to install it
echo "Git is not installed. Installing Git..."
sudo yum install -y git
fi

# Initialize a new Git repository and set the remote URL
echo "Initializing a new Git repository and setting remote URL..."
git init
git remote add origin https://github.com/tl-open-source/tl-rtc-file.git

# Pull the latest changes from the remote repository (use 'master' branch)
git pull origin master

# Optionally, you can set the default branch to 'master'
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master
fi

echo "Done."
6 changes: 6 additions & 0 deletions bin/ubuntu16/auto-check-install-http.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/bash
#########################
# 提供一键部署http服务环境的脚本
# 包含api服务,socket服务
# @auther: iamtsm
# @version: v1.0.0
#########################

# Function to install Node.js 16
install_node() {
Expand Down
6 changes: 6 additions & 0 deletions bin/ubuntu16/auto-check-install-https.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/bash
#########################
# 提供一键部署https服务环境的脚本
# 包含api服务,socket服务
# @auther: iamtsm
# @version: v1.0.0
#########################

# Function to install Node.js 16
install_node() {
Expand Down
6 changes: 6 additions & 0 deletions bin/ubuntu16/auto-start-http.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/bash
#########################
# 提供pm2启动管理http服务的脚本
# 包含api服务,socket服务
# @auther: iamtsm
# @version: v1.0.0
#########################

pm2 start npm --name=tl-rtc-file-api -- run http-api

Expand Down
6 changes: 6 additions & 0 deletions bin/ubuntu16/auto-start-https.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/bash
#########################
# 提供pm2启动管理https服务的脚本
# 包含api服务,socket服务
# @auther: iamtsm
# @version: v1.0.0
#########################

pm2 start npm --name=tl-rtc-file-api -- run https-api

Expand Down
6 changes: 6 additions & 0 deletions bin/ubuntu16/auto-stop.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/bash
#########################
# 提供pm2删除停止服务的脚本
# 包含api服务,socket服务
# @auther: iamtsm
# @version: v1.0.0
#########################

pm2 del tl-rtc-file-api

Expand Down
37 changes: 37 additions & 0 deletions bin/ubuntu16/auto-update-project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
#########################
# 提供一键更新项目代码版本的脚本
# @auther: iamtsm
# @version: v1.0.0
#########################

# Check if the current directory is a Git repository
if [ -d .git ]; then
# The current directory is a Git repository, so we can pull the latest changes
echo "Current directory is a Git repository. Pulling latest changes..."
git pull
else
# The current directory is not a Git repository
echo "Current directory is not a Git repository."

# Check if Git is installed
if ! command -v git &> /dev/null; then
# Git is not installed, so let's try to install it
echo "Git is not installed. Installing Git..."
sudo apt-get update
sudo apt-get install -y git # Adjust this for CentOS or other Linux distributions
fi

# Initialize a new Git repository and set the remote URL
echo "Initializing a new Git repository and setting remote URL..."
git init
git remote add origin https://github.com/tl-open-source/tl-rtc-file.git

# Pull the latest changes from the remote repository (use 'master' branch)
git pull origin master

# Optionally, you can set the default branch to 'master'
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master
fi

echo "Done."
Loading

0 comments on commit 9f5d912

Please sign in to comment.