| 1 | #!/bin/sh |
| 2 | set -eu |
| 3 | : "${LIMA_INSTANCE:=podman}" |
| 4 | : "${PODMAN:=podman}" |
| 5 | |
| 6 | if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then |
| 7 | echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE template:podman\` to create a new instance" >&2 |
| 8 | exit 1 |
| 9 | elif [ "$(limactl ls -f '{{ .Status }}' "$LIMA_INSTANCE" 2>/dev/null)" != "Running" ]; then |
| 10 | echo "instance \"$LIMA_INSTANCE\" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing instance" >&2 |
| 11 | exit 1 |
| 12 | fi |
| 13 | PODMAN=$(command -v "$PODMAN" || true) |
| 14 | if [ -n "$PODMAN" ]; then |
| 15 | CONTAINER_HOST=$(limactl list "$LIMA_INSTANCE" --format 'unix://{{.Dir}}/sock/podman.sock') |
| 16 | export CONTAINER_HOST |
| 17 | exec "$PODMAN" --remote "$@" |
| 18 | else |
| 19 | export LIMA_INSTANCE |
| 20 | exec lima podman "$@" |
| 21 | fi |