Skip to content

Commit 74c4532

Browse files
committed
Split up start scripts, prepare for Codespace prebuilds
1 parent 93b3daf commit 74c4532

32 files changed

Lines changed: 680 additions & 456 deletions

File tree

_dev/_devcontainers/cmk25/template/.devcontainer/devcontainer.json.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
}
2424
},
2525
"runArgs": ["--shm-size=1g"],
26-
"postCreateCommand": "bash .devcontainer/setup.sh",
26+
"onCreateCommand": "bash .devcontainer/oncreate.sh",
27+
"postCreateCommand": "bash .devcontainer/postcreate.sh",
2728
"remoteEnv": {
2829
"DISPLAY": ":1"
2930
},

examples/rf-python-varfiles/.devcontainer/setup.sh renamed to _dev/_devcontainers/cmk25/template/.devcontainer/oncreate.sh

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
2-
# .devcontainer/setup.sh — Runs once after the container is created.
3-
# Downloads RCC, builds the holotree environment, and configures VS Code.
2+
# .devcontainer/oncreate.sh — Runs once when the container image is built (prebuild-cached).
3+
# Downloads RCC, builds the holotree environment, installs the Checkmk agent and Firefox.
44

55
set -euo pipefail
66

@@ -40,29 +40,25 @@ step "Creating symlink ~/.rcc-env → ${SPACE_ROOT} ..."
4040
ln -sfn "${SPACE_ROOT}" "$HOME/.rcc-env"
4141
ok "~/.rcc-env → ${SPACE_ROOT}"
4242

43-
# ── Step 4: Add to PATH in ~/.bashrc ─────────────────────────────────────────
44-
step "Configuring PATH in ~/.bashrc ..."
45-
MARKER="# rcc-holotree-path"
46-
if grep -q "${MARKER}" "$HOME/.bashrc" 2>/dev/null; then
47-
info "PATH entry already present — skipping."
48-
else
49-
echo "${MARKER}" >> "$HOME/.bashrc"
50-
echo "export PATH=${SPACE_ROOT}/bin:\$PATH" >> "$HOME/.bashrc"
51-
ok "Added ${SPACE_ROOT}/bin to PATH"
52-
fi
43+
# ── Step 7: Install Checkmk agent ────────────────────────────────────────────
44+
step "Installing Checkmk agent ..."
45+
bash "$(dirname "$0")/install_cmk_agent.sh" vanilla
46+
ok "Checkmk agent installed."
5347

54-
# ── Step 5: Write .vscode/settings.json ──────────────────────────────────────
55-
step "Writing .vscode/settings.json ..."
56-
mkdir -p .vscode
57-
cat > .vscode/settings.json <<EOF
58-
{
59-
"python.defaultInterpreterPath": "${SPACE_ROOT}/bin/python",
60-
"python-envs.defaultEnvManager": "ms-python.python:system",
61-
"robotcode.run.openOutputAfterRun": "log",
62-
"window.autoDetectColorScheme": true
63-
}
48+
# ── Step 8: Install Firefox via Mozilla PPA ───────────────────────────────────
49+
step "Installing Firefox via Mozilla PPA ..."
50+
apt-get update -qq
51+
apt-get install -y --no-install-recommends software-properties-common
52+
add-apt-repository -y ppa:mozillateam/ppa
53+
# Pin Mozilla PPA above Ubuntu's snap redirect (priority 1001 > default 500)
54+
cat > /etc/apt/preferences.d/mozilla-firefox <<'EOF'
55+
Package: *
56+
Pin: release o=LP-PPA-mozillateam
57+
Pin-Priority: 1001
6458
EOF
65-
ok "python.defaultInterpreterPath → ${SPACE_ROOT}/bin/python"
59+
apt-get update -qq
60+
apt-get install -y --no-install-recommends firefox-esr
61+
ok "Firefox installed."
6662

6763
echo ""
68-
echo -e "${GREEN}${BOLD}Setup complete.${RESET} Open a new terminal to activate the PATH."
64+
echo -e "${GREEN}${BOLD}Container creation complete.${RESET}"

templates/web-browserlibrary/.devcontainer/setup.sh renamed to _dev/_devcontainers/cmk25/template/.devcontainer/postcreate.sh

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
2-
# .devcontainer/setup.sh — Runs once after the container is created.
3-
# Downloads RCC, builds the holotree environment, and configures VS Code.
2+
# .devcontainer/postcreate.sh — Runs each time a Codespace is created (not prebuild-cached).
3+
# Configures the user session: PATH, VS Code settings, VNC resolution, and Fluxbox menu.
44

55
set -euo pipefail
66

@@ -15,30 +15,8 @@ step() { echo -e "\n${CYAN}${BOLD}▶ $*${RESET}"; }
1515
ok() { echo -e "${GREEN}$*${RESET}"; }
1616
info() { echo -e " ${YELLOW}$*${RESET}"; }
1717

