Moved 80% of Foreman deploy.sh into functions

No match.