forked from Seagate/cortx-s3server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iss3up.sh
executable file
·61 lines (56 loc) · 1.82 KB
/
iss3up.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
#
# Copyright (c) 2020 Seagate Technology LLC and/or its Affiliates
#
# Licensed 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.
#
# For any questions about this software or licensing,
# please email opensource@seagate.com or cortx-questions@seagate.com.
#
#!/bin/sh
MAX_S3_INSTANCES_NUM=20
if [ $# -gt 1 ];
then
echo "Invalid number of arguments passed to the script"
echo "Usage: sudo ./iss3up.sh [<instance number>]"
exit 1
fi
# s3 port configured in s3config.yaml
s3_port_from_config=`python -c '
import yaml;
print yaml.load(open("/opt/seagate/cortx/s3/conf/s3config.yaml"))["S3_SERVER_CONFIG"]["S3_SERVER_BIND_PORT"];
' | tr -d '\r\n'`
instance=1
if [ $# -eq 1 ]; then
if [[ $1 =~ ^[0-9]+$ ]] && [ $1 -le $MAX_S3_INSTANCES_NUM ]; then
instance=$1
else
echo "Invalid argument [$1], needs to be an integer <= $MAX_S3_INSTANCES_NUM"
exit 1
fi
fi
if [[ $instance -ne 0 ]]; then
s3port=$(($s3_port_from_config + $instance - 1))
s3_pid="$(ps aux | grep "/var/run/s3server.$s3port.pid" | grep -v grep)"
if [[ "$s3_pid" != "" ]]; then
s3_instance=$(netstat -an | grep $s3port | grep LISTEN)
if [[ "$s3_instance" != "" ]]; then
echo "s3 server is running and listening on $s3port"
else
echo "s3 server is stopped for port: $s3port"
exit 1
fi
else
echo "s3 server is stopped for port: $s3port"
exit 1
fi
fi