mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-10-11 14:44:16 +00:00
37 lines
855 B
Bash
Executable File
37 lines
855 B
Bash
Executable File
#!/bin/sh
|
|
|
|
QEMU_IMAGE=mobylinux/qemu:2e63db70759e37de6f9cc5cdf67c15f3aa8373c8@sha256:958c6bb1fca426cadf7a3664b8c019eba9f9e2ad4f6b4f3ed02d766fe5e709e4
|
|
|
|
# if not interactive
|
|
if [ ! -t 0 -a -z "$1" ]
|
|
then
|
|
# non interactive, tarball input
|
|
docker run -i --rm "$QEMU_IMAGE"
|
|
exit $?
|
|
fi
|
|
|
|
FILE=$1
|
|
FILE2=$2
|
|
CMDLINE=$3
|
|
[ -z "$FILE" ] && FILE="$PWD/moby"
|
|
|
|
BASE=$(basename "$FILE")
|
|
DIR=$(dirname "$FILE")
|
|
if [ ! -f "$FILE" -a -f $DIR/$BASE-initrd.img -a -f $DIR/$BASE-bzImage ]
|
|
then
|
|
FILE=$DIR/$BASE-initrd.img
|
|
FILE2=$DIR/$BASE-bzImage
|
|
fi
|
|
|
|
echo "$FILE" | grep -q '^/' || FILE="$PWD/$FILE"
|
|
if [ ! -z "$FILE2" ]
|
|
then
|
|
echo "$FILE2" | grep -q '^/' || FILE2="$PWD/$FILE2"
|
|
fi
|
|
|
|
BASE=$(basename "$FILE")
|
|
MOUNTS="-v $FILE:/tmp/$BASE"
|
|
BASE2=$(basename "$FILE2")
|
|
[ ! -z "$FILE2" ] && MOUNTS="$MOUNTS -v $FILE2:/tmp/$BASE2"
|
|
docker run -it --rm $MOUNTS "$QEMU_IMAGE" $CMDLINE
|