#!/bin/sh set -e error() { echo "$*" 1>&2 } old_dir=/usr/lib/frei0r-1 new_dir="$(dpkg -L frei0r-plugins | grep '^/usr/lib/[^/]*/frei0r-1/.*\.so$' | head -1 | sed -e 's|/[^/]*$||')" if [ ! -L "${old_dir}" ] && [ -d "${old_dir}" ]; then # /usr/lib/frei0r-1 is still a directory, but should be a symlink error "frei0r-plugins: migrating '${old_dir}' to '${new_dir}'" # if there are any left-over plugins in the directory, move them to the new destination for f in "${old_dir}"/*; do test -e "${f}" || continue mv -v "${f}" "${new_dir}" done # remove the olddir if rmdir "${old_dir}"; then # and symlink it to the new one ln --symbolic --verbose "${new_dir#/usr/lib/}" "${old_dir}" else error "FAILED to remove '${old_dir}'" fi fi