Might I suggest putting your shell commands inside the if/endif. The way you have it now could lead to some unusual/unexpected results.