flowable工作流_使用Bash Shell实现flowable配置文件修改定制

1、概要

部署flowable工作流引擎,需要根据所在服务器的IP和MySQL账密信息,修改很多配置项,为方便,这些配置项,采用脚本批处理的方式,将用户在终端输入的信息,进行处理并修改配置项(以往的操作是,先将压缩包解压,再将war包解压,修改配置文件,再将文件打成war包,最后部署测试,及其容易出错)。节省了大量的时间。

脚本完整版地址:

https://flowable.oss-cn-beijing.aliyuncs.com/semi_auto_deploy_flowable_sample.sh

flowable下载地址

https://github.com/flowable/flowable-engine/releases/tag/flowable-6.3.0

2、脚本内容

脚本做了以下事情:

  • 解压flowable.zip

  • 创建flowable-admin等5个文件夹,并将flowable-admin.war等5个war包依次移动至相对应的文件夹

  • 解压war包 && 进入指定目录,处理配置文件

  • 接受用户输入的配置项各项信息

  • 每一个配置文件输入结束时,会确认是否要继续,正确输入y,则生成application.properies配置文件

  • 错误则输入n,输入指定的数字,进行纠正,直至用户输入y确认成配置文件

  • 将处理好的文件,打包成war包

3、实现

如图,使用的时候,保证脚本和压缩包在同一目录下:

447b484c824a87f17853fd251d39f5d2.png

这段代码是获取文件路径

CURDIR=$(  cd $(dirname ${BASH_SOURCE[0]})  pwd)

这段代码是处理用户输入的内容

cd flowable-admin/WEB-INF/classesrm -rf application.propertiestouch application.properties# 提示端口,如果不输入,会有默认值9988echo -n "[1]please input the server.port = ? (default is 9988)"read portif [[ $port == "" ]]; then  port='9988'fiecho -n "your server.port is $port"echo -n "[13]please input the MySQL server host ip = ? (default is 127.0.0.1)"read MySQLHostIpif [[ $MySQLHostIp == "" ]]; then  MySQLHostIp='127.0.0.1'fiecho -n "[14]please input the MySQL server host port = ? (default is 3306)"read MySQLHostPortif [[ $MySQLHostPort == "" ]]; then  MySQLHostPort='3306'fi

上文说过,如果错了,是可以根据序号修正输入信息的。如果flag不为y,则会一直询问正确输入,直至输入y为止。

read flagwhile [[ $flag == "n" ]]; do  echo 'input number 1 to 26, the numbers are not continuous'  echo 'your number is'  read aNum  case $aNum in  1)    echo 'number is 1, please fix your [port] current!'    read line1    port=$line1    ;;  13)    echo 'number is 13, please fix your [the MySQL server host ip] current!'    read line13    MySQLHostIp=$line13    ;;  14)    echo 'number is 14, please fix your [the MySQL server host port] current!'    read line14    MySQLHostPort=$line14    ;;  *)    echo 'Error'    ;;  esac  echo -n "confirm,if wrong, please choice 'n' to fix it !, input y/n:"  read flagdone

最后,使用

cat >application.properties <<EOF

并配合类似:

spring.datasource.username=$datasourceUsernamespring.datasource.password=$datasourcePassword

将读取终端input的变量值写入要生成的配置文件中。

4、最后

使用Bash Shell的好处,不需要再额外部署运行环境,也无需担心三方部署系统对生产机器带来不可预知的错误和问题。

可以尝试自己的工作或者学习中,有没有需要一个Bash Shell来解决的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值