forked from lunar-linux/lunar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuniqid.lunar
43 lines (32 loc) · 1.21 KB
/
uniqid.lunar
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
#!/bin/bash
# #
# uniqid.lunar - Make a unique id for tracking clients #
# #
############################################################
# #
# Copyright Fw systems LLC Under eitherGPL v2 or BSD Lic. #
# #
# Parts Copyrighted Stefan Wold 2013 under GPLv2 #
# #
############################################################
push_uniq_id() {
debug_msg "push_uniq_id ($@)"
if [ -z "$UNIQID" ]; then
create_uniq_id
fi
verbose_msg "registering \"$UNIQID\" with server"
wget -t 1 -T 5 -q -O - "lunar-linux.org/cgi-bin/houston?loc=$UNIQID"
}
create_uniq_id() {
local OS HASH IFACE
debug_msg "create_uniq_id ($@)"
if [ -n "$UNIQID" ]; then
return
fi
IFACE=$(ip route | awk '/^default/ {print $5}')
UNIQID=$(ip addr show $IFACE | awk '/link\/ether/ {print $2}' |\
tr 'A-Z' 'a-z' | md5sum | awk '{print $1}')
export UNIQID
verbose_msg "id(\"$IFACE\")=\"$UNIQID\""
set_local_config "UNIQID" "$UNIQID"
}