github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/scripts/image-pusher/push-to-importer (about)

     1  #! /bin/bash --posix
     2  #
     3  # push-to-importer sub image image_server
     4  #
     5  # Push an image to a sub which is running an importer image designed for
     6  # importing another image. The importer image should implement the
     7  # make-bootable-and-unmount service such that
     8  # the command "service make-bootable-and-unmount start" will make the parent
     9  # block device of the destination file-system bootable and will stop subd and
    10  # unmount the file-system.
    11  # The following parameters are required:
    12  #   sub:          the hostname of the sub
    13  #   image:        the image to push
    14  #   image_server: the hostname of the image server
    15  
    16  set -o nounset
    17  
    18  if [ "$#" -ne 3 ]; then
    19      echo "Usage: push-to-importer sub image image_server"
    20      exit 1
    21  fi
    22  
    23  readonly sub="$1"
    24  readonly image="$2"
    25  readonly image_server="$3"
    26  
    27  echo 'Pushing image content'
    28  subtool -subHostname="$sub" \
    29          -deleteBeforeFetch=true \
    30          -filterFile=/dev/null \
    31          -imageServerHostname="$image_server" \
    32          -showTimes=true \
    33          -triggersString='[]' \
    34    push-image "$image" || exit
    35  
    36  echo 'Making bootable and detaching file-system'
    37  subtool -subHostname="$sub" \
    38          -showTimes=true \
    39          -triggersString='[{"MatchLines":[".*"],"Service":"make-bootable"}]' \
    40    push-file "$HOME/etc/make-bootable-and-unmount" /make-bootable