-
Notifications
You must be signed in to change notification settings - Fork 14
/
gluster-lic-request.in
executable file
·116 lines (85 loc) · 2.5 KB
/
gluster-lic-request.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
ME=$(basename $0);
function show_help()
{
cat <<EOF
Gluster Licensing Tools, Version @PACKAGE_VERSION@.
Usage: $ME [-h]
Generate license.req file.
Miscellaneous:
-h display this help and exit
Example:
$ME
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 no non-option argument.
if [ $# -ne 0 ]; 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= );
now=$(date '+%s');
environment="Virtual";
if [ -e @prefix@/etc/ec2-pk.pem ]; then
environment="AWS";
fi
exec 20>license.req;
count=0;
for server in $server_list localhost; do
echo -n "Querying $server ... ";
macid=$(ssh $server cat /.epoch);
if [ $? -ne 0 ]; then
echo "failed to get machine identity (skipping)";
continue
fi
hostname=$(ssh $server hostname --fqdn);
if [ $? -ne 0 ]; then
hostname=$(ssh $server hostname);
if [ $? -ne 0 ]; then
echo "failed to get hostname (skipping)";
continue
fi
fi
echo "($macid $hostname)"
echo "$macid $now $hostname $environment" >&20;
count=$(( $count + 1 ));
done
exec 20>&-;
cat <<EOF
================================================================================
A Gluster license request for $count machines has been written to -
./license.req
You may now submit this license request file at -
http://supportservices.gluster.com/
Or mail it as an email attachment to support@gluster.com.
Once you have obtained the signed license file (license.asc) you need
to copy it back into this machine and run the following command -
sh# gluster-lic-install ./license.asc
NOTE: Every time you 'peer probe' a new server into the cluster, you
need to repeat this process within 30 days of probing.
================================================================================
EOF
}
main "$@";