I suspect that there is more than one Mail-in-a-Box directory on your server.
Turns out I also have more than one folder (oops).
One in the “user” home directory (/home/user) and one in the “root” home directory (/root).
When I execute the status_checks command as follow:
sudo ~/mailinabox/management/status_checks.py
I got this output:
System
======
âś“ All system services are running.
âś“ SSH disallows password-based login.
âś“ System software is up to date.
âś– A new version of Mail-in-a-Box is available. You are running version v57. The latest version is v67. For upgrade instructions, see https://mailinabox.email.
As you can see, my MiaB is not up to date (v57).
But when I execute the status_checks command as follow:
sudo -i -u root bash -c '~/mailinabox/management/status_checks.py'
I got this output:
System
======
âś“ All system services are running.
âś“ SSH disallows password-based login.
âś“ System software is up to date.
âś“ Mail-in-a-Box is up to date. You are running version v67.
My MiaB is up to date (v67).
That’s weird, I suspect it has something to do with git
I ran the following command to find all directories by the name mailinabox that contains a sub-directory named .git:
sudo find / -path "*/mailinabox/.git"
And got this output:
/home/user/mailinabox/.git
/root/mailinabox/.git
There lies my “problem”, it appears that in my case, I once executed the command:
curl -s https://mailinabox.email/setup.sh | sudo bash
logged in as “user”, which means that home directory is /home/user.
On another occasion I executed this command logged in as “root” which means that home directory is /root
If we’ll look at the code of status_checks.py we’ll see that the function checking the local MiaB git version looks like this:
897 def what_version_is_this(env):
898 # This function runs `git describe --abbrev=0` on the Mail-in-a-Box installation directory.
899 # Git may not be installed and Mail-in-a-Box may not have been cloned from github,
900 # so this function may raise all sorts of exceptions.
901 miab_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
902 tag = shell("check_output", ["/usr/bin/git", "describe", "--abbrev=0"], env={"GIT_DIR": os.path.join(miab_dir, '.git')}).strip()
903 return tag
If we’re logged in as “user”, miab_dir variable will contain: /home/user/mailinabox
and we’ll get the tag value from the command:
GIT_DIR=/home/user/mailinabox/.git bash -c '/usr/bin/git describe --abbrev=0'
If we’re logged in as “root”, miab_dir variable will contain: /root/mailinabox
and we’ll get the tag value from the command:
GIT_DIR=/root/mailinabox/.git bash -c '/usr/bin/git describe --abbrev=0'
Let see from where we got those git directories.
If we’ll look at the code of “setup.sh” we’ll see that it uses the $HOME variable as the base location to download its git repository.
- $HOME is an environment variable that holds the home directory of the current logged in user.
53 # Clone the Mail-in-a-Box repository if it doesn't exist.
54 if [ ! -d $HOME/mailinabox ]; then
55 if [ ! -f /usr/bin/git ]; then
56 echo Installing git . . .
57 apt-get -q -q update
58 DEBIAN_FRONTEND=noninteractive apt-get -q -q install -y git < /dev/null
59 echo
60 fi
So when we run the setup command:
curl -s https://mailinabox.email/setup.sh | sudo bash
It will clone the mailinabox git repository based on the $HOME location of the currently logged in user.
Therefore we need to stick to one user when installing and upgrading MiaB and make sure to only use this user.
I think it would be safe to delete the unnecessary MiaB git directory