Skip to content

Commit

Permalink
kraken: Add default extensions setup in install
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoMario109 authored and patrickelectric committed Jun 4, 2024
1 parent 0629b3c commit 8d467c3
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 3 deletions.
12 changes: 9 additions & 3 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# Set desired version to be installed
VERSION="${VERSION:-master}"
GITHUB_REPOSITORY=${GITHUB_REPOSITORY:-bluerobotics/blueos-docker}
DOCKER_USER=${DOCKER_USER:-$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)}
REMOTE="${REMOTE:-https://raw.githubusercontent.com/${GITHUB_REPOSITORY}}"
ROOT="$REMOTE/$VERSION"

alias curl="curl --retry 6 --max-time 15 --retry-all-errors"

# Additional options
Expand Down Expand Up @@ -196,12 +198,16 @@ command -v raspi-config && (
)

echo "Downloading bootstrap"
BLUEOS_BOOTSTRAP="bluerobotics/blueos-bootstrap:$VERSION" # Use current version
BLUEOS_CORE="bluerobotics/blueos-core:$VERSION" # We don't have a stable tag yet
BLUEOS_BOOTSTRAP="$DOCKER_USER/blueos-bootstrap:$VERSION" # Use current version
BLUEOS_CORE="$DOCKER_USER/blueos-core:$VERSION" # We don't have a stable tag yet
BLUEOS_FACTORY="bluerobotics/blueos-core:factory" # used for "factory reset"

docker pull $BLUEOS_BOOTSTRAP
docker pull $BLUEOS_CORE

# Set up default extensions
curl -fsSL $ROOT/install/kraken/set_default_extensions.sh | bash

# Use current release version for factory fallback
docker image tag $BLUEOS_CORE $BLUEOS_FACTORY

Expand Down Expand Up @@ -245,4 +251,4 @@ echo "You can access after the reboot:"
echo "- The computer webpage: http://blueos-avahi.local"
echo "- The ssh client: $USER@blueos-avahi.local"
echo "System will reboot in 10 seconds."
sleep 10 && reboot
sleep 10 && reboot
77 changes: 77 additions & 0 deletions install/kraken/set_default_extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env bash

# Extensions data fetch, use for Extensions that are synced by some online source

COCKPIT_RELEASE_URL="https://api.github.com/repos/bluerobotics/cockpit/releases/latest"
MAJOR_TOM_RELEASE_URL="https://kipulwyil1.execute-api.us-east-1.amazonaws.com/api/blueos/install"

response=$(curl -fsSL $COCKPIT_RELEASE_URL)

if [[ $response =~ \"tag_name\":\ *\"([^\"]+)\" ]]; then
cockpit_tag_name="${BASH_REMATCH[1]}"
echo "Using cockpit tag: $cockpit_tag_name"
else
echo "Could not find the latest release tag of Cockpit."
exit 1
fi

major_tom_install_data=$(curl -fsSL $MAJOR_TOM_RELEASE_URL)

if [[ $major_tom_install_data =~ \"docker\":\ *\"([^\"]+)\" ]]; then
major_tom_docker="${BASH_REMATCH[1]}"
else
echo "Could not find the latest release docker value of Major Tom."
exit 1
fi

if [[ $major_tom_install_data =~ \"tag\":\ *\"([^\"]+)\" ]]; then
major_tom_tag="${BASH_REMATCH[1]}"
else
echo "Could not find the latest release tag value of Major Tom."
exit 1
fi

echo "Using major tom: $major_tom_docker:$major_tom_tag"

# Images pulling

BLUEROBOTICS_COCKPIT_EXT="bluerobotics/cockpit:$cockpit_tag_name"
BLUEROBOTICS_MAJOR_TOM_EXT="$major_tom_docker:$major_tom_tag"

docker pull $BLUEROBOTICS_COCKPIT_EXT
docker pull $BLUEROBOTICS_MAJOR_TOM_EXT

# Settings creation

SETTINGS_BASE_DIR="/root/.config/blueos/kraken"

mkdir -p "${SETTINGS_BASE_DIR}"

# Check if the directory creation was successful
if [[ ! -d "${SETTINGS_BASE_DIR}" ]]; then
echo "Failed to create directory ${SETTINGS_BASE_DIR}"
exit 1
fi

# Creates kraken V2 settings with default extensions

cat > "${SETTINGS_BASE_DIR}/settings-2.json" <<EOF
{
"VERSION": 2,
"extensions": [
{
"docker": "bluerobotics/cockpit",
"enabled": true,
"identifier": "bluerobotics.cockpit",
"name": "Cockpit",
"permissions": "{\"ExposedPorts\":{\"8000/tcp\":{}},\"HostConfig\":{\"PortBindings\":{\"8000/tcp\":[{\"HostPort\":\"\"}]}}}",
"tag": "$cockpit_tag_name",
"user_permissions": ""
},
$major_tom_install_data
],
"manifests": []
}
EOF

echo "Default extensions settings configured successfully."

0 comments on commit 8d467c3

Please sign in to comment.