github.com/scaleway/scaleway-cli@v1.11.1/examples/create-image-testing-server.sh (about)

     1  #!/bin/bash
     2  
     3  set -e
     4  URL="${1}"
     5  
     6  if [ -z "${1}" ]; then
     7      echo "usage: $(basename ${0}) <url>"
     8      echo ""
     9      echo "examples:"
    10      echo "  - $(basename ${0}) http://test-images.fr-1.storage.online.net/scw-distrib-ubuntu-trusty.tar"
    11      echo "  - VOLUME=20GB $(basename ${0}) http://test-images.fr-1.storage.online.net/scw-distrib-ubuntu-trusty.tar"
    12      exit 1
    13  fi
    14  
    15  # FIXME: add usage
    16  
    17  NAME=$(basename "${URL}")
    18  NAME=${NAME%.*}
    19  
    20  
    21  echo "[+] URL of the tarball: ${URL}"
    22  echo "[+] Target name: ${NAME}"
    23  
    24  echo "[+] Creating new server in rescue mode..."
    25  SERVER=$(
    26      scw create \
    27          --bootscript=rescue \
    28          --name="[testing] $NAME" \
    29          --env="boot=rescue rescue_image=${URL}" \
    30          1GB
    31        )
    32  echo "[+] Server created: ${SERVER}"
    33  
    34  echo "[+] Booting..."
    35  scw start "${SERVER}" >/dev/null
    36  echo "[+] Done"