Blame scripts/install-cfg.sh

Packit f574b8
#!/bin/sh
Packit f574b8
# $LynxId: install-cfg.sh,v 1.4 2018/03/21 16:20:42 tom Exp $
Packit f574b8
# install lynx.cfg, ensuring the old config-file is saved to a unique file,
Packit f574b8
# and prepending customizations to the newly-installed file.
Packit f574b8
#
Packit f574b8
# $1 = install program
Packit f574b8
# $2 = file to install
Packit f574b8
# $3 = where to install it
Packit f574b8
PRG="$1"
Packit f574b8
SRC=$2
Packit f574b8
DST=$3
Packit f574b8
Packit f574b8
LANG=C;		export LANG
Packit f574b8
LC_ALL=C;	export LC_ALL
Packit f574b8
LC_CTYPE=C;	export LC_CTYPE
Packit f574b8
LANGUAGE=C;	export LANGUAGE
Packit f574b8
Packit f574b8
if test -f "$DST" ; then
Packit f574b8
	echo "** checking if you have customized $DST"
Packit f574b8
	OLD=lynx-cfg.old
Packit f574b8
	NEW=lynx-cfg.new
Packit f574b8
	TST=lynx-cfg.tst
Packit f574b8
	TMP=lynx-cfg.tmp
Packit f574b8
	trap "rm -f $OLD $NEW $TST $TMP; exit 9" 1 2 5 15
Packit f574b8
	rm -f $OLD $NEW $TST $TMP
Packit f574b8
Packit f574b8
	# avoid propagating obsolete URLs into new installs
Packit f574b8
	echo lynx.isc.org >$TMP
Packit f574b8
	echo lynx.browser.org >$TMP
Packit f574b8
	echo www.trill-home.com >>$TMP
Packit f574b8
	echo www.cc.ukans.edu >>$TMP
Packit f574b8
	echo www.ukans.edu >>$TMP
Packit f574b8
	echo www.slcc.edu >>$TMP
Packit f574b8
	echo sol.slcc.edu >>$TMP
Packit f574b8
Packit f574b8
	# Make a list of the settings which are in the original lynx.cfg
Packit f574b8
	# Do not keep the user's HELPFILE setting since we modify that in
Packit f574b8
	# a different makefile rule.
Packit f574b8
	egrep '^[ 	]*[A-Za-z]' $SRC |sed -e 's/^[ 	]*HELPFILE:.*/HELPFILE:/' >>$TMP
Packit f574b8
	egrep '^[ 	]*[A-Za-z]' $SRC |fgrep -v -f $TMP >$OLD
Packit f574b8
	egrep '^[ 	]*[A-Za-z]' $DST |fgrep -v -f $TMP >$TST
Packit f574b8
Packit f574b8
	if test -s $TST ; then
Packit f574b8
		cat >$TMP <
Packit f574b8
## The following lines were saved from your previous configuration.
Packit f574b8
Packit f574b8
EOF
Packit f574b8
		cat $TST >>$TMP
Packit f574b8
		cat $SRC >$NEW
Packit f574b8
		cat $TMP >>$NEW
Packit f574b8
Packit f574b8
		# See if we have saved this information before (ignoring the
Packit f574b8
		# HELPFILE line).
Packit f574b8
		if cmp -s $NEW $OLD
Packit f574b8
		then
Packit f574b8
			echo "... installed $DST would not be changed"
Packit f574b8
		else
Packit f574b8
			NUM=1
Packit f574b8
			while test -f ${DST}-${NUM}
Packit f574b8
			do
Packit f574b8
				if cmp -s $NEW ${DST}-${NUM}
Packit f574b8
				then
Packit f574b8
					break
Packit f574b8
				fi
Packit f574b8
				NUM=`expr $NUM + 1`
Packit f574b8
			done
Packit f574b8
			if test ! -f ${DST}-${NUM}
Packit f574b8
			then
Packit f574b8
				echo "... saving old config as ${DST}-${NUM}"
Packit f574b8
				mv $DST ${DST}-${NUM} || exit 1
Packit f574b8
			fi
Packit f574b8
			echo "** installing $NEW as $DST"
Packit f574b8
			eval $PRG $NEW $DST || exit 1
Packit f574b8
		fi
Packit f574b8
	else
Packit f574b8
		echo "... no customizations found"
Packit f574b8
		echo "** installing $SRC as $DST"
Packit f574b8
		eval $PRG $SRC $DST || exit 1
Packit f574b8
	fi
Packit f574b8
	rm -f $SKIP $OLD $NEW $TST $TMP
Packit f574b8
elif cmp -s $SRC $DST
Packit f574b8
then
Packit f574b8
	echo "... installed $DST would not be changed"
Packit f574b8
else
Packit f574b8
	echo "** installing $SRC as $DST"
Packit f574b8
	eval $PRG $SRC $DST || exit 1
Packit f574b8
fi