File SuSEconfig.groff of Package gxditview.import4718

#
# Copyright (c) 1998 S.u.S.E. Gmbh Fuerth, Germany.
#               2002 SuSE Linux AG, Nuernberg, Germany.
#
# please send bugfixes or comments to <feedback@suse.de>
#
# Authors: Werner Fink, <werner@suse.de>
#          Mike Fabian <mfabian@suse.de>

# only one of UID and USER must be set correctly
if test "$UID" != 0 -a "$USER" != root; then
    echo "You must be root to start $0."
    exit 1
fi

test -f $ROOT/etc/sysconfig/suseconfig || {
    echo "No /etc/sysconfig/suseconfig found." && exit 1 ;
}
. $ROOT/etc/sysconfig/suseconfig

test -f /lib/YaST/SuSEconfig.functions || {
        echo "ERROR - can not find /lib/YaST/SuSEconfig.functions!!"
        echo "This should not happen.  Exit..."
        exit 1
}
. /lib/YaST/SuSEconfig.functions

test -n "$UPDATE_GROFF_CONF" -a "$UPDATE_GROFF_CONF" = "no" && {
    echo "Warning: UPDATE_GROFF_CONF is deprecated and might be removed in future"
    echo "SuSEconfig.groff no longer rewrites user modified /etc/papersize"
}

test -n "$UPDATE_GROFF_CONF" -a "$UPDATE_GROFF_CONF" = "yes" || exit 0

function get_paper () {
    (
	. /etc/sysconfig/language &> /dev/null
	read h w r < <(LANG=$RC_LANG LC_ALL=$RC_LC_ALL LC_PAPER=$RC_LC_PAPER locale -k LC_PAPER)
	case "$h" in
	    height=297) echo a4	    ;;
	    *)		echo letter ;;
	esac
    )
}

# first get the paper size from the locale information
PAPER_SIZE=$(get_paper)

# if GROFF_PAGESIZE is set, it overrides the locale information:
if [ -n "$GROFF_PAGESIZE" ] ; then
    echo "Warning: GROFF_PAGESIZE is deprecated and might be removed in future"
    echo "Use RC_LANG or RC_LC_PAPER in /etc/sysconfig/language"
    echo "or write the value to /etc/papersize, it will not be overwritten"
    # make GROFF_PAGESIZE lower case only:
    GROFF_PAGESIZE=$( echo $GROFF_PAGESIZE | tr '[:upper:]' '[:lower:]' )
    case $GROFF_PAGESIZE in
	a4|letter)
	    PAPER_SIZE=$GROFF_PAGESIZE
	;;
	*)
            echo "illegal value of GROFF_PAGESIZE, using 'a4' instead."
            PAPER_SIZE=a4
        ;;
    esac
fi

echo "$PAPER_SIZE" > /etc/papersize.SuSEconfig
check_md5_and_move /etc/papersize 

exit 0