变更记录

变更项 时间 更新者
初始化文档,实现war包的处理 2020.01 me

1、概要

部署flowable工作流引擎,需要根据所在服务器的IP和MySQL账密信息,修改很多配置项,为方便,这些配置项,采用脚本批处理的方式,将用户在终端输入的信息,进行处理并修改配置项。

2、脚本内容

脚本做了以下事情:

  • 解压flowable.zip
  • 创建flowable-admin等5个文件夹,并将flowable-admin.war等5个war包依次移动至相对应的文件夹
  • 解压war包 && 进入指定目录,处理配置文件
  • 接受用户输入的配置项各项信息
  • 每一个配置文件输入结束时,会确认是否要继续,正确输入y,则生成application.properies配置文件
  • 错误则输入n,输入指定的数字,进行纠正,直至用户输入y确认成配置文件
  • 将处理好的文件,打包成war包

3、实现

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



这段代码是获取路径

1
2
3
4
CURDIR=$(
cd $(dirname ${BASH_SOURCE[0]})
pwd
)



处理用户输入内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
cd flowable-admin/WEB-INF/classes
rm -rf application.properties
touch application.properties
# 提示端口,如果不输入,会有默认值9988
echo -n "[1]please input the server.port = ? (default is 9988)"
read port
if [[ $port == "" ]]; then
port='9988'
fi

echo -n "your server.port is $port"

echo -n "[13]please input the MySQL server host ip = ? (default is 127.0.0.1)"
read MySQLHostIp
if [[ $MySQLHostIp == "" ]]; then
MySQLHostIp='127.0.0.1'
fi

echo -n "[14]please input the MySQL server host port = ? (default is 3306)"
read MySQLHostPort
if [[ $MySQLHostPort == "" ]]; then
MySQLHostPort='3306'
fi



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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
read flag
while [[ $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 flag
done



最后,使用

1
cat >application.properties <<EOF

并配合类似:

1
2
spring.datasource.username=$datasourceUsername
spring.datasource.password=$datasourcePassword

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

4、脚本地址

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