You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
#!/bin/bash
|
|
# ============================================
|
|
# RuoYi-Vue 前端部署脚本
|
|
# 使用方式: ./scripts/deploy/frontend-deploy.sh <dist-dir>
|
|
# ============================================
|
|
|
|
set -e
|
|
|
|
# 配置
|
|
DEPLOY_DIR="/usr/share/nginx/html/ruoyi-ui"
|
|
BACKUP_DIR="/usr/share/nginx/html/backup"
|
|
NGINX_CONF="/etc/nginx/conf.d/ruoyi-ui.conf"
|
|
|
|
echo_info() {
|
|
echo -e "\033[0;32m[INFO]\033[0m $1"
|
|
}
|
|
|
|
echo_error() {
|
|
echo -e "\033[0;31m[ERROR]\033[0m $1"
|
|
}
|
|
|
|
if [ ! -d "$1" ]; then
|
|
echo_error "构建目录不存在: $1"
|
|
exit 1
|
|
fi
|
|
|
|
echo_info "========================================"
|
|
echo_info "RuoYi-Vue 前端部署"
|
|
echo_info "========================================"
|
|
|
|
# 创建目录
|
|
mkdir -p $DEPLOY_DIR $BACKUP_DIR
|
|
|
|
# 备份现有版本
|
|
if [ -d "$DEPLOY_DIR" ] && [ "$(ls -A $DEPLOY_DIR)" ]; then
|
|
echo_info "备份现有版本..."
|
|
tar -czf ${BACKUP_DIR}/frontend-$(date +%Y%m%d_%H%M%S).tar.gz -C $(dirname $DEPLOY_DIR) $(basename $DEPLOY_DIR)
|
|
fi
|
|
|
|
# 部署新版本
|
|
echo_info "部署新版本..."
|
|
rm -rf ${DEPLOY_DIR}/*
|
|
cp -r $1/* $DEPLOY_DIR/
|
|
|
|
# 设置权限
|
|
chown -R nginx:nginx $DEPLOY_DIR
|
|
chmod -R 755 $DEPLOY_DIR
|
|
|
|
# 重新加载 Nginx
|
|
echo_info "重新加载 Nginx..."
|
|
nginx -t && systemctl reload nginx
|
|
|
|
echo_info "✅ 部署成功!"
|
|
echo_info "========================================"
|