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/s3.cnf.new
config etc/my.cnf.d/server.cnf.new
config etc/my.cnf.d/spider.cnf.new
config etc/logrotate.d/mysql.new

# This one is only comments, so remove it if it's left behind:
if [ -r etc/security/user_map.conf.new ]; then
  config etc/security/user_map.conf.new
fi
rm -f etc/security/user_map.conf.new

( cd usr/bin ; rm -rf mariabackup )
( cd usr/bin ; ln -sf mariadb-backup mariabackup )
( cd usr/bin ; rm -rf mariadb-config )
( cd usr/bin ; ln -sf mariadb_config mariadb-config )
( cd usr/bin ; rm -rf mysql )
( cd usr/bin ; ln -sf mariadb mysql )
( cd usr/bin ; rm -rf mysql_client_test )
( cd usr/bin ; ln -sf mariadb-client-test mysql_client_test )
( cd usr/bin ; rm -rf mysql_client_test_embedded )
( cd usr/bin ; ln -sf mariadb-client-test-embedded mysql_client_test_embedded )
( cd usr/bin ; rm -rf mysql_convert_table_format )
( cd usr/bin ; ln -sf mariadb-convert-table-format mysql_convert_table_format )
( cd usr/bin ; rm -rf mysql_embedded )
( cd usr/bin ; ln -sf mariadb-embedded mysql_embedded )
( cd usr/bin ; rm -rf mysql_find_rows )
( cd usr/bin ; ln -sf mariadb-find-rows mysql_find_rows )
( cd usr/bin ; rm -rf mysql_fix_extensions )
( cd usr/bin ; ln -sf mariadb-fix-extensions mysql_fix_extensions )
( cd usr/bin ; rm -rf mysql_install_db )
( cd usr/bin ; ln -sf mariadb-install-db mysql_install_db )
( cd usr/bin ; rm -rf mysql_ldb )
( cd usr/bin ; ln -sf mariadb-ldb mysql_ldb )
( cd usr/bin ; rm -rf mysql_plugin )
( cd usr/bin ; ln -sf mariadb-plugin mysql_plugin )
( cd usr/bin ; rm -rf mysql_secure_installation )
( cd usr/bin ; ln -sf mariadb-secure-installation mysql_secure_installation )
( cd usr/bin ; rm -rf mysql_setpermission )
( cd usr/bin ; ln -sf mariadb-setpermission mysql_setpermission )
( cd usr/bin ; rm -rf mysql_tzinfo_to_sql )
( cd usr/bin ; ln -sf mariadb-tzinfo-to-sql mysql_tzinfo_to_sql )
( cd usr/bin ; rm -rf mysql_upgrade )
( cd usr/bin ; ln -sf mariadb-upgrade mysql_upgrade )
( cd usr/bin ; rm -rf mysql_waitpid )
( cd usr/bin ; ln -sf mariadb-waitpid mysql_waitpid )
( cd usr/bin ; rm -rf mysqlaccess )
( cd usr/bin ; ln -sf mariadb-access mysqlaccess )
( cd usr/bin ; rm -rf mysqladmin )
( cd usr/bin ; ln -sf mariadb-admin mysqladmin )
( cd usr/bin ; rm -rf mysqlbinlog )
( cd usr/bin ; ln -sf mariadb-binlog mysqlbinlog )
( cd usr/bin ; rm -rf mysqlcheck )
( cd usr/bin ; ln -sf mariadb-check mysqlcheck )
( cd usr/bin ; rm -rf mysqld_multi )
( cd usr/bin ; ln -sf mariadbd-multi mysqld_multi )
( cd usr/bin ; rm -rf mysqld_safe )
( cd usr/bin ; ln -sf mariadbd-safe mysqld_safe )
( cd usr/bin ; rm -rf mysqld_safe_helper )
( cd usr/bin ; ln -sf mariadbd-safe-helper mysqld_safe_helper )
( cd usr/bin ; rm -rf mysqldump )
( cd usr/bin ; ln -sf mariadb-dump mysqldump )
( cd usr/bin ; rm -rf mysqldumpslow )
( cd usr/bin ; ln -sf mariadb-dumpslow mysqldumpslow )
( cd usr/bin ; rm -rf mysqlhotcopy )
( cd usr/bin ; ln -sf mariadb-hotcopy mysqlhotcopy )
( cd usr/bin ; rm -rf mysqlimport )
( cd usr/bin ; ln -sf mariadb-import mysqlimport )
( cd usr/bin ; rm -rf mysqlshow )
( cd usr/bin ; ln -sf mariadb-show mysqlshow )
( cd usr/bin ; rm -rf mysqlslap )
( cd usr/bin ; ln -sf mariadb-slap mysqlslap )
( cd usr/bin ; rm -rf mysqltest )
( cd usr/bin ; ln -sf mariadb-test mysqltest )
( cd usr/bin ; rm -rf mysqltest_embedded )
( cd usr/bin ; ln -sf mariadb-test-embedded mysqltest_embedded )
( cd usr/bin ; rm -rf wsrep_sst_rsync_wan )
( cd usr/bin ; ln -sf wsrep_sst_rsync wsrep_sst_rsync_wan )
( cd usr/lib64 ; rm -rf libmariadb.so )
( cd usr/lib64 ; ln -sf libmariadb.so.3 libmariadb.so )
( cd usr/lib64 ; rm -rf libmariadbd.so )
( cd usr/lib64 ; ln -sf libmariadbd.so.19 libmariadbd.so )
( cd usr/lib64 ; rm -rf libmysqlclient.so )
( cd usr/lib64 ; ln -sf libmariadb.so.3 libmysqlclient.so )
( cd usr/lib64 ; rm -rf libmysqlclient_r.so )
( cd usr/lib64 ; ln -sf libmariadb.so.3 libmysqlclient_r.so )
( cd usr/lib64 ; rm -rf libmysqld.so )
( cd usr/lib64 ; ln -sf libmariadbd.so.19 libmysqld.so )
( cd usr/libexec ; rm -rf mysqld )
( cd usr/libexec ; ln -sf mariadbd mysqld )
