config() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
    # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

# Keep same perms on rc.mysqld.new:
if [ -e etc/rc.d/rc.mysqld ]; then
  cp -a etc/rc.d/rc.mysqld etc/rc.d/rc.mysqld.new.incoming
  cat etc/rc.d/rc.mysqld.new > etc/rc.d/rc.mysqld.new.incoming
  mv etc/rc.d/rc.mysqld.new.incoming etc/rc.d/rc.mysqld.new
fi

config etc/rc.d/rc.mysqld.new
config etc/mysqlaccess.conf.new
config etc/my.cnf.new
config etc/my.cnf.d/client.cnf.new
config etc/my.cnf.d/mysql-clients.cnf.new
config etc/my.cnf.d/server.cnf.new
config etc/logrotate.d/mysql.new

echo "Read /etc/rc.d/rc.mysqld on how to prepare and start mariadb!!"

# update rarian database
if [ -x usr/bin/rarian-sk-update ]; then
  usr/bin/rarian-sk-update 1> /dev/null 2> /dev/null
fi

# update mime database
if [ -x usr/bin/update-mime-database ]; then
  usr/bin/update-mime-database usr/share/mime 1> /dev/null 2> /dev/null
fi

# update desktop entries
if [ -x usr/bin/update-desktop-database ]; then
  usr/bin/update-desktop-database 1> /dev/null 2> /dev/null
fi

# update hicolor icons
if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
	rm -f usr/share/icons/hicolor/icon-theme.cache
fi
usr/bin/gtk-update-icon-cache -f -q usr/share/icons/hicolor 1>/dev/null 2>/dev/null

if [ -x /usr/bin/glib-compile-schemas ]; then
  /usr/bin/glib-compile-schemas usr/share/glib-2.0/schemas/ >/dev/null 2>&1
fi

# Restart gconfd-2 if running to reload new gconf settings
if ps acx | grep -q gconfd-2 ; then
        killall -HUP gconfd-2 ;
fi

# A good idea whenever kernel modules are added or changed:
if [ -x sbin/depmod ]; then
  /sbin/depmod -a 1> /dev/null 2> /dev/null
fi

( cd usr/lib ; rm -rf libmysqlclient.so.18 )
( cd usr/lib ; ln -sf libmysqlclient.so.18.0.0 libmysqlclient.so.18 )
( cd usr/lib ; rm -rf libmysqlclient_r.so )
( cd usr/lib ; ln -sf libmysqlclient.so libmysqlclient_r.so )
( cd usr/lib ; rm -rf libmysqld.so )
( cd usr/lib ; ln -sf libmysqld.so.18 libmysqld.so )
( cd usr/lib ; rm -rf libmysqlclient_r.so.18 )
( cd usr/lib ; ln -sf libmysqlclient.so libmysqlclient_r.so.18 )
( cd usr/lib ; rm -rf libmysqlclient.so )
( cd usr/lib ; ln -sf libmysqlclient.so.18 libmysqlclient.so )
( cd usr/lib ; rm -rf libmysqlclient_r.so.18.0.0 )
( cd usr/lib ; ln -sf libmysqlclient.so libmysqlclient_r.so.18.0.0 )
( cd etc/init.d ; rm -rf mysql )
( cd etc/init.d ; ln -sf /etc/rc.d/rc.mysqld mysql )
