Skip to content

Commit 8356181

Browse files
committed
脚本兼容
1 parent 18f228a commit 8356181

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

dist/agent.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
#!/bin/bash
2-
# run in Centos
2+
# run in Unix
3+
4+
ip=$(ifconfig eth0 2>/dev/null|grep "inet "|awk '{print $2}')
5+
if [ ! $ip ];then
6+
ip=$(ifconfig eno1 2>/dev/null|grep "inet "|awk '{print $2}')
7+
fi
8+
if [ ! $ip ];then
9+
ip=$(ifconfig en0 2>/dev/null|grep "inet "|awk '{print $2}')
10+
fi
11+
312
getServerInfoResp(){
413
if [ $# -lt 2 ];then
514
echo "invalid cmd...please input your request [serviceName],[serviceName.yml]"
615
exit 1
716
fi
8-
ip=$(ifconfig eth0|grep "inet "|awk '{print $2}')
9-
1017

1118
if [ -e "$2" ];then
12-
time=`stat -c %Y $2`
19+
time=`stat -c %Y $2 2>/dev/null`
20+
# macos
21+
if [ ! $time ];then
22+
time=`stat -f "%B %N" $2 | awk '{print$1}'`
23+
fi
1324
else
1425
time=0
1526
fi
@@ -53,7 +64,6 @@ deployResp() {
5364
}
5465

5566
stopResp() {
56-
ip=$(ifconfig eth0|grep "inet "|awk '{print $2}')
5767
echo $@
5868
echo -e "\033[33m $ip stopping $1 \033[0m"
5969
docker stop $1
@@ -67,7 +77,6 @@ stopResp() {
6777
}
6878

6979
restartResp() {
70-
ip=$(ifconfig eth0|grep "inet "|awk '{print $2}')
7180
echo -e "\033[33m $ip restarting $1 \033[0m"
7281
docker restart $1
7382
if [ $? -ne 0 ]; then
@@ -80,7 +89,6 @@ restartResp() {
8089
}
8190

8291
rmContainerResp() {
83-
ip=$(ifconfig eth0|grep "inet "|awk '{print $2}')
8492
echo $@
8593
echo -e "\033[33m $ip rm Container $1 \033[0m"
8694
docker rm $1
@@ -101,7 +109,6 @@ getYamlFile() {
101109
}
102110

103111
syncNetworkResp() {
104-
ip=$(ifconfig eth0|grep "inet "|awk '{print $2}')
105112
networkName="$1"
106113
driver="$2"
107114
subnet="$3"
@@ -118,7 +125,6 @@ syncNetworkResp() {
118125

119126
build() {
120127
# build info start
121-
ip=$(ifconfig eth0|grep "inet "|awk '{print $2}')
122128
serviceName=$1
123129
projectUrl=$2
124130
serviceBranch=$3

0 commit comments

Comments
 (0)