I don't think there is a way you can script configuration changes inside of the SLD; my line of thinking is that if the SLD is down and your script tries to run, it can't verify changes are what you want to set them to be.
If you have a Windows system you could leverage, it would make things easier on you.
Perhaps someone else has an idea?