Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add PROGRAM parameter to eve-enter-container #4159

Merged
merged 1 commit into from
Aug 26, 2024
Merged
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
2 changes: 1 addition & 1 deletion docs/DEBUGGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ In order to attach to the console of the hosting Vm of the Container application

The `prime-cons` console exists only for the Container applications and is always reachable for executing commands on the Vm which hosts corresponding container.

Once terminal responds on the `prime-cons` console it is possible to enter container by executing the `eve-enter-container` command:
Once terminal responds on the `prime-cons` console it is possible to enter container by executing the `eve-enter-container` command. The script takes an optional argument with the path to the program to run in the container (the path is relative to the root of the container filesystem). If no argument is provided, the script will try to call the shell (`/bin/sh`) in the container:

```bash
~ # eve-enter-container
Expand Down
10 changes: 9 additions & 1 deletion pkg/xen-tools/initrd/eve-enter-container
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ if [ ! -f "$PID_FILE" ]; then
fi

PID=$(cat "$PID_FILE")
nsenter -t "$PID" -m -u -i -n -p -r/mnt/rootfs -w/mnt/rootfs

# Check if the first argument is provided, otherwise use /bin/sh as the default
PROGRAM=${1:-/bin/sh}

# Shift arguments if a program is provided, so "$@" contains the rest of the command-line arguments
shift

# Enter the namespaces and execute the specified program with its arguments
nsenter -t "$PID" -m -u -i -n -p -r/mnt/rootfs -w/mnt/rootfs "$PROGRAM" "$@"
Loading