preinst is in moodle 3.0.3+dfsg-0ubuntu1.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/bin/sh
set -e
case "$1" in
  install|upgrade)
    if dpkg --compare-versions "$2" lt "2.2.3.dfsg-2.4"; then
      # Make sure the new Moodle can install its files in yui - #689506
      if [ -h /usr/share/moodle/lib/yui ] ; then
        rm -f /usr/share/moodle/lib/yui
      fi
    fi
    if dpkg --compare-versions "$2" lt "2.5.1-1"; then
      # Remove directories we're going to replace with symlinks
      if [ -d /usr/share/moodle/lib/adodb ]; then
        rm -rf /usr/share/moodle/lib/adodb
      fi
      if [ -d /usr/share/moodle/lib/htmlpurifier/HTMLPurifier ]; then
        rm -rf /usr/share/moodle/lib/htmlpurifier/HTMLPurifier
      fi
    fi
    if dpkg --compare-versions "$2" eq "2.5.3-3"; then
      # Remove symlink
      if [ -L /usr/share/moodle/lib/yuilib/3.9.1/build ]; then
        rm -f /usr/share/moodle/lib/yuilib/3.9.1/build
      fi
    fi
  ;;
esac
 |