little flaw in create_chroot_env

i found a little flaws in create_chroot_env.sh and i post it here so that anyone of the developer with write access to the source-file can change (fix) it.

at the end of the file BEVORE ln /var/run/mysqld/mysqld.soc ${HOMEDIR}... we have to add

Code:

#delete the old one, because it changes if the server (or mysql) is restarted
rm ${HOMEDIR}/var/run/mysqld/mysqld.sock

because the problem is, that this file is regenerated every time the mysql database is (re)started. Maybe anyone has a better idea (maybe a "other" link which worked if the "original" file was removed and new generated or anything else...)

#delete the old one, because it changes if the server (or mysql) is restarted
rm ${HOMEDIR}/var/run/mysqld/mysqld.sock

because the problem is, that this file is regenerated every time the mysql database is (re)started. Maybe anyone has a better idea (maybe a "other" link which worked if the "original" file was removed and new generated or anything else...)

if something is unclear, please fell free to ask...

Click to expand...

i've reproduced the problem. a hard link like ${HOMEDIR}/var/run/mysqld/mysqld.sock uses the same inode as the original file. so if the original is modified, the hard linked file will also change because both are technically identical. but if you delete the original (when you stop mysqld), the linked file stays and gets the only one using the inode. there's no more link to another file then. so if you start mysqld again, the socket in the home dir is still the old one, but /var/run/mysqld/mysqld.sock is the new one.

in my case, the creation of the hard link also failed because of an "invalid cross-device link" error. reason: hardlinking between different filesystems is not possible (because both files have to use the same inode on the same filesystem).

bugfix for both problems is to use a symbolic link. it will stay, even if the original is removed, but won't work anymore. if the original is back, the link to the original works again. symbolic links also don't care about linking between different filesystems.

fixed it in the ispconfig2-dev trunk. or simply change the following line at the end of create_chroot_env.sh: