Sorted this out, the problem was I was running the script with sudo sh ./installfog.sh

Needs to be sudo bash ./installfog.sh