mail-in-a-box / mailinabox

Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.
https://mailinabox.email/
Creative Commons Zero v1.0 Universal
14.03k stars 1.44k forks source link

setup script not reading STORAGE_ROOT #1501

Open mlchai opened 5 years ago

mlchai commented 5 years ago

I'm setting the STORAGE_ROOT env var and the setup script seems to ignore it. I can't get it to read this var. I've tried setting it in terminal and .profile/bashrc, and when I do an echo $STORAGE_ROOT it shows up but still doesn't seem to be read by the setup script.

jvolkenant commented 5 years ago

Did you export the variable?

mlchai commented 5 years ago

I did, and eventually it did work but was pretty inconsistent. I had to do it with my root user since it didn't work when using a non-root user. I found that it seemed to work sometime after the first install, but wouldn't work when doing a fresh one.

mlchai commented 5 years ago

Found another possible solution. Looked into this a bit more and I don't think there's anything wrong with the mailinabox install script. What's happening is that the environment variable is lost when the setup script is run since a new session or child session is created when the script is run, and this new session doesn't preserve environment variables. Here's a hacky but sure fire way to get the script the STORAGE_ROOT env var:

As root, edit the /etc/environment file and add the following at the end:

STORAGE_ROOT=/your/path/here

Don't put "export" or anything, just define the env var there. After installation, you can just remove it if you want. This allows all users and all session access to that env var. Should work with whatever user you decide to use for the installation.

The only change needed would probably be an update to the documentation that mentions STORAGE_ROOT.