✓ Solved

How do I get the server's label name from within the server?

I need to get the label name of the server in the StackScript, how do I do this?

4 Replies

✓ Best Answer

There's a Linode API call to do this:

https://techdocs.akamai.com/linode-api/reference/api-summary#linodes-list

What you're looking for is the "label"

-- sw

P.S. If you put the Linode ID from the cloud manager into a file on your Linode (say /etc/linodeid), your query can read that file and just query that Linode…instead of having to sort through all the Linodes assigned to you (which is what the above returns to you). The Linode ID is a constant for the life of the Linode.

Ah so the label is not put anywhere don't the server, it has to be queried through the API.

The label is a construct of the Linode platform…not the VPS or the distro. You only have access to it using the facilities of the Linode platform (the API).

-- sw

Hello,

StackScripts do set a few environment variables, including LINODE_ID - but not label. But LINODE_ID may help you…

https://www.linode.com/docs/platform/stackscripts/writing-scripts-for-use-with-linode-stackscripts-a-tutorial/#default-environment-variables

-Chris

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct