-
Notifications
You must be signed in to change notification settings - Fork 14
/
gluster-lic-install.in
executable file
·87 lines (64 loc) · 1.59 KB
/
gluster-lic-install.in
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
#!/bin/bash
ME=$(basename $0);
function validate_license()
{
echo -n "Validating signature ... "
/lic/gpgv --keyring /lic/pubring.gpg "$1" >/dev/null 2>&1;
if [ $? -ne 0 ]; then
echo "FAILED."
exit 1;
fi
echo "done."
true
}
function show_help()
{
cat <<EOF
Gluster Licensing Tools, Version @PACKAGE_VERSION@.
Usage: $ME [-h] LICENSE-ASC-FILE
Install Gluster license. LICENSE-ASC-FILE is the license file
generated by Gluster Inc.
Miscellaneous:
-h display this help and exit
Example:
$ME license.asc
EOF
}
function main()
{
# Parse command line arguments.
while getopts :h OPT; do
case "$OPT" in
h)
show_help
exit 0
;;
\?)
# getopts issues an error message
echo "Invalid option: -$OPTARG"
show_help
exit 1
;;
esac
done
# Remove the switches we parsed above.
shift `expr $OPTIND - 1`
# We want only one non-option argument.
if [ $# -ne 1 ]; then
show_help
exit 1
fi
# if 'glusterd' is not running, the 'gluster peer status' will never succeed. hence
# we need a mechanism to get the server list with cli
#server_list=$(gluster peer status 2>/dev/null | grep -i hostname: | cut -f2 -d: );
server_list=$(cat /etc/glusterd/peers/* 2>/dev/null | grep -i hostname1= | cut -f2 -d= );
validate_license $1;
for server in $server_list localhost; do
scp "$1" $server:/lic/license.asc;
if [ $? -ne 0 ]; then
echo "Installing license on $server failed";
fi
done
@prefix@/bin/gluster-lic-info
}
main "$@";