1

When installing mysql-server on Debian Wheezy, the user "mysql" is created without a home directory. In my setup, directly after MySQL was installed, a new task is performed which relies on the mysql user having /var/lib/mysql as home directory.

At the moment, this task fails. I have to adjust the mysql user and re-run my task again. So what I am looking for is a builtin method in Debian which allows me to either "preseed" the home dir of the mysql user (which is created by one of the mysql packages) or creating a trigger which reacts on the event of the mysql-server package being installed (or the mysql user being created, I don't care).

I know that I could modify the mysql package or wrap mysql installation in some sort of script or puppet manifest; however, things like this are not suitable for my setup. I need a clean Debian method to do it.

Is there something existing which could be triggered on package installation or user creation? I thought about watching mysql files via inotify as a workaround; however, I think that inotify would be too much for my little problem here.

I am currently looking at dpkg-triggers, but I am not sure if this is the right solution..

PythonLearner
  • 1,032
  • 2
  • 12
  • 31
  • Sounds like you just need to amend your post-install process to not require mysql to have a proper home dir. You've essentially ruled out any other reasonable way to resolve this. – EEAA Apr 03 '14 at 21:21

1 Answers1

2

You can create the user mysql just before installation of the package. If you look at the preinst script of the package, this won't break anything:

# creating mysql user if he isn't already there
if ! getent passwd mysql >/dev/null; then
    # Adding system user: mysql.
    adduser \
        --system \
        --disabled-login \
        --ingroup mysql \
        --no-create-home \
        --home /nonexistent \
        --gecos "MySQL Server" \
        --shell /bin/false \
        mysql  >/dev/null
fi

http://sources.debian.net/src/mysql-5.5/5.5.35%2Bdfsg-2/debian/mysql-server-5.5.preinst

tlo
  • 548
  • 2
  • 8
  • 24
  • That was exactly what I was looking for, ty! However, I just found out that the MySQL package on Debian "unsets" the home of the mysql user afterwards, so I still have to find another way. – PythonLearner Apr 05 '14 at 23:09