Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 95931d60fe986cb88dac43d05c397ef3 > files > 27

gimp-2.2.13-2.0.10.el5.src.rpm

#!/bin/bash

shopt -s nullglob

GIMPTOOL="@GIMPTOOL@"
GIMPPLUGINDIR="`"$GIMPTOOL" --gimpplugindir`"
EXITVAL=0

showhelp () {
	cat << EOF
Usage: gimp-plugin-mgr <mode> [<pluginname> [<pluginname> [...]]
Mode can be:
--install|-i:	install plugin(s)
--uninstall|-u:	uninstall plugin(s)
--help|-h:	show this message
EOF
}

install_uninstall () {
    local action="$1"
    shift
    local plugins="$@"
    pushd "$GIMPPLUGINDIR/plug-ins" >&/dev/null
    if [ "$plugins" == "*" ]; then
        pushd "/etc/gimp/plugins.d" >&/dev/null
        plugins=""
        for file in *; do
            plugins="$plugins ${file%.conf}"
        done
        popd >&/dev/null
    fi

	for plugin in $plugins; do
        PLUGINFILE=
        if [ ! -r "/etc/gimp/plugins.d/${plugin}.conf" ]; then
            echo "gimp-plugin-mgr: can't read /etc/gimp/plugins.d/${plugin}.conf" >&2
            EXITVAL=$(( $EXITVAL + 1 ))
            continue
        fi
        . "/etc/gimp/plugins.d/${plugin}.conf"
        case "$action" in
        install)
            if [ ! "$PLUGINFILE" ]; then
                echo "gimp-plugin-mgr: PLUGINFILE not defined for $plugin" >&2
                EXITVAL=$(( $EXITVAL + 1 ))
                continue
            fi
            ln -snf "$PLUGINFILE" "$GIMPPLUGINDIR/plug-ins/$plugin"
            ;;
        uninstall)
            if [ ! -L "$GIMPPLUGINDIR/plug-ins/$plugin" ]; then
                echo "gimp-plugin-mgr: $GIMPPLUGINDIR/plug-ins/$plugin not a symbolic link" >&2
                EXITVAL=$(( $EXITVAL + 1 ))
                continue
            fi
            rm -f "$plugin"
            ;;
        esac
	done
    popd >&/dev/null
}

case "$1" in
--install|-i)
    shift
	install_uninstall install "$@"
	;;
--uninstall|-u)
    shift
	install_uninstall uninstall "$@"
	;;
*)
	if [ "$1" != "--help" -a "$1" != "-h" ]; then
		EXITVAL=1
	fi
	showhelp
	;;
esac

exit $EXITVAL