Skip to content

Commit 69b95d3

Browse files
dolkeinDigital-Larry
authored andcommitted
[RC-906] initial update for Auto Registration (#47)
* initial update for Auto Registration * Make bourn shell * Added API identity * Added OEM overrides (#48) * Added OEM overrides in one file (#49) Approved for further testing. * RC 949 integrate oem settings (#50) * Added OEM ovewrrides in one file * Fixed show API version * Fixed registration key * RC-949 OEM fixed ipv6 route (#51) * [RC-979] Added call to device ready API after provisioning (#53) * Added call to device ready API after provisioning * Update connectd/usr/bin/connectd_control Co-Authored-By: Dana Woodman <[email protected]> * CTD-397 handle ubuntu oem settings (#54) * Adjust oem for Ubuntu * attempt to fix CI test issue * fix typo * RC 996 add claimcode (#55) * Added claimcode to device ready * Minor bug on provisioning * RC-1002 adding auto-registration to CI testing * RC-1002 adding auto-registration to CI testing (#57) Merging CI to RC-906 branch. * RC-906 update control file and version prior to merge to master to allow beta testing of auto registration. * RC-906 updated changelog. * RC-906 cleared values for VERSION and PLATFORM in connectd_options. They are set during the build process.
1 parent 37dca40 commit 69b95d3

File tree

13 files changed

+677
-61
lines changed

13 files changed

+677
-61
lines changed

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818
- restore_cache:
1919
keys:
2020
- cache-{{ .Branch }}-{{ checksum "package-lock.json" }}
21+
- run:
22+
name: apt update
23+
command: sudo apt-get update
2124
- run:
2225
name: Install lintian
2326
command: sudo apt-get install lintian

connectd/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: connectd
2-
Version: 2.3.17
2+
Version: 3.0.6
33
Section: non-free/net
44
Priority: optional
55
Homepage: https://remote.it

connectd/etc/connectd/oem_settings

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/bin/sh
2+
#
3+
# remote.it OEM Settings manages remote.it settings to register OEM devices
4+
#
5+
# not called directly. functions are called by connectd_control
6+
#
7+
# will store info in CONNECTD_DIR
8+
#
9+
# remot3.it, Inc. : https://remote.it
10+
#
11+
12+
oemGetSystemId()
13+
{
14+
15+
cpuid=$(awk '/Serial/ {print $3}' /proc/cpuinfo | sed 's/://g')
16+
17+
##
18+
## Override default system ID for this platform
19+
#cpuid=$(oemGetDefaultHardwareId)
20+
21+
# check for legal value
22+
if [ ${#cpuid} -ge 1 ]; then
23+
continue
24+
else
25+
echo ""
26+
echo "ACTION: system ID is not set properly. Fix oemGetSystemId() in /etc/connectd/oem_settings "
27+
fi
28+
29+
# return the System ID
30+
echo $cpuid
31+
32+
}
33+
34+
oemGetDefaultHardwareId()
35+
{
36+
37+
#
38+
# This method gets the hardware ID based on the default LAN MAC address
39+
# You can overide the network interface below for a custom configuration for your platform
40+
41+
# get the default interface
42+
interface=$(oemGetInterface)
43+
44+
##
45+
## Override the default interface - change and uncomment the assignment below
46+
## RPi interfaces: eth0, wlan0
47+
## Ubuntu interfaces: enp3s0 wlp2s0
48+
#interface='eth0'
49+
#interface='enp3s0'
50+
51+
# get the adapter MAC
52+
if [ -f "/sys/class/net/$interface/address" ]; then
53+
hw_mac=$(cat /sys/class/net/$interface/address | sed 's/://g')
54+
else
55+
echo "ACTION: hardware ID is not set properly. Fix oemGetDefaultHardwareId() in /etc/connectd/oem_settings "
56+
fi
57+
58+
echo $hw_mac
59+
60+
}
61+
62+
oemGetDefaultRegistrationKey()
63+
{
64+
65+
##
66+
## Override the default interface - change the assignment below
67+
## RPi interfaces: eth0, wlan0
68+
## Ubuntu interfaces: enp3s0 wlp2s0
69+
70+
## must be set to something for your platform - default is for RPi
71+
interface='wlan0'
72+
#interface='wlp2s0'
73+
74+
# get the adapter MAC
75+
if [ -f "/sys/class/net/$interface/address" ]; then
76+
rk_mac=$(cat /sys/class/net/$interface/address | sed 's/://g')
77+
else
78+
echo "ACTION: registration key is not set properly. Fix oemGetDefaultRegistrationKey() in /etc/connectd/oem_settings "
79+
fi
80+
81+
echo $rk_mac
82+
83+
}
84+
85+
oemGetTCPServices()
86+
{
87+
88+
tcp=$(netstat -antp 2>/dev/null | grep 0.0.0.0: | awk '{ print $4 }' | awk -F':' '{print $2}' | xargs | sed -e 's/ /,/g')
89+
90+
echo $tcp
91+
92+
}
93+
94+
oemGetOSLabel()
95+
{
96+
97+
# return the OS label
98+
os=$(uname -a)
99+
echo $os
100+
101+
}
102+
103+
oemGetInterface()
104+
{
105+
106+
#
107+
# This method returns the default interface use for grabbing the hardware ID MAC address.
108+
#
109+
110+
# host we want to "reach"
111+
host=google.com
112+
113+
# get the ip of that host (works with dns and /etc/hosts. In case we get
114+
# multiple IP addresses, we just want one of them
115+
host_ip=$(getent ahosts "$host" | awk '{print $1; exit}')
116+
117+
# only list the interface used to reach a specific host/IP. We only want the part
118+
# between dev and src (use grep for that)
119+
interface=$(ip route get "$host_ip" | grep -Po '(?<=(dev )).*(?= src| proto)' | awk '{print $1; exit}')
120+
121+
echo $interface
122+
123+
}
124+
125+
oemGetWebPath()
126+
{
127+
128+
# return the default web path. Override if different
129+
echo /var/www/html
130+
131+
}
132+
133+
#
134+
# Hook for OEM to add a function to save configuration changes
135+
# OEM must add the file in $BIN_DIR, called connectd_save_config
136+
# it must be set to be executable (chmod +x)
137+
#
138+
139+
oemSaveConfig()
140+
{
141+
# hook for OEM to add platform specific call to save configuration changes
142+
if [ -e "$BIN_DIR"/connectd_save_config ]; then
143+
"$BIN_DIR"/connectd_save_config
144+
fi
145+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
#
3+
# remote.it Change Identity Script allows overriding hardware ID and registration key
4+
# identity settings.
5+
#
6+
# NOTE: This is a development script and not used in a production device
7+
#
8+
# connectd_change_identity
9+
#
10+
# will store info in CONNECTD_DIR
11+
#
12+
# remot3.it, Inc. : https://remote.it
13+
14+
# show the current configuration
15+
echo "Current configuration is ... "
16+
sudo connectd_control show
17+
18+
# ask for new settings and save them in well know files
19+
echo -n "Enter Hardware ID: "
20+
read answer
21+
echo $answer > /tmp/hwid.txt
22+
sudo mv /tmp/hwid.txt /etc/connectd/hardware_id.txt
23+
24+
echo -n "Enter Registration Key: "
25+
read answer
26+
echo $answer > /tmp/regkey.txt
27+
sudo mv /tmp/regkey.txt /etc/connectd/registration_key.txt
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/sh
2+
#
3+
# remote.it Check Production Readiness Script allows developers to know if the deviceis cloneable
4+
# and will help reset a device to make it ready for production
5+
#
6+
# NOTE: This is a development script and not used in a production device
7+
#
8+
# connectd_check_production_ready
9+
#
10+
# will alter contents in CONNECTD_DIR
11+
#
12+
# remot3.it, Inc. : https://remote.it
13+
14+
BASEDIR=
15+
CONNECTD_DIR="$BASEDIR"/etc/connectd
16+
# pick up global options, e.g. PLATFORM and API
17+
. "$CONNECTD_DIR"/oem_settings
18+
19+
# test for unique identifiers - status will emit on errors
20+
echo "CPU ID:"$(oemGetSystemId)
21+
echo "Hardware ID:"$(oemGetDefaultHardwareId)
22+
echo "Registration Key:"$(oemGetDefaultRegistrationKey)
23+
24+
DIRECTORY=/etc/connectd/services
25+
if [ -d "$DIRECTORY" ]; then
26+
echo "Issue: remote.it services folder exists"
27+
STATUS=0
28+
fi
29+
30+
DIRECTORY=/etc/connectd/pfiles
31+
if [ -d "$DIRECTORY" ]; then
32+
echo "Issue: remote.it provisioning folder exists"
33+
STATUS=0
34+
fi
35+
36+
DIRECTORY=/etc/connectd/dfiles
37+
if [ -d "$DIRECTORY" ]; then
38+
echo "Issue: remote.it configuration folder exists"
39+
STATUS=0
40+
fi
41+
42+
DIRECTORY=/etc/connectd/active
43+
if [ -d "$DIRECTORY" ]; then
44+
echo "Issue: remote.it active service folder exists"
45+
STATUS=0
46+
fi
47+
48+
DIRECTORY=/etc/connectd/available
49+
if [ -d "$DIRECTORY" ]; then
50+
echo "Issue: remote.it available service folder exist"
51+
STATUS=0
52+
fi
53+
54+
if [ -f "/etc/connectd/bulk_identification_code.txt" ]; then
55+
bic=$(cat /etc/connectd/bulk_identification_code.txt)
56+
else
57+
echo "Issue: Bulk Identification Code missing"
58+
STATUS=0
59+
fi
60+
61+
if [ -z "$STATUS" ] ; then
62+
echo "Ok: device is cloneable for production"
63+
else
64+
echo "Issue: No device is not safe to clone for production."
65+
echo "ACTION: Use the sudo connectd_prepare_production command to ready this system"
66+
fi
67+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/sh
2+
#
3+
# remote.it Claimcode is for authorizing local access. The code is also sent in the
4+
# Device ready message for app and portal based claiming
5+
#
6+
# connectd_set_claimcode
7+
#
8+
# will alter contents in CONNECTD_DIR
9+
#
10+
# remot3.it, Inc. : https://remote.it
11+
12+
BASEDIR=
13+
CONNECTD_DIR="$BASEDIR"/etc/connectd
14+
# pick up global options, e.g. PLATFORM and API
15+
. "$CONNECTD_DIR"/oem_settings
16+
17+
if [ -f "/etc/connectd/hardware_id.txt" ]; then
18+
hwid=$(cat /etc/connectd/hardware_id.txt)
19+
else
20+
echo "Device not registered"
21+
exit
22+
fi
23+
24+
if [ "$1" = "get" ]; then
25+
26+
if [ -f "/etc/connectd/claimcode.txt" ]; then
27+
cc=$(cat /etc/connectd/claimcode.txt)
28+
echo "last claimcode is $cc"
29+
fi
30+
else
31+
32+
claimcode=$(awk -v min=10001 -v max=99999 'BEGIN{srand(); print int(min+rand()*(max-min+1))}')
33+
34+
if [ -f "/etc/connectd/hardware_id.txt" ]; then
35+
hwid=$(cat /etc/connectd/hardware_id.txt)
36+
echo $claimcode > /etc/connectd/claimcode.txt
37+
38+
DIRECTORY=$(oemGetWebPath)
39+
if [ -d "$DIRECTORY" ]; then
40+
if [ ! -d "/var/www/html/r3/$hwid" ]; then
41+
sudo mkdir /var/www/html/r3/$hwid
42+
fi
43+
echo '{"code":"'$claimcode'"}' > /var/www/html/r3/$hwid/claimcode.json
44+
fi
45+
echo $claimcode
46+
fi
47+
48+
fi

0 commit comments

Comments
 (0)