Update init.d script

The original init.d script uses a fixed username (e.g. git). Which is not flexible
when we using other user. So, I've updated it to use $APP_USER variable
instead and wrap it in a function to reduce repetitive codes.