We can configure a bash startup script using Shadeform’s Create Instance API.
In this example, we will run the script below once the instance becomes ready.
Script
Copy
#!/bin/bashcounter=1# Infinite loopwhile true; do echo $counter # Increment the counter ((counter++)) # Wait for 3 seconds sleep 3done
First, we must Base64 encode the script to preserve all special characters, whitespacing, and formatting of the script.
We recommend using this tool to base64 encode our script. After base64 encoding the script, you should get the following:
Once the instance is created, we can get the status and IP address of the instance by calling the Instances API.
Once the instance is active, we can verify that the script ran correctly by SSHing into the instance and running: