Codeprogrammers/codecraft-init-script — comment on commit 1b078d3abf71c1117cc946378832a863797efe6f
File:  line 0
By Toasty27:

Yes, and I only ever had a problem running commands through the as_user command when I wasn't running the script as the user specified in the $USERNAME variable.

Seeing as the script is supposed to be run as root (it's a service script), not the user specified in the $USERNAME variable, I changed that part of the script so that it would work properly.

I'll do some more testing to double confirm this, but that's what I remember having trouble with in the past.