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...
}

config etc/udev/rules.d/99-megasync-udev.rules.new
config etc/sysctl.d/99-megasync-inotify-limit.conf.new

if [ -x /usr/bin/update-desktop-database ]; then
  /usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1
fi

if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
  if [ -x /usr/bin/gtk-update-icon-cache ]; then
    /usr/bin/gtk-update-icon-cache -f -q usr/share/icons/hicolor >/dev/null 2>&1
  fi
fi
( cd opt/megasync/lib ; rm -rf libavcodec.so )
( cd opt/megasync/lib ; ln -sf libavcodec.so.61.19.101 libavcodec.so )
( cd opt/megasync/lib ; rm -rf libavcodec.so.61 )
( cd opt/megasync/lib ; ln -sf libavcodec.so.61.19.101 libavcodec.so.61 )
( cd opt/megasync/lib ; rm -rf libavformat.so )
( cd opt/megasync/lib ; ln -sf libavformat.so.61.7.100 libavformat.so )
( cd opt/megasync/lib ; rm -rf libavformat.so.61 )
( cd opt/megasync/lib ; ln -sf libavformat.so.61.7.100 libavformat.so.61 )
( cd opt/megasync/lib ; rm -rf libavutil.so )
( cd opt/megasync/lib ; ln -sf libavutil.so.59.39.100 libavutil.so )
( cd opt/megasync/lib ; rm -rf libavutil.so.59 )
( cd opt/megasync/lib ; ln -sf libavutil.so.59.39.100 libavutil.so.59 )
( cd opt/megasync/lib ; rm -rf libswresample.so )
( cd opt/megasync/lib ; ln -sf libswresample.so.5.3.100 libswresample.so )
( cd opt/megasync/lib ; rm -rf libswresample.so.5 )
( cd opt/megasync/lib ; ln -sf libswresample.so.5.3.100 libswresample.so.5 )
( cd opt/megasync/lib ; rm -rf libswscale.so )
( cd opt/megasync/lib ; ln -sf libswscale.so.8.3.100 libswscale.so )
( cd opt/megasync/lib ; rm -rf libswscale.so.8 )
( cd opt/megasync/lib ; ln -sf libswscale.so.8.3.100 libswscale.so.8 )
