#function.sh文件函数的定义:
1
2
3
4
5
|
cat function .sh
#ftp上拉取静态文件到跳板机 function scpFtpStatic() {
scp $ftpHost:$ftpPath/$dateTime /static/ * $projectDir /static
} |
#上线发布脚本如下:
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
29
30
31
32
33
34
35
36
37
38
39
40
41
|
$ cat static_online.sh
#!/bin/bash . . /function .sh
static_nginx=10.10.70.10 back_time=` date + "%Y-%m-%d-%H-%M-%S" `
if [ $userName == ody ]; then
echo "###################当前所在目录为$nowdir#######################"
echo "正在执行了拉取静态文件操作."
scpFtpStatic
if [ $? - eq 0 ]; then
read -p "请输入需要发布的静态资源zip包:(steel.zip|steel-front.zip|steel-h5.zip|cms_dev.zip):" static_war
if [ -f .. /static/ ${static_war} ]; then
case $static_war in
steel.zip)
ssh $static_nginx "cd /data/didipingang/ && cp -r steel{,-${back_time}};cd /data/didipingang/steel && /bin/rm -rf ./*"
scp .. /static/ ${static_war} ${static_nginx}: /data/didipingang/steel
ssh $static_nginx "cd /data/didipingang/steel && unzip ${static_war}"
;;
steel-front.zip)
ssh $static_nginx "cd /data/didipingang/ && cp -r steel-front{,-${back_time}};cd /data/didipingang/steel-front && /bin/rm -rf ./*"
scp .. /static/ ${static_war} ${static_nginx}: /data/didipingang/steel-front
ssh $static_nginx "cd /data/didipingang/steel-front && unzip ${static_war}"
;;
steel-h5.zip)
ssh $static_nginx "cd /data/didipingang/ && cp -r steel-h5{,-${back_time}};cd /data/didipingang/steel-h5 && /bin/rm -rf ./*"
scp .. /static/ ${static_war} ${static_nginx}: /data/didipingang/steel-h5/
ssh $static_nginx "cd /data/didipingang/steel-h5 && unzip ${static_war}"
;;
cms_dev.zip)
ssh $static_nginx "cd /data/didipingang/ && cp -r cms_dev{,-${back_time}};cd /data/didipingang/cms_dev && /bin/rm -rf ./*"
scp .. /static/ ${static_war} ${static_nginx}: /data/didipingang/cms_dev
ssh $static_nginx "cd /data/didipingang/cms_dev && unzip ${static_war}"
;;
esac
else
echo "未正确输入静态资源zip包: (steel.zip|steel-front.zip|steel-h5.zip|cms_dev.zip)"
fi
else
exit 1;
fi
fi |
本文转自青衫解衣 51CTO博客,原文链接:http://blog.51cto.com/215687833/1898450