Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .devcontainer/mei/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "Go (MEI Device - Linux host)",
"image": "mcr.microsoft.com/devcontainers/go:1.25-trixie",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"installOhMyZsh": true,
"installOhMyZshConfig": true,
"configureZshAsDefaultShell": true
}
},
"runArgs": [
"--device",
"/dev/mei0",
"--privileged",
Comment thread
nbmaiti marked this conversation as resolved.
"--net=host"
],
"remoteUser": "root",
Comment thread
nbmaiti marked this conversation as resolved.
"forwardPorts": [
8181
],
"containerEnv": {
"HTTP_PROXY": "${localEnv:HTTP_PROXY:}",
"HTTPS_PROXY": "${localEnv:HTTPS_PROXY:}",
"NO_PROXY": "${localEnv:NO_PROXY:}",
"http_proxy": "${localEnv:http_proxy:}",
"https_proxy": "${localEnv:https_proxy:}",
"no_proxy": "${localEnv:no_proxy:}"
},
"initializeCommand": "DEVCONTAINER_LMS_SETUP=${localEnv:DEVCONTAINER_LMS_SETUP:off} /bin/bash .devcontainer/pre-create.sh",
"postCreateCommand": "/bin/bash .devcontainer/post-create.sh",
"customizations": {
"vscode": {
"extensions": [
"waderyan.gitblame",
"shd101wyy.markdown-preview-enhanced",
"artisanbytecrafter.poptheme",
"ryu1kn.text-marker",
"anoff.theme-monokai-light"
],
"settings": {
"workbench.colorTheme": "Monokai Light",
"workbench.preferredLightColorTheme": "Monokai Light"
}
}
}
}
32 changes: 32 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e

# Unset empty proxy variables
for var in HTTP_PROXY HTTPS_PROXY NO_PROXY http_proxy https_proxy no_proxy; do
eval v="\${$var}"
if [ -z "$v" ]; then unset $var; fi
Comment thread
nbmaiti marked this conversation as resolved.
done

# Strip all trailing '/' or '\\' from proxy URLs for apt config
strip_trailing_slash() {
local url="$1"
# Remove all trailing / or \
url="${url%%*(/|\\)}"
# Fallback for Bash < 4.0 (no extglob): use sed
Comment thread
nbmaiti marked this conversation as resolved.
echo "$url" | sed 's%[\\/]*$%%'
}

if [ -n "$HTTP_PROXY" ] || [ -n "$http_proxy" ] || [ -n "$HTTPS_PROXY" ] || [ -n "$https_proxy" ]; then
echo "Configuring apt to use proxy..."
sudo mkdir -p /etc/apt/apt.conf.d
# Remove all trailing / or \\ from proxy URLs
apt_http_proxy="$(strip_trailing_slash "${HTTP_PROXY:-${http_proxy:-}}")"
apt_https_proxy="$(strip_trailing_slash "${HTTPS_PROXY:-${https_proxy:-}}")"
sudo tee /etc/apt/apt.conf.d/99proxy > /dev/null <<EOF
Acquire::http::Proxy "$apt_http_proxy";
Acquire::https::Proxy "$apt_https_proxy";
EOF
fi

go install github.com/air-verse/air@latest
go install github.com/go-delve/delve/cmd/dlv@latest
Comment thread
nbmaiti marked this conversation as resolved.
127 changes: 127 additions & 0 deletions .devcontainer/pre-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/bin/bash

# This script runs on the host machine BEFORE the container is created.
# It ensures the Intel LMS service is running.

# Opt-in gate for host-side privileged LMS setup.
# Values:
# off (default): skip host LMS checks/changes
# start : start LMS if already installed; never install
# install : install LMS if missing, then start
# on : backward-compatible alias for "install"
LMS_SETUP_MODE="${DEVCONTAINER_LMS_SETUP:-off}"

# Keep compatibility with previous docs.
if [ "$LMS_SETUP_MODE" = "on" ]; then
LMS_SETUP_MODE="install"
fi

if [ "$LMS_SETUP_MODE" = "off" ]; then
echo "Skipping LMS host setup (DEVCONTAINER_LMS_SETUP=$LMS_SETUP_MODE)."
exit 0
fi

