From d699ab17120458385acf924676775c5724defab0 Mon Sep 17 00:00:00 2001 From: YuleiLan Date: Wed, 7 Apr 2021 19:06:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=B8=80=E9=94=AE?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E8=84=9A=E6=9C=AC=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..b666011 --- /dev/null +++ b/build.sh @@ -0,0 +1,164 @@ +#!/bin/bash + +cat << EOF + + 执行此脚本之前,请确认一下软件是否安装或者是否有现成的连接地址。 + + 若未没有请根据不同的系统,自行百度一下安装教程。 + + 1. git 最新版本即可 + 1. MySQL >= 5.7 + 2. Go >= 1.14 + 3. Redis 最新版本即可 + 4. node >= v12 (稳定版本) + 5. npm >= v6.14.8 + +EOF + +# 判断目录是否存在,不存在则新建目录 +isDirExist() { + if [ ! -d "$1" ]; then + mkdir -p $1 + fi +} + +echo "确认 build 目录是否存在" +isDirExist "./build" +isDirExist "./build/log" +isDirExist "./build/template" + +echo "开始迁移配置信息..." +isDirExist "./build/config" +cp -r ./config/db.sql ./build/config +cp -r ./config/settings.yml ./build/config/settings.yml +cp -r ./config/rbac_model.conf ./build/config/rbac_model.conf + +echo "开始迁移静态文件..." +isDirExist "./build/static/scripts" +isDirExist "./build/static/template" +isDirExist "./build/static/uploadfile" +cp -r ./static/template/email.html ./build/static/template/email.html + +# 编译前端程序,再此处需输入程序的访问地址,来进行前端程序的编译 +read -p "请输入您的程序访问地址,例如:https://fdevops.com:8001,不可为空: " url +if [ -z "$url" ]; then + echo "url输入不能为空" + exit 1 +fi + +echo "请选择从哪里拉取前端代码,默认是gitee: " +cat << EOF + + 1. gitee + 2. github + 3. 自定义拉取地址 + +EOF + +read -p "请选择[1]: " ui +if [ -z "$ui" ]; then + ui=1 +fi + +if [ $ui == 1 ]; then + ui_address="https://gitee.com/yllan/ferry_web.git" +elif [ $ui == 2 ]; then + ui_address="https://github.com/lanyulei/ferry_web.git" +elif [ $ui == 3 ]; then + read -p "请输入拉取地址: " ui_address +else + echo "选项不正确,请重新输入" + exit 1 +fi + +echo "开始拉取前端程序..." +read -p "此处会执行 rm -rf ./ferry_web 的命令,若此命令不会造成当前环境的损伤则请继续,y/n[y] :" s +if [ ! -z "$s" ]; then + if [ $s == "n" ]; then + echo "结束此次编译" + exit 1 + elif [ $s != "y" ]; then + echo "结束此次编译" + exit 1 + fi +fi + + if [ -d "./ferry_web" ]; then + echo "请稍等,正在删除 ferry_web ..." + rm -rf ./ferry_web + fi + git clone $ui_address + +echo "替换程序访问地址..." +cat > ./ferry_web/.env.production << EOF +# just a flag +ENV = 'production' + +# base api +VUE_APP_BASE_API = '$url' +EOF + +echo "开始安装前端依赖..." + npm install -g cnpm --registry=https://registry.npm.taobao.org + cd ferry_web && cnpm install && npm run build:prod && cp -r web ../build/template + +echo "\n需注意: 邮件服务器信息若是暂时没有,可暂时不修改,但是MySQL和Redis是必须配置正确的\n" +read -p "请确认是否配置MySQL、Redis及邮件服务器信息,配置文件地址: build/config/settings.yml,y/n[y]: " config_status +if [ ! -z "$config_status" ]; then + if [ $config_status == "n" ]; then + echo "结束此次编译" + exit 1 + elif [ $config_status != "y" ]; then + echo "结束此次编译" + exit 1 + fi +fi + +read -p "请确认是否创建配置文件中的MySQL库,y/n[y]: " mysql_db_status +if [ ! -z "$mysql_db_status" ]; then + if [ $mysql_db_status == "n" ]; then + echo "结束此次编译" + exit 1 + elif [ $mysql_db_status != "y" ]; then + echo "结束此次编译" + exit 1 + fi +fi + +cat <