-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functionality to support app update
Signed-off-by: Mike Sul <[email protected]>
- Loading branch information
Showing
10 changed files
with
181 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
build/ | ||
.sysroot | ||
.init-rootfs | ||
.device | ||
.env | ||
CMakeLists.txt.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
docker run --rm -it -u $(id -u):$(id -g) -v $PWD:$PWD -w $PWD --env-file=$PWD/.env sotactl bash | ||
#!/bin/bash | ||
|
||
# Function to execute custom commands before exiting | ||
down() { | ||
docker compose --env-file=$PWD/docker/.env.dev -f $PWD/docker/docker-compose.yml down --remove-orphans | ||
} | ||
|
||
# Register the cleanup function to be called on EXIT | ||
trap down EXIT | ||
|
||
mkdir -p $PWD/.device | ||
docker compose --env-file=$PWD/docker/.env.dev -f $PWD/docker/docker-compose.yml run -e DEV_USER=$(id -u) -e DEV_GROUP=$(id -g) sotactl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FACTORY=$USER_FACTORY | ||
AUTH_TOKEN=$USER_TOKEN | ||
|
||
SOTA_DIR=$PWD/.device/sota | ||
DOCKER_DATA_ROOT=$PWD/.device/docker/data | ||
DOCKER_RUN_ROOT=$PWD/.device/docker/run | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"credHelpers": { | ||
"hub.foundries.io": "fio-helper" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version: '3.8' | ||
|
||
services: | ||
dockerd: | ||
image: docker:25.0-dind | ||
command: ["dockerd", "-H", "unix:///var/run/docker/docker.sock"] | ||
volumes: | ||
- ${DOCKER_DATA_ROOT}:/var/lib/docker | ||
- ${DOCKER_RUN_ROOT}:/var/run/docker | ||
privileged: true | ||
|
||
sotactl: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
|
||
image: sotactl:latest | ||
volumes: | ||
- "${PWD}:${PWD}" | ||
- ${DOCKER_RUN_ROOT}:/var/run/docker | ||
- ${SOTA_DIR}:/var/sota | ||
working_dir: "${PWD}" | ||
hostname: device | ||
user: "root" | ||
environment: | ||
- FACTORY=${FACTORY} | ||
- AUTH_TOKEN=${AUTH_TOKEN} | ||
- DOCKER_HOST=unix:///var/run/docker/docker.sock | ||
- SOTA_DIR=/var/sota | ||
- AKLITE_CONFIG_DIR=/var/sota | ||
- DOCKER_CONFIG=/usr/lib/docker | ||
depends_on: | ||
- dockerd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh -e | ||
|
||
# Use stderr for logging err output in libaktualizr | ||
export LOG_STDERR=1 | ||
SOTA_DIR="${SOTA_DIR-/var/sota}" | ||
|
||
LOGLEVEL="${CREDS_LOGLEVEL-4}" | ||
|
||
if [ "$1" = "get" ] ; then | ||
if [ ! -f ${SOTA_DIR}/sota.toml ] ; then | ||
echo "ERROR: Device does not appear to be registered under $SOTA_DIR" | ||
exit 1 | ||
fi | ||
server=$(grep -m1 '^[[:space:]]*server' ${SOTA_DIR}/sota.toml | cut -d\" -f2) | ||
if [ -z $server ] ; then | ||
server="https://ota-lite.foundries.io:8443" | ||
fi | ||
exec /usr/local/bin/aktualizr-get --loglevel $LOGLEVEL -u ${server}/hub-creds/ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
if [ -z $DEV_USER ] || [ -z $DEV_GROUP ]; then | ||
echo "DEV_USER and DEV_GROUP environment variables must be set." | ||
exit 1 | ||
fi | ||
|
||
# Create a group with the specified GID if it doesn't already exist | ||
if ! getent group $DEV_GROUP >/dev/null; then | ||
groupadd -g $DEV_GROUP devgrp | ||
fi | ||
|
||
# Create a user with the specified UID and GID if it doesn't already exist | ||
if ! getent passwd $DEV_USER >/dev/null; then | ||
useradd -u $DEV_USER -g $DEV_GROUP -m dev | ||
fi | ||
|
||
# Change ownership of the home directory to the appuser | ||
chown -R dev:devgrp /home/dev | ||
|
||
chown dev:devgrp /var/run/docker/docker.sock | ||
|
||
chown -R dev:devgrp /var/sota | ||
|
||
# Run the command as the created user | ||
exec gosu $DEV_USER:$DEV_GROUP "$@" |