Skip to content

Commit 6e2bec3

Browse files
authored
Merge pull request #36 from thin-edge/feat-bootstrap-improvements
feat: add bootstrapping options
2 parents 0e77bcd + 930239c commit 6e2bec3

File tree

25 files changed

+488
-103
lines changed

25 files changed

+488
-103
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ src/tedge/bin/tedge
99
tmp/
1010
/tedge-*
1111
binaries/zig-mosquitto/
12+
log.html
13+
output.xml
14+
report.html

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python3",
3+
"robot.language-server.python": "${workspaceFolder}/.venv/bin/python3",
4+
"robot.python.executable": "${workspaceFolder}/.venv/bin/python3",
5+
"robot.pythonpath": [
6+
"${workspaceFolder}/tests/RobotFramework/.venv/bin/python3"
7+
],
8+
"python.envFile": "${workspaceFolder}/.env"
9+
}

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ wget -q -O - https://raw.githubusercontent.com/thin-edge/tedge-standalone/main/i
4444
curl -fsSL https://raw.githubusercontent.com/thin-edge/tedge-standalone/main/install.sh | sh -s -- --install-path /data
4545
```
4646

47-
Then, follow the instructions printed out on the console to bootstrap (configure) and then start the services. However if you are planning on using Cumulocity's basic authentication, then you need to run the following section before running the `bootstrap.sh` script.
47+
Then, follow the instructions printed out on the console to bootstrap (configure) and then start the services.
4848

4949
### Install without wget/curl
5050

@@ -66,11 +66,24 @@ Before running the `bootstrap.sh` script, you will need to set the device's cred
6666
For example, if you installed thin-edge.io under `/data` then you can set the credentials using the following snippet:
6767
6868
```sh
69-
cat <<EOT > /data/tedge/credentials.toml
69+
./bootstrap.sh --device-user "{tenant}/device_{external_id}" --device-password "{password}" --c8y-url {CumulocityURL}
70+
71+
# example
72+
./bootstrap.sh --device-user "t12345/device_tedge-abcdef" --device-password 'ex4amp!3' --c8y-url example.cumulocity.com
73+
```
74+
75+
Alternative, you can set the `credentials.toml` under the installed directory, e.g. `/data/tedge/credentials.toml` (if you're using the default installation directory):
76+
77+
```sh
7078
[c8y]
7179
username = "{tenant}/device_{external_id}"
7280
password = "{password}"
73-
EOT
81+
```
82+
83+
For [go-c8y-cli](https://goc8ycli.netlify.app/) users, you can register a device and generate randomized credentials using the following command. The device's username (including tenant) and password will be printed out on the console, and then you can provide the values to the `bootstrap.sh` script.
84+
85+
```sh
86+
c8y deviceregistration register-basic --id tedge-abcdef
7487
```
7588
7689
## Automatically starting services
@@ -103,7 +116,7 @@ Assuming you have already launched the custom `runsvdir` instance, the following
103116
Before running any of the command you need to load the environment variables using the following one-liner:
104117
105118
```sh
106-
set -a; . /data/tedge/env; set +a
119+
. /data/tedge/env
107120
```
108121
109122
### Start services

docs/Luckfox.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Install thin-edge.io standalone on a Luckfox Pico device using the following ste
5959

6060
```sh
6161
load_tedge_env() {
62-
set -a; . /opt/tedge/env; set +a;
62+
. /opt/tedge/env;
6363
}
6464
load_tedge_env
6565
```

install.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ EXAMPLE
3636
# Install under a custom location but install the non-upx'd versions
3737
3838
$0 --install-path /home/etc --overwrite
39-
# Install under a custom location and overrite any existing configuration files
39+
# Install under a custom location and overwrite any existing configuration files
4040
4141
$0 --file ./tedge-standalone-arm64.tar.gz --install-path /home/root
4242
# Install from a manually downloaded file and install under a custom path
@@ -183,11 +183,26 @@ main() {
183183
echo
184184
echo "Configure and start thin-edge.io using the following command:"
185185
echo
186-
echo " $INSTALL_PATH/tedge/bootstrap.sh"
186+
echo Option 1: Register using Cumulocity Certificate Authority
187+
echo
188+
echo " $INSTALL_PATH/tedge/bootstrap.sh --ca c8y --c8y-url 'example.cumulocity.com'"
189+
echo
190+
echo " $INSTALL_PATH/tedge/bootstrap.sh --ca c8y --c8y-url 'example.cumulocity.com' --device-id tedge01"
191+
echo
192+
echo
193+
echo Option 2: Register using Cumulocity self-signed certificate
194+
echo
195+
echo " $INSTALL_PATH/tedge/bootstrap.sh --ca c8y --c8y-url 'example.cumulocity.com' --device-id tedge01"
196+
echo
197+
echo
198+
echo "Option 3: Register using Cumulocity Basic Authorization Credentials (pre-registered)"
199+
echo
200+
echo " $INSTALL_PATH/tedge/bootstrap.sh --c8y-url 'example.cumulocity.com' --device-user 't12345/device_tedge01' --device-password 'ex4ampl3['"
201+
echo
187202
echo
188203
echo Import the shell environment using:
189204
echo
190-
echo " set -a; . '$INSTALL_PATH/tedge/env'; set +a"
205+
echo " . '$INSTALL_PATH/tedge/env'"
191206
echo
192207
}
193208

justfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,17 @@ PACKAGE := "tedge-standalone"
44
# Build static binaries and create the tarball package
55
build target target_name *args:
66
./scripts/build.sh --target {{target}} --target-name {{target_name}} --package {{PACKAGE}} {{args}}
7+
8+
# Build artifacts to be used in system tests
9+
build-test:
10+
just build aarch64-linux-musl arm64-noupx --skip-upx
11+
just build aarch64-linux-musl arm64
12+
13+
# Install python virtual environment
14+
venv:
15+
[ -d .venv ] || python3 -m venv .venv
16+
./.venv/bin/pip3 install -r tests/requirements.txt
17+
18+
# Run tests
19+
test *args='':
20+
./.venv/bin/python3 -m robot.run --outputdir output {{args}} tests

src/tedge/bin/tedgectl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ export SVDIR="${SVDIR:-/run/services}"
55
export RUNIT_SRCDIR="${RUNIT_SRCDIR:-@CONFIG_DIR@/services}"
66

77
if [ -f @CONFIG_DIR@/env ]; then
8-
set -a
98
# shellcheck disable=SC1091
109
. @CONFIG_DIR@/env
11-
set +a
1210
fi
1311

1412
manage_runit() {
@@ -20,9 +18,17 @@ manage_runit() {
2018
# Check if runit instance is active
2119
pgrep -f "runsvdir -P $SVDIR" >/dev/null 2>&1
2220
;;
23-
start) sv start "$name" ;;
24-
stop) sv stop "$name" ;;
25-
restart) sv restart "$name" ;;
21+
start)
22+
manage_runit enable "$name" ||:
23+
sv start "$name" ||:
24+
;;
25+
stop)
26+
sv stop "$name" ||:
27+
;;
28+
restart)
29+
manage_runit enable "$name" ||:
30+
sv restart "$name" ||:
31+
;;
2632
enable)
2733
if [ ! -d "$SVDIR/$name" ]; then
2834
ln -s "$RUNIT_SRCDIR/$name" "$SVDIR/"

0 commit comments

Comments
 (0)