Theoretically, that will take the result of your btsync status command and store it in the variable as text. if the text doesn't contain the word 'running' it shuts down. The rest is just like the checkwifi steps at the link you mentioned: