[systemd-devel] PgSQL, MySQL systemd services - how to rewrite complex init scripts?

Michał Piotrowski mkkp4x4 at gmail.com
Sat Apr 9 11:55:25 PDT 2011


W dniu 9 kwietnia 2011 20:18 użytkownik Mirco Tischler <mt-ml at gmx.de> napisał:
> 2011/4/9 Michał Piotrowski <mkkp4x4 at gmail.com>
>>
>> >>  Have you considered using a file in /etc/tmpfiles.d and let syBstemd
>> >> take
>> >> care of this?
>> >>
>> >> Mirco
>> >>
>> >
>> > No, but I think that this is a good idea. Thanks!
>>
>> >>
>> Hmmm... but what if I want to change default dir? I use /home/data/
>> instead of /var/lib/pgsql and /var/lib/mysql
>>
>>
>> --
>> Best regards,
>> Michal
>
> Does mysql really try to create the data dir on every start if it doesn't
> exist?

        if [ ! -d "$datadir/mysql" ] ; then
            # First, make sure $datadir is there with correct permissions
            if [ ! -e "$datadir" -a ! -h "$datadir" ]
            then
                mkdir -p "$datadir" || exit 1
            fi
            chown mysql:mysql "$datadir"
            chmod 0755 "$datadir"
            [ -x /sbin/restorecon ] && /sbin/restorecon "$datadir"
            # Now create the database
            action $"Initializing MySQL database: "
/usr/bin/mysql_install_db --datadir="$datadir" --user=mysql
            ret=$?
            chown -R mysql:mysql "$datadir"
            if [ $ret -ne 0 ] ; then
                return $ret
            fi
        fi


> This sounds flawed to me.
> If the data dir doesn't exist it's likely there is a bigger problem.
> I thought we were talking about pid or lockfiles, which might reside on a
> tmpfs.
>
> Thanks, Mirco
>



-- 
Best regards,
Michal

http://eventhorizon.pl/


More information about the systemd-devel mailing list