How do I pass UDF Variables between StackScripts?
I've been looking everywhere and I can't seem to find any way to do this. I am calling other stackscripts like so
<ssinclude StackScriptID="1">
and I am hoping you can do something like
<ssinclude StackScriptID="1" username="user" password ="..." ...etc>
Let me know if it's possible or not, thanks.
1 Reply
Hey,
You got it! This is absolutely possible. What we need is to do is separate out the user defined variables from Linode's special <ssinclude>
directive. This is just bash, so everything on its own newline is fine. You can export your variables to other additional scripts, or source additional stackscripts directly. Here's an example
#!/bin/bash
# this parent script sets some variables and downloads a child script.
user=user39292
password="an insecure password"
<ssinclude StackScriptID=1204415>
# we know the name of the file that the ss directive will create
# set that file to be executable and source it
chmod +x ssinclude-1204415
. ssinclude-1204415