title: Packer hangs at the end of my last command
body: <p>I am wondering why my code hangs at the end of my build using OpenVAS Scanner. This is what it shows at the end:</p>
  <pre><code>==&gt; Ubuntu AMI Builder: Provisioning with shell script: ../../pipeline/build/start.sh
      Ubuntu AMI Builder: Creating Data folder...
      Ubuntu AMI Builder: Running first start configuration...
      Ubuntu AMI Builder: Creating Openvas NVT sync user...
      Ubuntu AMI Builder: Wait for redis socket to be created...
      Ubuntu AMI Builder: Testing redis status...
      Ubuntu AMI Builder: Redis ready.
      Ubuntu AMI Builder: Creating NVT Plugins folder...
      Ubuntu AMI Builder: Fixing NVT Plugins folder...
      Ubuntu AMI Builder: Updating NVTs...
      Ubuntu AMI Builder: Removing leftover pid files from system
      Ubuntu AMI Builder: Starting Open Scanner Protocol daemon for OpenVAS...
      Ubuntu AMI Builder: Read and write capabilities for OpenVAS...
      Ubuntu AMI Builder: +++++++++++++++++++++++++++++++++++++++++++++++++++
      Ubuntu AMI Builder: + Your OpenVAS Scanner image is now ready to use! +
      Ubuntu AMI Builder: +++++++++++++++++++++++++++++++++++++++++++++++++++
      Ubuntu AMI Builder:
      Ubuntu AMI Builder: ++++++++++++++++++++++++++++++++
      Ubuntu AMI Builder: +++++++++ Tailing Logs +++++++++
      Ubuntu AMI Builder: ++++++++++++++++++++++++++++++++
      Ubuntu AMI Builder: OSPD[22021] 2021-04-15 03:44:05,252: INFO: (ospd.main) Starting OSPd OpenVAS version 20.8.1.
  </code></pre>
  <p>It is successful but hangs at the end of my script which confuses me so much. My last piece of the script is as follows:</p>
  <pre><code>####### Initiate ospd daemon for OpenVAS ########
  echo &quot;Starting Open Scanner Protocol daemon for OpenVAS...&quot;
  ospd-openvas --log-file /usr/local/var/log/gvm/ospd-openvas.log --unix-socket /data/ospd.sock --log-level INFO
  
  while  [ ! -S /data/ospd.sock ]; do
      sleep 1
  done
  
  echo &quot;Read and write capabilities for OpenVAS...&quot;
  chmod 666 /data/ospd.sock
  
  echo &quot;+++++++++++++++++++++++++++++++++++++++++++++++++++&quot;
  echo &quot;+ Your OpenVAS Scanner image is now ready to use! +&quot;
  echo &quot;+++++++++++++++++++++++++++++++++++++++++++++++++++&quot;
  echo &quot;&quot;
  echo &quot;++++++++++++++++++++++++++++++++&quot;
  echo &quot;+++++++++ Tailing Logs +++++++++&quot;
  echo &quot;++++++++++++++++++++++++++++++++&quot;
  tail /usr/local/var/log/gvm/*
  </code></pre>
  <p>Would anyone know why it hangs at the end after it has finished. I would appreciate any help if possible!</p>
  <p>UPDATE:
  I updated the code without having <code>-F</code> at the end of the provisioner and it still continues to hang. I am unsure if <code>ospd-openvas</code> is the culprit but it should end with a loop if it doesn't apply the code.
  <a href="https://i.stack.imgur.com/Xo6Xh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xo6Xh.png" alt="enter image description here" /></a></p>
  <p>UPDATE UPDATE:
  Here is my provisioner template I am using:</p>
  <pre><code>    &quot;provisioners&quot;: [
        {
          &quot;type&quot;: &quot;shell&quot;,
          &quot;execute_command&quot;: &quot;sudo -u root /bin/bash -c '{{.Path}}'&quot;,
          &quot;scripts&quot;: [
            &quot;../../pipeline/build/build_ami.sh&quot;,
            &quot;../../pipeline/build/start.sh&quot;
          ]
        }
      ]
    }
  </code></pre>
  <p>AND here are my debug logs once it hangs:</p>
  <pre><code>2021/04/15 13:12:40 packer-provisioner-shell plugin: [INFO] RPC client: Communicator ended with: 0
  2021/04/15 13:12:40 packer-builder-amazon-ebs plugin: [DEBUG] Opening new ssh session
  2021/04/15 13:12:40 packer-builder-amazon-ebs plugin: [DEBUG] starting remote command: sudo -u root /bin/bash -c '/tmp/script_2838.sh'
  2021/04/15 13:12:40 ui: [0;32m    Ubuntu AMI Builder: Creating Data folder...[0m
  2021/04/15 13:12:40 ui: [0;32m    Ubuntu AMI Builder: Running first start configuration...[0m
  2021/04/15 13:12:40 ui: [0;32m    Ubuntu AMI Builder: Creating Openvas NVT sync user...[0m
  2021/04/15 13:12:40 ui: [0;32m    Ubuntu AMI Builder: Wait for redis socket to be created...[0m
  2021/04/15 13:12:41 ui: [0;32m    Ubuntu AMI Builder: Testing redis status...[0m
  2021/04/15 13:12:41 ui: [0;32m    Ubuntu AMI Builder: Redis ready.[0m
  2021/04/15 13:12:41 ui: [0;32m    Ubuntu AMI Builder: Creating NVT Plugins folder...[0m
  2021/04/15 13:12:41 ui: [0;32m    Ubuntu AMI Builder: Fixing NVT Plugins folder...[0m
  2021/04/15 13:12:41 ui: [0;32m    Ubuntu AMI Builder: Removing leftover pid files from system[0m
  2021/04/15 13:12:41 ui: [0;32m    Ubuntu AMI Builder: Starting Open Scanner Protocol daemon for OpenVAS...[0m
  2021/04/15 13:12:42 ui: [0;32m    Ubuntu AMI Builder: Read and write capabilities for OpenVAS...[0m
  2021/04/15 13:12:42 ui: [0;32m    Ubuntu AMI Builder: +++++++++++++++++++++++++++++++++++++++++++++++++++[0m
  2021/04/15 13:12:42 ui: [0;32m    Ubuntu AMI Builder: + Your OpenVAS Scanner image is now ready to use! +[0m
  2021/04/15 13:12:42 ui: [0;32m    Ubuntu AMI Builder: +++++++++++++++++++++++++++++++++++++++++++++++++++[0m
  2021/04/15 13:12:42 ui: [0;32m    Ubuntu AMI Builder:[0m
  2021/04/15 13:12:42 ui: [0;32m    Ubuntu AMI Builder: ++++++++++++++++++++++++++++++++[0m
  2021/04/15 13:12:42 ui: [0;32m    Ubuntu AMI Builder: +++++++++ Tailing Logs +++++++++[0m
  2021/04/15 13:12:42 ui: [0;32m    Ubuntu AMI Builder: ++++++++++++++++++++++++++++++++[0m
  2021/04/15 13:12:42 ui: [0;32m    Ubuntu AMI Builder: OSPD[22185] 2021-04-15 18:12:41,530: INFO: (ospd.main) Starting OSPd OpenVAS version 20.8.1.[0m
  2021/04/15 13:26:44 ui error: Cancelling build after receiving interrupt
  2021/04/15 13:26:44 packer-provisioner-file plugin: Received interrupt signal (count: 1). Ignoring.
  2021/04/15 13:26:44 packer-provisioner-file plugin: Received interrupt signal (count: 1). Ignoring.
  2021/04/15 13:26:44 packer-provisioner-shell plugin: Received interrupt signal (count: 1). Ignoring.
  2021/04/15 13:26:44 packer-builder-amazon-ebs plugin: Received interrupt signal (count: 1). Ignoring.
  2021/04/15 13:26:44 Cancelling builder after context cancellation context canceled
  2021/04/15 13:26:44 packer-builder-amazon-ebs plugin: Cancelling provisioning due to context cancellation: context canceled
  2021/04/15 13:26:44 packer-builder-amazon-ebs plugin: Cancelling hook after context cancellation context canceled
  2021/04/15 13:26:44 Cancelling provisioner after context cancellation context canceled
  2021/04/15 13:26:44 ui: ask: [1;32m==&gt; Ubuntu AMI Builder: Pausing before cleanup of step 'StepSetGeneratedData'. Press enter to continue.[0m
  2021/04/15 13:26:44 packer-provisioner-shell plugin: Retryable error: context canceled
  2021/04/15 13:26:44 [INFO] (telemetry) ending shell
  2021/04/15 13:26:50 ui: ask: [1;32m==&gt; Ubuntu AMI Builder: Pausing before cleanup of step 'StepConnect'. Press enter to continue.[0m
  2021/04/15 13:26:51 ui: ask: [1;32m==&gt; Ubuntu AMI Builder: Pausing before cleanup of step 'StepCreateSSMTunnel'. Press enter to continue.[0m
  2021/04/15 13:26:52 ui: ask: [1;32m==&gt; Ubuntu AMI Builder: Pausing before cleanup of step 'StepGetPassword'. Press enter to continue.[0m
  2021/04/15 13:26:53 ui: ask: [1;32m==&gt; Ubuntu AMI Builder: Pausing before cleanup of step 'StepRunSourceInstance'. Press enter to continue.[0m
  2021/04/15 13:26:54 ui: [1;32m==&gt; Ubuntu AMI Builder: Terminating the source AWS instance...[0m
  2021/04/15 13:26:55 packer-builder-amazon-ebs plugin: [INFO] RPC endpoint: Communicator ended with: 0
  2021/04/15 13:26:55 [INFO] 716 bytes written for 'stdout'
  2021/04/15 13:26:55 [INFO] 0 bytes written for 'stderr'
  2021/04/15 13:26:55 [INFO] RPC client: Communicator ended with: 0
  2021/04/15 13:26:55 [INFO] RPC endpoint: Communicator ended with: 0
  2021/04/15 13:26:55 packer-provisioner-shell plugin: [INFO] 716 bytes written for 'stdout'
  2021/04/15 13:26:55 packer-provisioner-shell plugin: [INFO] 0 bytes written for 'stderr'
  2021/04/15 13:26:55 packer-provisioner-shell plugin: [INFO] RPC client: Communicator ended with: 0
  </code></pre>