if [ "$LMS_SETUP_MODE" != "start" ] && [ "$LMS_SETUP_MODE" != "install" ]; then
echo "Invalid DEVCONTAINER_LMS_SETUP value: $LMS_SETUP_MODE"
echo "Supported values: off, start, install"
exit 0
fi

echo "Checking LMS service status..."

check_lms_active() {
if sudo systemctl is-active --quiet lms; then
echo "LMS service is active."
return 0
else
return 1
fi
}

if check_lms_active; then
exit 0
fi

echo "LMS service is not active."

# Check if the service unit exists
if sudo systemctl list-unit-files | grep -q "^lms.service"; then
echo "LMS service exists but is inactive."

echo "Attempting to start LMS..."
sudo systemctl start lms

# Wait for up to 10 seconds for service to start
for i in {1..10}; do
sleep 1
if check_lms_active; then
echo "LMS started successfully."
exit 0
fi
done

echo "ERROR: Failed to start LMS service."
sudo systemctl status lms
exit 1
fi

echo "LMS service not found."

if [ "$LMS_SETUP_MODE" = "start" ]; then
echo "LMS is missing and DEVCONTAINER_LMS_SETUP=start. Skipping install."
exit 0
fi

echo "Proceeding with LMS install because DEVCONTAINER_LMS_SETUP=install..."

# Install dependencies
echo "Installing dependencies..."
# Update apt cache first (optional but recommended before installing)
# sudo apt-get update
sudo apt-get install -y cmake libglib2.0-dev libcurl4-openssl-dev libxerces-c-dev \
Comment thread
nbmaiti marked this conversation as resolved.
libnl-3-dev libnl-route-3-dev libxml2-dev libidn2-0-dev libace-dev build-essential git

# Prepare working directory
WORK_DIR="$HOME/lms_setup"
mkdir -p "$WORK_DIR"
echo "Working directory: $WORK_DIR"

if [ -d "$WORK_DIR/lms" ]; then
echo "Cleaning up previous LMS source..."
sudo rm -rf "$WORK_DIR/lms"
fi

# Clone LMS
echo "Cloning LMS repository..."
git clone https://github.com/intel/lms.git "$WORK_DIR/lms"

# Build LMS
echo "Building LMS..."
cd "$WORK_DIR/lms"
mkdir -p build
cd build

# Using dynamic paths based on where we verified the clone
sudo cmake -S .. -B .
sudo cmake --build .
Comment thread
nbmaiti marked this conversation as resolved.

echo "Installing LMS..."
sudo make install

echo "Starting LMS service..."
sudo systemctl daemon-reload
sudo systemctl enable lms
sudo systemctl start lms

# Verify installation
for i in {1..10}; do
sleep 1
if check_lms_active; then
echo "LMS installed and started successfully."
exit 0
fi
done

echo "ERROR: Failed to start LMS after installation."
sudo systemctl status lms
exit 1
Comment thread
nbmaiti marked this conversation as resolved.
46 changes: 46 additions & 0 deletions .devcontainer/standard/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go
{
"name": "Go (Standard - no MEI device)",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/go:1.25-trixie",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"installOhMyZsh": true,
"installOhMyZshConfig": true,
"configureZshAsDefaultShell": true
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
8181
],
"containerEnv": {
"HTTP_PROXY": "${localEnv:HTTP_PROXY:}",
"HTTPS_PROXY": "${localEnv:HTTPS_PROXY:}",
"NO_PROXY": "${localEnv:NO_PROXY:}",
"http_proxy": "${localEnv:http_proxy:}",
"https_proxy": "${localEnv:https_proxy:}",
"no_proxy": "${localEnv:no_proxy:}"
},
// Use 'initializeCommand' to run commands on the host before the container is created.
// "initializeCommand": "echo 'This runs on the host before container creation'",
"initializeCommand": "DEVCONTAINER_LMS_SETUP=${localEnv:DEVCONTAINER_LMS_SETUP:off} /bin/bash .devcontainer/pre-create.sh",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "/bin/bash .devcontainer/post-create.sh",
"customizations": {
"vscode": {
"extensions": [
"waderyan.gitblame",
"shd101wyy.markdown-preview-enhanced",
"artisanbytecrafter.poptheme",
"ryu1kn.text-marker"
],
"settings": {
"workbench.colorTheme": "Pop Light"
}
}
}
}
Loading