All pastes #512662 Raw Edit

Unnamed

public text v1 · immutable
#512662 ·published 2007-05-26 23:58 UTC
rendered paste body
#Some functions for handling .new files
#was taken from various Slackware doinst.sh
testargs()
{
    case "$OPENBOXREPLACEOPTION" in
        P|R|p|r)
        REPLACECONFIG=99;
        ;;
    esac;
}

config_mangle()
{
    NEW="$1";
    OLD="$(dirname $NEW)/$(basename $NEW .new)";
    if [ ! -e "$OLD" ]; then
        mv "$NEW" "$OLD";
    elif [ "$(cat $NEW | md5sum)" = "$(cat $OLD | md5sum)" ]; then
        rm "$NEW"
    elif [ -e "$OLD" ]; then
        echo "There is a previous $(basename $1 .new) config detected in /etc/xdg/openbox.";
        echo "What would you like to do with the new config files?";
        echo "Preserve keeps the new config as $(basename $1) for later actions";
        echo -n "Replace(R) or Preserve(P): ";
        read OPENBOXREPLACEOPTION;
        testargs;
        while [ "$REPLACECONFIG" != 99 ] ; do
            echo -n "Replace(R) or Preserve(P): ";
            read OPENBOXREPLACEOPTION;
            testargs
        done;            
        case "$OPENBOXREPLACEOPTION" in
        R|r)
        mv -f "$NEW" "$OLD";
        ;;
        *)
        :;
        ;;
    esac;
    fi;
}

config_mangle etc/xdg/openbox/menu.xml.new
echo;
config_mangle etc/xdg/openbox/rc.xml.new