diff --git a/alpine/Dockerfile b/alpine/Dockerfile index f30abd987..67d4b66d0 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -73,6 +73,7 @@ COPY packages/userns/useradd /usr/sbin COPY packages/vsudd/vsudd /sbin COPY packages/vsudd/etc /etc COPY packages/mobyconfig/mobyconfig /usr/bin +COPY packages/bootflag/bootflag /usr/bin COPY packages/gummiboot/gummiboot.tar.gz /usr/share/src/ COPY packages/oom/etc /etc COPY packages/9pmount-vsock/9pmount-vsock /sbin diff --git a/alpine/packages/bootflag/bootflag b/alpine/packages/bootflag/bootflag new file mode 100755 index 000000000..d45372a6a --- /dev/null +++ b/alpine/packages/bootflag/bootflag @@ -0,0 +1,24 @@ +#!/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