|
1 | 1 | #!/bin/bash |
2 | 2 | # |
3 | 3 | # Entrypoint for containers that share the wg-client's network namespace. |
4 | | -# Installs the mitmproxy CA cert, loads env vars and secret placeholders |
5 | | -# from sandcat.env, then hands off to the container's main command. |
| 4 | +# Installs the mitmproxy CA cert, disables commit signing, loads env vars |
| 5 | +# and secret placeholders from sandcat.env, runs vscode-user setup (git |
| 6 | +# identity, Java trust store, Claude Code update), then drops to vscode |
| 7 | +# and exec's the container's main command. |
6 | 8 | # |
7 | 9 | set -e |
8 | 10 |
|
9 | 11 | CA_CERT="/mitmproxy-config/mitmproxy-ca-cert.pem" |
10 | 12 |
|
11 | | -# The CA cert should already exist (wg-client depends_on mitmproxy healthy), |
12 | | -# but wait briefly in case of a slight race on the shared volume. |
13 | | -elapsed=0 |
14 | | -while [ ! -f "$CA_CERT" ]; do |
15 | | - if [ "$elapsed" -ge 30 ]; then |
16 | | - echo "Timed out waiting for mitmproxy CA cert" >&2 |
17 | | - exit 1 |
18 | | - fi |
19 | | - sleep 1 |
20 | | - elapsed=$((elapsed + 1)) |
21 | | -done |
| 13 | +# The CA cert is guaranteed to exist: app depends_on wg-client (healthy), |
| 14 | +# which depends_on mitmproxy (healthy), whose healthcheck requires the |
| 15 | +# WireGuard config — generated after the CA. |
| 16 | +if [ ! -f "$CA_CERT" ]; then |
| 17 | + echo "mitmproxy CA cert not found at $CA_CERT" >&2 |
| 18 | + exit 1 |
| 19 | +fi |
22 | 20 |
|
23 | 21 | cp "$CA_CERT" /usr/local/share/ca-certificates/mitmproxy.crt |
24 | 22 | update-ca-certificates |
|
55 | 53 | echo "No $SANDCAT_ENV found — env vars and secret substitution disabled" |
56 | 54 | fi |
57 | 55 |
|
58 | | -# Run vscode-user tasks: git identity and Claude Code update. |
| 56 | +# Run vscode-user tasks: git identity, Java trust store, Claude Code update. |
59 | 57 | su - vscode -c /usr/local/bin/app-user-init.sh |
60 | 58 |
|
61 | | -# If app-user-init.sh set up Java (symlink + trust store), export JAVA_HOME |
62 | | -# and JAVA_TOOL_OPTIONS for shells and child processes of PID 1. |
63 | | -SANDCAT_JAVA_HOME="/home/vscode/.local/share/sandcat/java-home" |
64 | | -if [ -L "$SANDCAT_JAVA_HOME" ]; then |
65 | | - export JAVA_HOME="$SANDCAT_JAVA_HOME" |
66 | | - echo "export JAVA_HOME=\"$SANDCAT_JAVA_HOME\"" > /etc/profile.d/sandcat-java.sh |
67 | | -fi |
68 | | -if [ -f /tmp/sandcat-java-cacerts-path ]; then |
69 | | - SANDCAT_CACERTS=$(cat /tmp/sandcat-java-cacerts-path) |
70 | | - JAVA_TRUST_OPTS="-Djavax.net.ssl.trustStore=$SANDCAT_CACERTS -Djavax.net.ssl.trustStorePassword=changeit" |
71 | | - export JAVA_TOOL_OPTIONS="$JAVA_TRUST_OPTS" |
72 | | - echo "export JAVA_TOOL_OPTIONS=\"$JAVA_TRUST_OPTS\"" >> /etc/profile.d/sandcat-java.sh |
73 | | - rm -f /tmp/sandcat-java-cacerts-path |
74 | | -fi |
75 | | - |
76 | 59 | # Source all sandcat profile.d scripts from /etc/bash.bashrc so env vars |
77 | 60 | # are available in non-login shells (e.g. VS Code integrated terminals). |
78 | 61 | # Guard with a marker to avoid duplicating on container restart. |
|
0 commit comments