How do I properly update a StackScript using the CLI?
Hi there,
I'm using linode-cli from a bash command line to try to update a StackScript. I'm properly authenticated. Here's the command I'm trying:
$ linode-cli stackscripts update XXXXXX --script FILENAME --rev_note "trying CLI updating"
And here's the error I receive:
Request failed: 400
┌errors──┬────────────────────────────────────────────────────────────┐
│ field │ reason │
├────────┼────────────────────────────────────────────────────────────┤
│ script │ Script must begin with a shebang (example: '#!/bin/bash'). │
└────────┴────────────────────────────────────────────────────────────┘
When I try just "#!/bin/bash" as the --script argument value (rather than just using a file), the command completes, but obviously my script is more than just a shebang! I'm missing something super obvious here, but I'm banging my head trying to figure out what.
Thank you for your help!
5 Replies
Hello there! I believe the error is with the file itself. Do the contents of the file begin with #!/bin/bash
or some other shebang? Without that your script will fail.
Hey @scrane — yep, the file does start with #!/bin/bash
. When I paste the script into the Edit window in a browser, it validates and works just fine. I actually ran it 10 minutes ago on a new Linode, and all's good. It's just updating via the CLI that isn't working. I've been using versions of this StackScript for at least a year now, if not more, so I know the script runs properly.
I don't mean to bump, but anyone got any ideas? There's precious little documentation, and I can't figure out for the life of me why I can't update a stackscript from the command line! @scrane any ideas?
Thank you!
I've had issues with this. I think its related to improper shell escaping. I use a makefile to perform common tasks. I've created a gist with its contents:
https://gist.github.com/kaymccormick/b3d210bb23a2d4e4bbe37998c0ad7e18
This is the basic command (stackscript is the name of the script, which is confusing, I know). I added ./ to make that hopefully a bit more clear. The double backticks should be single backticks but I had trouble quoting them.
$(LINODE_CLI) stackscripts update --script "``cat ./stackscript``" $(SS_ID)
Amazing! I tried so many variations of trying to get the script inserted into the --script argument, but backticking the cat command worked perfectly! Many thanks for your help, adapting your update command will streamline my workflow hugely! @justdesserts Thank you!! Cheers!