-
Notifications
You must be signed in to change notification settings - Fork 173
/
Copy pathdeploy.sh
executable file
·103 lines (89 loc) · 3.64 KB
/
deploy.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
#!/bin/bash
#
# Copyright 2023 PayPal Inc.
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cd "$(dirname "$0")"
###############################################################
### BUILDTOP is github root folder, JUNO_BUILD_DIR is ######
### binary code folder. Sample: BUILDTOP=~/github/juno ######
###############################################################
if [ "$BUILDTOP" == "" ]; then
echo "JUNO_BUILD_DIR and BUILDTOP required but not defined"
exit
elif [ "$JUNO_BUILD_DIR" == "" ]; then
export JUNO_BUILD_DIR=$BUILDTOP/release-binary/code-build
fi
# Default action of deploy is to start services
# To stop the services call ./deploy.sh stop
[[ ! -z $1 ]] && svc=$1
: ${action:=${svc:="start"}}
group=`/usr/bin/id -gn`
TAR='/bin/tar xvzf'
RM='/bin/rm -rf'
GO_VERSION=1.18.2
if [ ! -d deploy ]; then
mkdir -p deploy
fi
cd deploy
# copy onfig, shutdown/start, binary etc. sript or files to each package folder
for i in junoclustercfg junoclusterserv junoserv junostorageserv;
do
if [ ! -d $i ]; then #create package folder
mkdir -p $i
elif [ -f ${i}/shutdown.sh ]; then #stop service if it is up before starting
$i/shutdown.sh
fi
cp $BUILDTOP/package_config/package/${i}/script/*.sh $i
cp $BUILDTOP/package_config/script/postuninstall.sh $i
cp $BUILDTOP/package_config/script/logstate.sh $i
cp $BUILDTOP/package_config/script/log.sh $i
$BUILDTOP/package_config/package/${i}/build.sh
cp $BUILDTOP/package_config/package/${i}/config-${i}* $i
$RM $BUILDTOP/package_config/package/${i}/config-${i}*
done
cp $JUNO_BUILD_DIR/etcdsvr.py junoclusterserv
cp $JUNO_BUILD_DIR/etcdctl junoclusterserv
cp $JUNO_BUILD_DIR/etcdsvr_exe junoclusterserv
cp $JUNO_BUILD_DIR/join.sh junoclusterserv
cp $JUNO_BUILD_DIR/status.sh junoclusterserv
cp $JUNO_BUILD_DIR/tool.py junoclusterserv
cp $JUNO_BUILD_DIR/clustermgr junoclustercfg
cp $JUNO_BUILD_DIR/junocfg junoclustercfg
cp $JUNO_BUILD_DIR/storageserv junostorageserv
cp $JUNO_BUILD_DIR/dbcopy junostorageserv
cp $JUNO_BUILD_DIR/dbscanserv junostorageserv
cp -r $BUILDTOP/package_config/package/junoserv/secrets/ junoserv
cp $JUNO_BUILD_DIR/proxy junoserv
if [ ${action} == "start" ]; then
####### install all four packages, start up junostorageserv/junoserv service ########
prefix=$BUILDTOP/script/deploy
junoclusterserv/postinstall.sh junoclusterserv etcdsvr $prefix $group
junoclustercfg/postinstall.sh junoclustercfg junoclustercfg $prefix $group
junostorageserv/postinstall.sh junostorageserv storageserv $prefix $group
junoserv/postinstall.sh junoserv proxy $prefix $group
elif [ ${action} == "stop" ]; then
####### start up junostorageserv/junoserv service ########
junoserv/shutdown.sh
junostorageserv/shutdown.sh
junoclusterserv/shutdown.sh
fi
cd $BUILDTOP/script #get out from deploy folder, into script folder to create test link
### create soft link to test folder #####
if [ ! -d test ]; then
ln -s $BUILDTOP/test test
fi