Replace $USER with $(id -un).
In some environments the USER variable is not setup. Instead of checking for it, always use $(id -un) instead.
In some environments the USER variable is not setup. Instead of checking for it, always use $(id -un) instead.