github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/builtin/app/docker-external/data/aws-simple/deploy/cloud-init.sh.tpl (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  # Install cURL if we have to
     5  apt-get update -y
     6  apt-get install -y curl
     7  
     8  # Install Docker
     9  curl -sSL https://get.docker.com/ | sh
    10  
    11  # Create the container
    12  docker create {{ run_args }} --name="{{ name }}" {{ docker_image }}
    13  
    14  # Write the service
    15  cat >/etc/init/{{ name }}.conf <<EOF
    16  description "Docker container: {{ name }}"
    17  
    18  start on filesystem and started docker
    19  stop on runlevel [!2345]
    20  
    21  respawn
    22  
    23  post-stop exec sleep 5
    24  
    25  script
    26    /usr/bin/docker start {{ name }}
    27  end script
    28  EOF
    29  
    30  # Start the service
    31  start {{ name }}