debian compatibility and variable use

This patch fixes the use of `/etc/init.d/functions` which seems to be not standard across linux distributions. Furthermore the template now uses the global variables instead of the local ones / some functions.