18-
RCC_URL="https://github.com/elabit/robotmk/releases/download/v4.0.0/rcc_linux64"
19-
RCC_BIN="$HOME/bin/rcc"
20-
21-
# ── Step 1: Download RCC ──────────────────────────────────────────────────────
22-
step "Downloading RCC ..."
23-
mkdir -p "$HOME/bin"
24-
curl -fsSL -o "$RCC_BIN" "$RCC_URL"
25-
chmod +x "$RCC_BIN"
26-
ok "RCC $(${RCC_BIN} --version 2>&1 | head -1) ready at ${RCC_BIN}"
27-
28-
# ── Step 2: Build holotree environment ────────────────────────────────────────
29-
step "Building RCC holotree environment (this takes a few minutes on first run) ..."
30-
info "robot.yaml: $(pwd)/robot.yaml"
31-
SPACE_ROOT=$(
32-
"$RCC_BIN" holotree vars --robot robot.yaml 2>&1 \
33-
| grep '^export RCC_HOLOTREE_SPACE_ROOT=' \
34-
| cut -d= -f2
35-
)
36-
ok "Environment ready at ${SPACE_ROOT}"
37-
38-
# ── Step 3: Symlink ~/.rcc-env ────────────────────────────────────────────────
39-
step "Creating symlink ~/.rcc-env → ${SPACE_ROOT} ..."
40-
ln -sfn "${SPACE_ROOT}" "$HOME/.rcc-env"
41-
ok "~/.rcc-env → ${SPACE_ROOT}"
18+
# Resolve SPACE_ROOT from the symlink created during oncreate
19+
SPACE_ROOT="$(readlink -f "$HOME/.rcc-env")"
4220

4321
# ── Step 4: Add to PATH in ~/.bashrc ─────────────────────────────────────────
4422
step "Configuring PATH in ~/.bashrc ..."
@@ -67,7 +45,6 @@ ok "python.defaultInterpreterPath → ${SPACE_ROOT}/bin/python"
6745
# ── Step 6: Configure fluxbox resolution ─────────────────────────────────────
6846
step "Configuring fluxbox resolution ..."
6947
FLUXBOX_STARTUP="$HOME/.fluxbox/startup"
70-
# Read VNC_RESOLUTION from .env if present, otherwise fall back to default
7148
VNC_RESOLUTION="1280x1024"
7249
if grep -q '^VNC_RESOLUTION=' .env 2>/dev/null; then
7350
VNC_RESOLUTION="$(grep '^VNC_RESOLUTION=' .env | cut -d= -f2 | tr -d '[:space:]')"
@@ -80,5 +57,19 @@ else
8057
ok "Set VNC resolution to ${VNC_RESOLUTION} in ${FLUXBOX_STARTUP}"
8158
fi
8259

60+
# ── Step 9: Configure Fluxbox menu ───────────────────────────────────────────
61+
step "Configuring Fluxbox menu ..."
62+
MENU_FILE="${HOME}/.fluxbox/menu"
63+
if [[ -f "${MENU_FILE}" ]] && ! grep -qF "firefox" "${MENU_FILE}"; then
64+
sed -i '/^\[begin\]/a\ [exec] (Checkmk) {firefox-esr http://localhost:5000/cmk}' "${MENU_FILE}"
65+
ok "Checkmk shortcut added to Fluxbox menu."
66+
else
67+
info "Fluxbox menu entry already present — skipping."
68+
fi
69+
# Restart Fluxbox to pick up menu changes (if already running)
70+
pkill fluxbox 2>/dev/null || true
71+
nohup fluxbox >/dev/null 2>&1 &
72+
disown
73+
8374
echo ""
8475
echo -e "${GREEN}${BOLD}Setup complete.${RESET} Open a new terminal to activate the PATH."

_dev/_devcontainers/cmk25/template/.devcontainer/setup.sh

Lines changed: 0 additions & 118 deletions
This file was deleted.

_dev/_devcontainers/desktop/template/.devcontainer/devcontainer.json.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
]
1919
}
2020
},
21-
"postCreateCommand": "bash .devcontainer/setup.sh",
21+
"onCreateCommand": "bash .devcontainer/oncreate.sh",
22+
"postCreateCommand": "bash .devcontainer/postcreate.sh",
2223
"remoteEnv": {
2324
"DISPLAY": ":1"
2425
},

_dev/_devcontainers/headless/template/.devcontainer/setup.sh renamed to _dev/_devcontainers/desktop/template/.devcontainer/oncreate.sh

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
2-
# .devcontainer/setup.sh — Runs once after the container is created.
3-
# Downloads RCC, builds the holotree environment, and configures VS Code.
2+
# .devcontainer/oncreate.sh — Runs once when the container image is built (prebuild-cached).
3+
# Downloads RCC and builds the holotree environment.
44

55
set -euo pipefail
66

@@ -40,29 +40,5 @@ step "Creating symlink ~/.rcc-env → ${SPACE_ROOT} ..."
4040
ln -sfn "${SPACE_ROOT}" "$HOME/.rcc-env"
4141
ok "~/.rcc-env → ${SPACE_ROOT}"
4242

