How do I add a startup script to an existing VM from the developer console?

前端 未结 3 1840
旧时难觅i
旧时难觅i 2021-02-12 12:50

I have an existing, already configured VM on Google Cloud Platform. It was created without a startup script, but I\'d like to add one now.

How do I add it from the conso

3条回答
  •  别跟我提以往
    2021-02-12 13:21

    You can add a startup script to an already created VM by creating a new custom metadata field. Follow these steps:

    1. Get to your VM's configuration page: Navigate to https://console.developers.google.com Click your project. Go to Compute -> Compute Engine -> VM Instances. Click the name of your VM.
    2. Scroll down to Custom Metadata. Click Edit.
    3. Create a new metadata field. Set the key to startup-script.
    4. Paste your startup script into the value field. Don't forget the shebang. Here's an example of a valid script.

      #! /bin/bash
      apt-get update
      apt-get install -y apache2
      cat < /var/www/index.html
      

      Hello World

      This page was created from a simple startup script!

      EOF
    5. Restart your VM. Enjoy the yields of your awesome startup script.

提交回复
热议问题