1. Use standard shell indentation
2. Use [ expr -a expr ] instead of [ expr ] && [ expr ] (same with -o and ||)
3. Cleanup 0 length string tests
4. Factor out the routing code
5. Use a large switch statement based on $reason instead of the endless
if elif's
6. Use variables for filenames used
7. Test in all cases for the existance of domainname and hostname
8. No need for individual command redirections in structured statements.
Thanks to kleink for testing and fixing my typos!