-
Notifications
You must be signed in to change notification settings - Fork 3
/
start_services.sh
executable file
·107 lines (88 loc) · 2.38 KB
/
start_services.sh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# start development services
scriptDir=$(cd `dirname $0`; pwd)
# import public scripts
. "$scriptDir/public/index.sh"
softDir=/opt
startDir=`pwd`
appConf="$scriptDir/app.properties"
# mount windows dir
function mountWorkspace() {
mountFlag=`getProperty $appConf mount`
if [ "x$mountFlag" != "x1" ]; then
echoWarn "you do not wanna mount"
return 1
fi
mountIp=`getProperty $appConf mountIp`
mountUsername=`getProperty $appConf mountUsername gerrylon`
mountPassword=`getProperty $appConf mountPassword gerrylon`
mountSrcDir=`getProperty $appConf mountSrcDir workspace`
mountDstDir=`getProperty $appConf mountDstDir /var/workspace`
if ! isValidIp "$mountIp"; then
echoError "invalid ip found: $mountIp, please check!"
return 1
fi
df -h | grep -q "$mountDstDir"
if [ $? -eq 0 ]; then
echoInfo "//$mountIp/$mountSrcDir was already mounted to $mountDstDir"
return
fi
echo "mounting //$mountIp/$mountSrcDir to $mountDstDir"
[ ! -d $mountDstDir ] && echoWarn "creating dir: $mountDstDir" && mkdir -p "$mountDstDir"
mount -t cifs -o username=$mountUsername,password=$mountPassword,vers=2.0,iocharset=utf8 //$mountIp/$mountSrcDir $mountDstDir
df -h | grep -q "$mountDstDir"
if [ $? -ne 0 ]; then
echoError "mount error"
return 1
fi
echoInfo "mount success"
return $?
}
mountWorkspace
# start docker
if isCmdExist docker; then
ps -ef | grep docker | grep -v grep
if [ $? -eq 0 ]; then
echoInfo 'docker is already running'
else
echoInfo "starting docker..."
service docker start
fi
else
echoWarn 'docker is not installed'
fi
# start nginx
nginxCmd=`getProperty $appConf nginxRoot`/sbin/nginx
if [ -x $nginxCmd ]; then
ps -ef | grep nginx | grep -v grep
if [ $? -eq 0 ]; then
echoInfo 'nginx is running'
else
echoInfo 'start nginx'
$nginxCmd
fi
fi
# start mysql
if isCmdExist mysql; then
ps -ef | grep mysql | grep -v grep
if [ $? -eq 0 ]; then
echoInfo 'mysql is already running'
else
service mysql restart
fi
fi
# start redis
if isCmdExist redis-server; then
ps -ef | grep redis-server | grep -v grep
if [ $? -eq 0 ]; then
echoInfo 'redis is already running'
else
redisRoot=`getProperty $appConf redisRoot`
$redisRoot/bin/redis-server $redisRoot/conf/redis.conf
fi
fi
# nptdate cn.pool.ntp.org
if isCmdExist ntpdate; then
echoInfo "sync time..."
ntpdate cn.pool.ntp.org
fi