-
Notifications
You must be signed in to change notification settings - Fork 14
/
gluster-lic-register.in
executable file
·81 lines (60 loc) · 1.32 KB
/
gluster-lic-register.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
#!/bin/bash
#
# chkconfig: 35 99 12
# description: Register this instance with Gluster
#
ME=$(basename $0);
function show_help()
{
cat <<EOF
Gluster Licensing Tools, Version @PACKAGE_VERSION@.
Usage: $ME [-h]
Register AMI ID with Gluster
Miscellaneous:
-h display this help and exit
Example:
$ME
EOF
}
function gluster_pingback()
{
sleep 5; # wait for metastrap
macid=$(cat /.epoch);
region=$(wget -q -O - http://169.254.169.254/latest/meta-data/placement/availability-zone);
if [ -z "$region" ]; then
return;
fi
if [ -f @prefix@/etc/ec2-pk.pem ]; then
# this instance got meta-strapped, so has to be an added node
Added=1
else
Added=0
fi
md5=$(echo -n $macid | md5sum -);
url="http://www.gluster.com/check4updates.php?AMIID=$macid&Region=$region&AddNode=$Added&secret=$md5";
wget -q $url -O /dev/null;
echo $url > /lic/.registered;
}
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
if [ ! -f /.default -o -f /lic/.registered ]; then
exit 0;
fi
gluster_pingback &
}
main "$@";