Reboot after stackscript

I have a python script that launches Linodes using the API and StackScripts. Since I'm adding a private IP to the linodes, they need to be rebooted to work properly. I can't seem to reboot my linodes through the stackscript though.

I tried the subshell solution listed on this forum but it didn't work for me. The stackscript completes fine and then just drops to a prompt. I have a feeling the completed stackscript is also killing off the restart process that's been backgrounded.

Is anyone able to successfully able to reboot from their stackscripts without having the script run over again?

Thanks for the help.

4 Replies

Hello .. hmm … you need to allow the the StackScript to exit so its parent can clean up. You can either cron, or fork a script that waits and then issues a reboot to achieve this. I've done it, plenty of others have too.

Why not make the call to add the private IP before booting? No rebooting necessary that way.

-Chris

Thanks, Chris. I was thinking that I'd either cron or touch a file to indicate on restart that the stackscript should just exit the second time around. That just seemed "sloppier" to me so I figured I was doing something wrong. Can you point me to an example of forking the script. I thought that's what the (command) & syntax was doing in the page I linked and that didn't work. The script finishes OK but doesn't reboot.

I'll look into adding the IP first. If that saves me a reboot, it's a good solution.

Try adding this to the end of your stack script````
$(shutdown -r +1) &

````

Thanks, obs. I'll give that a shot.

Turns out I was adding the private IP before boot OK. But I was using "service networking restart" which doesn't work on the Ubuntu boxes I'm creating. I changed it to use "/etc/init.d/networking restart", which complains but seems to actually bring up my aliases.

Off to test. Thanks for the advice.

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