StackScripts provide Linode users with the ability to automate the deployment of custom systems. They work by running a custom script when deploying a new Compute Instance. These custom scripts store tasks that you may need to repeat often on new Compute Instances, such as:
Automating common system administration tasks, such as installing and configuring software, configuring system settings, adding limited user accounts, and more.
Running externally hosted deployment scripts.
Quickly creating Compute Instances for yourself or clients with the exact starter configuration you need.
All StackScripts are stored in the Linode Cloud Manager and can be accessed whenever you deploy a Compute Instance. A StackScript authored by you is an Account StackScript. A Community StackScript is a StackScript created by a Linode community member that has made their StackScript publicly available.
Get All
LinodeClient linodeClient = new LinodeClient("apikey");
// Get All
List<StackScript> list = await linodeClient.StackScript.Get();
Get One
Returns all of the information about a specified StackScript, including the contents of the script.
LinodeClient linodeClient = new LinodeClient("apikey");
// Get One
StackScript stackScript = await linodeClient.StackScript.Get(1278172);+
Create
Creates a StackScript in your Account.
LinodeClient linodeClient = new LinodeClient("apikey");
// Label
string label = "Super-StackScript";
// Images
List<string> listImages = new List<string> { "linode/debian10", "linode/debian11", "linode/debian12" };
// Script. In this example we will update the system and install several packages
string script = "#!/bin/bash\n" +
"# Updates the packages\n" +
"DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade\n" +
"# Tools\n" +
"apt install curl -y\n" +
"apt install wget -y\n" +
"apt install unzip -y\n" +
"apt install nginx -y\n" +
"apt install nano -y";
// Optional
// Description
string description = "This its an example";
// revNote
string revNote = "check (LJChuello)";
// Is Public; Default => false
bool isPublic = true;
// Create StackScript
StackScript stackScript = await linodeClient.StackScript.Create(
label,
listImages,
script,
revNote: revNote,
description: description,
isPublic: isPublic);
Update
Updates a StackScript.
Once a StackScript is made public, it cannot be made private.
LinodeClient linodeClient = new LinodeClient("apikey");
// Get
StackScript stackScript = await linodeClient.StackScript.Get(1300720);
// Rename label
stackScript.Label = "How to be an F1 driver for dummies (By; Valtteri Bottas)";
// Set images, We add Ubuntu images
stackScript.Images.Add("linode/ubuntu18.04");
stackScript.Images.Add("linode/ubuntu20.04");
stackScript.Images.Add("linode/ubuntu22.04");
// Update
stackScript = await linodeClient.StackScript.Update(stackScript);
Delete
Deletes a private StackScript you have permission to read_write. You cannot delete a public StackScript.
LinodeClient linodeClient = new LinodeClient("apikey");
// Get
StackScript stackScript = await linodeClient.StackScript.Get(1300722);
// You can delete it by passing the object as a parameter
await linodeClient.StackScript.Delete(stackScript);
// You can also delete it by passing the ID as a parameter.
await linodeClient.StackScript.Delete(1300722);