mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
Add conditional services based on mobyplatform
Replaces https://github.com/docker/moby/pull/282 Use mobyplatform=xxx to specify platform in boot command Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
parent
18bcc15d20
commit
67b2a00853
@ -3,4 +3,4 @@ FROM justincormack/alpine-qemu
|
||||
COPY alpine/initrd.img.gz .
|
||||
COPY alpine/kernel/vmlinuz64 .
|
||||
|
||||
ENTRYPOINT [ "qemu-system-x86_64", "-serial", "stdio", "-kernel", "vmlinuz64", "-initrd", "initrd.img.gz", "-m", "1024", "-append", "earlyprintk=serial console=ttyS0 noapic mobytest=true", "-vnc", "none" ]
|
||||
ENTRYPOINT [ "qemu-system-x86_64", "-serial", "stdio", "-kernel", "vmlinuz64", "-initrd", "initrd.img.gz", "-m", "1024", "-append", "earlyprintk=serial console=ttyS0 noapic mobyplatform=test", "-vnc", "none" ]
|
||||
|
@ -68,7 +68,7 @@ COPY packages/userns/etc /etc/
|
||||
COPY packages/vsudd/vsudd /sbin/
|
||||
COPY packages/vsudd/etc /etc/
|
||||
COPY packages/mobyconfig/mobyconfig /usr/bin/
|
||||
COPY packages/bootflag/bootflag /usr/bin/
|
||||
COPY packages/mobyplatform/mobyplatform /usr/bin/
|
||||
COPY packages/gummiboot/gummiboot.tar.gz /usr/share/src/
|
||||
COPY packages/oom/etc /etc/
|
||||
COPY packages/9pmount-vsock/9pmount-vsock /sbin/
|
||||
|
@ -14,7 +14,7 @@ COPY packages/gummiboot/linuxx64.efi.stub /tmp/efi
|
||||
# Create a EFI boot file with kernel and initrd. From:
|
||||
# https://github.com/haraldh/mkrescue-uefi/blob/master/mkrescue-uefi.sh
|
||||
RUN cd /tmp/efi && \
|
||||
echo "earlyprintk=serial console=ttyS0" > cmdline.txt && \
|
||||
echo "earlyprintk=serial console=ttyS0 mobyplatform=windows" > cmdline.txt && \
|
||||
objcopy \
|
||||
--add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \
|
||||
--add-section .cmdline=./cmdline.txt --change-section-vma .cmdline=0x30000 \
|
||||
|
@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Script to print values of arbitrary kvpairs the kernel was passed as command
|
||||
# line parameters on boot.
|
||||
#
|
||||
# e.g. if kernel booted with cloud_provider=azure, 'bootflag cloud_provider'
|
||||
# will return 'azure'.
|
||||
#
|
||||
# If multiple flags have the same key, it will return only the first one found.
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: bootflag [key]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
awk -v flag=$1 '{
|
||||
for(i = 1; i <= NF; i++) {
|
||||
split($i, kvpair, "=");
|
||||
if(kvpair[1] == flag) {
|
||||
print kvpair[2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}' /proc/cmdline
|
@ -15,9 +15,9 @@ start()
|
||||
|
||||
# Only start with networking on cloud editions
|
||||
DOCKER_OPTS="${DOCKER_OPTS} -H unix:///var/run/docker.sock"
|
||||
if [ ! -z $(bootflag cloud_provider) ]
|
||||
if [ "$(mobyplatform)" == "aws" ] || [ "$(mobyplatform)" == "azure" ]
|
||||
then
|
||||
# TODO: More elegant way to turn on "debug mode"
|
||||
# TODO: Don't do this
|
||||
DOCKER_OPTS="${DOCKER_OPTS} -H 0.0.0.0:2375"
|
||||
fi
|
||||
|
||||
|
19
alpine/packages/mobyplatform/mobyplatform
Executable file
19
alpine/packages/mobyplatform/mobyplatform
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Returns the platform we are running on
|
||||
|
||||
# return the value matching the kvpair in the command line
|
||||
kvpair()
|
||||
{
|
||||
awk -v flag=$1 '{
|
||||
for(i = 1; i <= NF; i++) {
|
||||
split($i, kvpair, "=");
|
||||
if(kvpair[1] == flag) {
|
||||
printf kvpair[2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}' /proc/cmdline
|
||||
}
|
||||
|
||||
kvpair mobyplatform
|
@ -2,11 +2,13 @@
|
||||
|
||||
depend()
|
||||
{
|
||||
before docker
|
||||
before docker
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
[ "$(mobyplatform)" != "mac" ] && [ "$(mobyplatform)" != "windows" ] && exit 0
|
||||
|
||||
ebegin "Setting up proxy port service"
|
||||
|
||||
mkdir -p /port
|
||||
@ -32,6 +34,8 @@ start()
|
||||
|
||||
stop()
|
||||
{
|
||||
[ "$(mobyplatform)" != "mac" ] && [ "$(mobyplatform)" != "windows" ] && exit 0
|
||||
|
||||
ebegin "Stopping proxy port service"
|
||||
|
||||
[ -n "${PIDFILE}" ] || PIDFILE=/var/run/proxy-vsockd.pid
|
||||
|
@ -7,7 +7,7 @@ depend()
|
||||
|
||||
start()
|
||||
{
|
||||
cat /proc/cmdline | grep -q 'mobytest' || exit 0
|
||||
[ "$(mobyplatform)" != "test" ] && exit 0
|
||||
|
||||
ebegin "Running tests"
|
||||
|
||||
|
@ -9,6 +9,8 @@ depend()
|
||||
|
||||
start()
|
||||
{
|
||||
[ "$(mobyplatform)" != "mac" ] && [ "$(mobyplatform)" != "windows" ] && exit 0
|
||||
|
||||
ebegin "Starting vsock proxy"
|
||||
|
||||
if [ -d /sys/bus/vmbus ]; then
|
||||
@ -39,6 +41,8 @@ start()
|
||||
|
||||
stop()
|
||||
{
|
||||
[ "$(mobyplatform)" != "mac" ] && [ "$(mobyplatform)" != "windows" ] && exit 0
|
||||
|
||||
ebegin "Stopping docker socket passthrough"
|
||||
|
||||
[ -n "${PIDFILE}" ] || PIDFILE=/var/run/vsudd.pid
|
||||
|
23
docs/platforms.md
Normal file
23
docs/platforms.md
Normal file
@ -0,0 +1,23 @@
|
||||
## List of platforms
|
||||
|
||||
These are the supported platforms. Each should boot with `mobyplatform=xxx` in the command line.
|
||||
|
||||
### Desktop
|
||||
`mac`
|
||||
`windows`
|
||||
|
||||
https://github.com/docker/pinata
|
||||
|
||||
### Cloud
|
||||
`aws`
|
||||
`azure`
|
||||
|
||||
https://github.com/docker/editions
|
||||
|
||||
### Test
|
||||
`test`
|
||||
|
||||
https://github.com/docker/moby
|
||||
|
||||
### Other
|
||||
KVM/machine https://github.com/docker/moby/pull/225
|
Loading…
Reference in New Issue
Block a user