reply to dangmoo
I've just solved the problem,
From a security perspective, I would stay far far far away from a shell script like this that that runs as root. This is exactly the kind of thing attackers take advantage of to compromise systems.