Skip to content

Instantly share code, notes, and snippets.

View reubenmiller's full-sized avatar

Reuben Miller reubenmiller

  • Hamburg, Germany
View GitHub Profile
@reubenmiller
reubenmiller / TEDGE_CHANGE_LOG_OUTPUT_FOLDER.md
Last active February 16, 2023 19:46
thin-edge.io: changing the log output folder

Changing thin-edge.io log output folder

By default thin-edge.io persists logs under the /var/log folder. On some devices the /var folder is volatile, which means that the folder is newly created after each device reboot.

Normally, the folder structure under /var/log is created by thin-edge.io during the installation process, but since the /var/log folder is deleted, some thin-edge.io services do not function as expected.

There are two main ways to solve this problem, they are listed below.

Option 1: Create a initialization service which runs before tedge-agent service

@reubenmiller
reubenmiller / lock-testcases.sh
Created February 17, 2023 15:54
Test cases to check tedge locking
#!/bin/sh
cleanup() {
sudo systemctl stop tedge-agent || true
sudo rm -f /run/lock/tedge-agent.lock
}
test_case_1() {
echo
echo "--------------------------------------------------------"
@reubenmiller
reubenmiller / README.md
Last active July 15, 2024 19:49
thin-edge.io install and bootstrap for thin-edge connected to AWS

Bootstrap thin-edge.io for AWS

The script is a convience script to get started with thin-edge.io and AWS as quick as possible.

By default thin-edge.io will only be installed if it is not already, but if you want to update to the latest version you can provide the --update flag.

For more details check the --help of the script.

Interactive mode

@reubenmiller
reubenmiller / bootstrap.sh
Last active March 2, 2023 17:39
thin-edge.io install/bootstrapping script
#!/bin/sh
set -e
# TODO:
# * Run stop_services if there is an actual update (e.g. check if apt-get will actually do something or not)
# * Look at using a nicer command console progresss bar: printf "\033c";
# * Sometimes restart some services is required to get everything to work, e.g.
# * systemctl restart tedge-mapper-c8y
# * systemctl restart tedge-agent
# * systemctl restart c8y-log-plugin
@reubenmiller
reubenmiller / README.md
Last active March 8, 2023 13:04
POC: tedge pki interface

PKI Device certificate interface example

There is a script called tedge-cert.sh which can be used to managed the certificate used by thin-edge.

The device.id (which will be used as the Common Name in the certificate) will be controlled by an environment variable (for now). So before using the tedge-cert.sh script, the environment variable needs to be set. Ideally this is done when creating the docker environment, or alternatively a dummy certificate can be created us

Certificate Management Interface

The following commands are supported by the tedge-cert.sh script.

@reubenmiller
reubenmiller / README.md
Last active March 24, 2023 13:30
Add signedoff-by message to all git commits via a git hook

Getting started

Add the following signedoff-by git hook using the following steps:

  1. Create a new file (from above) and add it to the project's git folder .git/hooks/commit-msg
  2. Make the hook executable
chmod +x .git/hooks/commit-msg
@reubenmiller
reubenmiller / example.sh
Created June 14, 2023 09:11
go-c8y-cli examples
c8y util repeat 3 | c8y devices create --template "{name: 'device_%04d' % input.index, uuid: _.Hex(24)}" --dry
c8y devices list --query "has(uuid)" | c8y identity create --template "{externalId: input.value.uuid, type: 'mytype'}" --dry
@reubenmiller
reubenmiller / deploy.sh
Last active June 26, 2023 06:13
example refactored deploy.sh script
#!/bin/bash
set -e
info () { echo "INFO $*" >&2; }
error () { echo "ERROR $*" >&2; }
print_usage() {
echo "
Deploy a Cumulocity IoT microservice from a github release url
@reubenmiller
reubenmiller / EDIT_MOSQUITTO_SYSTEMD_SERVICE.md
Last active July 17, 2023 13:56
How to edit mosquitto systemd service restart interval to fix dns resolution error on startup

Option 1: Override mosquitto systemd service

This solution relies on using systemd override functionality require allows additional settings to be applied to existing systemd configuration files without having to redefined the entire systemd service definition.

Editing the mosquitto systemd definition

  1. Edit the mosquitto service definition
@reubenmiller
reubenmiller / check-sysvinit-status.sh
Created August 8, 2023 05:43
Check a sysv init system to gather information about if tedge-agent can be run or not
#!/bin/sh
echo "------------ System info ------------"
uname -a
echo "sysvinit version: $(/sbin/init --version)"
echo
echo "----------- Checking setup -----------"
command -V service || echo "FAIL: service does not exist"
command -V start-stop-daemon || echo "WARN: start-stop-daemon does not exist, this is used by the service definitions currently"