diff --git a/scripts/vm/systemvm/injectkeys.sh b/scripts/vm/systemvm/injectkeys.sh index f69e33168d7..6f224cdddcf 100755 --- a/scripts/vm/systemvm/injectkeys.sh +++ b/scripts/vm/systemvm/injectkeys.sh @@ -85,14 +85,19 @@ systemvmpath=$3 command -v mkisofs > /dev/null || (echo "$(basename $0): mkisofs not found, please install or ensure PATH is accurate" ; exit 4) -# if running into Docker as unprivileges, skip ssh verification as iso cannot be mounted. -if [ -e /dev/loop0 ]; then +# if running into Docker as unprivileges, skip ssh verification as iso cannot be mounted due to missing loop device. +if [ -f /.dockerinit ]; then + if [ -e /dev/loop0 ]; then + # it's a docker instance with privileges. + inject_into_iso systemvm.iso $newpubkey + [ $? -ne 0 ] && exit 5 + copy_priv_key $newprivkey + else + # this mean it's a docker instance, ssh key cannot be verify. + echo "We run inside Docker, skipping ssh key insertion in systemvm.iso" + fi +else inject_into_iso systemvm.iso $newpubkey [ $? -ne 0 ] && exit 5 copy_priv_key $newprivkey -else - # this mean it's a docker instance, ssh key cannot be verify. - echo "No loop device found, skipping ssh key insertion in systemvm.iso" fi - -exit $?