43-
# ── Step 4: Add to PATH in ~/.bashrc ─────────────────────────────────────────
44-
step "Configuring PATH in ~/.bashrc ..."
45-
MARKER="# rcc-holotree-path"
46-
if grep -q "${MARKER}" "$HOME/.bashrc" 2>/dev/null; then
47-
info "PATH entry already present — skipping."
48-
else
49-
echo "${MARKER}" >> "$HOME/.bashrc"
50-
echo "export PATH=${SPACE_ROOT}/bin:\$PATH" >> "$HOME/.bashrc"
51-
ok "Added ${SPACE_ROOT}/bin to PATH"
52-
fi
53-
54-
# ── Step 5: Write .vscode/settings.json ──────────────────────────────────────
55-
step "Writing .vscode/settings.json ..."
56-
mkdir -p .vscode
57-
cat > .vscode/settings.json <<EOF
58-
{
59-
"python.defaultInterpreterPath": "${SPACE_ROOT}/bin/python",
60-
"python-envs.defaultEnvManager": "ms-python.python:system",
61-
"robotcode.run.openOutputAfterRun": "log",
62-
"window.autoDetectColorScheme": true
63-
}
64-
EOF
65-
ok "python.defaultInterpreterPath → ${SPACE_ROOT}/bin/python"
66-
6743
echo ""
68-
echo -e "${GREEN}${BOLD}Setup complete.${RESET} Open a new terminal to activate the PATH."
44+
echo -e "${GREEN}${BOLD}Container creation complete.${RESET}"

examples/web-cryptolibrary/.devcontainer/setup.sh renamed to _dev/_devcontainers/desktop/template/.devcontainer/postcreate.sh

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
2-
# .devcontainer/setup.sh — Runs once after the container is created.
3-
# Downloads RCC, builds the holotree environment, and configures VS Code.
2+
# .devcontainer/postcreate.sh — Runs each time a Codespace is created (not prebuild-cached).
3+
# Configures the user session: PATH, VS Code settings, and VNC desktop resolution.
44

55
set -euo pipefail
66

@@ -15,30 +15,8 @@ step() { echo -e "\n${CYAN}${BOLD}▶ $*${RESET}"; }
1515
ok() { echo -e "${GREEN}$*${RESET}"; }
1616
info() { echo -e " ${YELLOW}$*${RESET}"; }
1717

18-
RCC_URL="https://github.com/elabit/robotmk/releases/download/v4.0.0/rcc_linux64"
19-
RCC_BIN="$HOME/bin/rcc"
20-
21-
# ── Step 1: Download RCC ──────────────────────────────────────────────────────
22-
step "Downloading RCC ..."
23-
mkdir -p "$HOME/bin"
24-
curl -fsSL -o "$RCC_BIN" "$RCC_URL"
25-
chmod +x "$RCC_BIN"
26-
ok "RCC $(${RCC_BIN} --version 2>&1 | head -1) ready at ${RCC_BIN}"
27-
28-
# ── Step 2: Build holotree environment ────────────────────────────────────────
29-
step "Building RCC holotree environment (this takes a few minutes on first run) ..."
30-
info "robot.yaml: $(pwd)/robot.yaml"
31-
SPACE_ROOT=$(
32-
"$RCC_BIN" holotree vars --robot robot.yaml 2>&1 \
33-
| grep '^export RCC_HOLOTREE_SPACE_ROOT=' \
34-
| cut -d= -f2
35-
)
36-
ok "Environment ready at ${SPACE_ROOT}"
37-
38-
# ── Step 3: Symlink ~/.rcc-env ────────────────────────────────────────────────
39-
step "Creating symlink ~/.rcc-env → ${SPACE_ROOT} ..."
40-
ln -sfn "${SPACE_ROOT}" "$HOME/.rcc-env"
41-
ok "~/.rcc-env → ${SPACE_ROOT}"
18+
# Resolve SPACE_ROOT from the symlink created during oncreate
19+
SPACE_ROOT="$(readlink -f "$HOME/.rcc-env")"
4220

4321
# ── Step 4: Add to PATH in ~/.bashrc ─────────────────────────────────────────
4422
step "Configuring PATH in ~/.bashrc ..."
@@ -67,7 +45,6 @@ ok "python.defaultInterpreterPath → ${SPACE_ROOT}/bin/python"
6745
# ── Step 6: Configure fluxbox resolution ─────────────────────────────────────
6846
step "Configuring fluxbox resolution ..."
6947
FLUXBOX_STARTUP="$HOME/.fluxbox/startup"
70-
# Read VNC_RESOLUTION from .env if present, otherwise fall back to default
7148
VNC_RESOLUTION="1280x1024"
7249
if grep -q '^VNC_RESOLUTION=' .env 2>/dev/null; then
7350
VNC_RESOLUTION="$(grep '^VNC_RESOLUTION=' .env | cut -d= -f2 | tr -d '[:space:]')"

_dev/_devcontainers/headless/template/.devcontainer/devcontainer.json.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
]
1010
}
1111
},
12-
"postCreateCommand": "bash .devcontainer/setup.sh"
12+
"onCreateCommand": "bash .devcontainer/oncreate.sh",
13+
"postCreateCommand": "bash .devcontainer/postcreate.sh"
1314
}

0 commit comments

Comments
 (0)