mirror of https://github.com/mongodb/mongo
SERVER-112612: Add xdg-open wrapper to open browser urls on the host (#43174)
GitOrigin-RevId: 277d7824e33d5e863beafa339fdcfa723a119794
This commit is contained in:
parent
cf3a5e9ef1
commit
55bc36a85b
|
|
@ -10,7 +10,15 @@ ARG USER_GID=$USER_UID
|
|||
# Create the user
|
||||
RUN groupadd $USERNAME && useradd -s /bin/bash --gid $USER_GID -m $USERNAME
|
||||
|
||||
RUN apt-get update && apt-get install -y sudo curl ca-certificates
|
||||
RUN apt-get update && apt-get install -y sudo curl ca-certificates xdg-utils
|
||||
|
||||
# Install xdg-open wrapper for browser integration
|
||||
COPY .devcontainer/xdg-open-wrapper.sh /usr/local/bin/xdg-open-wrapper.sh
|
||||
RUN chmod +x /usr/local/bin/xdg-open-wrapper.sh && \
|
||||
if [ -f /usr/bin/xdg-open ]; then \
|
||||
mv /usr/bin/xdg-open /usr/bin/xdg-open.real; \
|
||||
fi && \
|
||||
ln -s /usr/local/bin/xdg-open-wrapper.sh /usr/bin/xdg-open
|
||||
|
||||
# Give user sudo access
|
||||
RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/devcontaineruser && chmod 0440 /etc/sudoers.d/devcontaineruser
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
# xdg-open wrapper for devcontainer
|
||||
# Launches URLs using VSCode's $BROWSER environment variable
|
||||
# Falls back to native xdg-open for non-URLs
|
||||
|
||||
NATIVE_XDG_OPEN="/usr/bin/xdg-open.real"
|
||||
|
||||
# If it's an HTTP/HTTPS URL and $BROWSER is set, use it
|
||||
if [[ "$1" == http:* || "$1" == https:* ]] && [ -n "$BROWSER" ]; then
|
||||
exec "$BROWSER" "$@"
|
||||
fi
|
||||
|
||||
# Otherwise, fall back to native xdg-open if it exists
|
||||
if [ -x "$NATIVE_XDG_OPEN" ]; then
|
||||
exec "$NATIVE_XDG_OPEN" "$@"
|
||||
fi
|
||||
|
||||
# If we get here, we couldn't handle it
|
||||
echo "Error: Cannot open '$1' - no suitable handler found" >&2
|
||||
exit 1
|
||||
Loading…
Reference in New Issue