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",
"--net=host"
],
"remoteUser": "root",
"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": "sed -i 's/\\r$//' .devcontainer/pre-create.sh && /bin/bash .devcontainer/pre-create.sh",
"postCreateCommand": "sed -i 's/\\r$//' .devcontainer/post-create.sh && /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
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
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
137 changes: 137 additions & 0 deletions .devcontainer/pre-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#!/bin/bash

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

echo "Checking LMS service status..."

# Skip LMS checks on non-Linux hosts.
if [[ "$(uname -s)" != "Linux" ]]; then
echo "Non-Linux host detected; skipping LMS service check."
exit 0
fi

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

prompt_timeout() {
local msg="$1"
local sec=10
USER_INPUT=""
while [ $sec -gt 0 ]; do
echo -ne "\r$msg (timeout: ${sec}s) "
if read -t 1 USER_INPUT; then
echo ""
return 0
fi
((sec--))
done
echo ""
USER_INPUT="n"
}

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."

prompt_timeout "Do you want to start it? (y/n) [n]"
answer="$USER_INPUT"

if [[ "$answer" =~ ^[Yy]$ ]]; then
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
else
echo "Skipping LMS start. Proceeding with devcontainer creation..."
exit 0
fi
fi

echo "LMS service not found."

prompt_timeout "Do you want to install and start it? (y/n) [n]"
answer="$USER_INPUT"

if [[ "$answer" =~ ^[Yy]$ ]]; then
# Proceed with installation
echo "Proceeding with installation..."
else
echo "Skipping LMS installation. Proceeding with devcontainer creation..."
exit 0
fi

# 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 \
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 .

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
42 changes: 42 additions & 0 deletions .devcontainer/standard/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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, only Lms supported)",
// 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:}"
},
"postCreateCommand": "sed -i 's/\\r$//' .devcontainer/post-create.sh && /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"
}
}
}
}