File: initscripts.preinst

package info (click to toggle)
sysvinit 2.88dsf-13.1%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,512 kB
  • ctags: 808
  • sloc: ansic: 8,578; sh: 3,486; perl: 535; makefile: 364
file content (65 lines) | stat: -rw-r--r-- 1,674 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /bin/sh
#
# initscripts preinst
#

set -e

# Remove a no-longer used conffile
#
# $1: conffile
#
# If the argument was not listed as a conffile, silently do nothing.
# Adapted from code obtained from http://wiki.debian.org/DpkgConffileHandling
eliminate_conffile() {
	PKGNAME="initscripts"
	CONFFILE="$1"

	if [ -e "$CONFFILE" ]; then
		CURRENT_MD5SUM="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
		FACTORY_MD5SUM="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE'{s/ obsolete$//;s/.* //p}\"`"
		if [ "$CURRENT_MD5SUM" != "$FACTORY_MD5SUM" ]; then
			echo "Obsolete conffile $CONFFILE has been modified by you."
			echo "Saving as $CONFFILE.dpkg-old ..."
			mv -f "$CONFFILE" "$CONFFILE".dpkg-old
		else
			echo "Removing unmodified and obsolete conffile $CONFFILE ..."
			rm -f "$CONFFILE"
		fi
	fi
}

case "$1" in
  install|upgrade)
	#
	# /etc/init.d/stop-bootlogd used to be a symlink to bootlogd;
	# now it is a separate script.  We need to remove the symlink here,
	# before dpkg installs the /etc/init.d/stop-bootlogd file.
	#
	[ -L /etc/init.d/stop-bootlogd ] && rm -f /etc/init.d/stop-bootlogd
	#
	# Remove obsolete conffiles
	#
	if [ "$2" ] && dpkg --compare-versions "$2" lt "2.86.ds1-10" ; then
		eliminate_conffile "/etc/init.d/bootclean.sh"
	fi
	#
	# The /etc/init.d/bootclean script fragment was moved to
	# /lib/init/ in version 2.86.ds1-39
	#
	if [ "$2" ] && dpkg --compare-versions "$2" lt "2.86.ds1-54" ; then
		eliminate_conffile "/etc/init.d/bootclean"
	fi
	#
	# Move conflicting log _file_ if present
	#
	[ -f /var/log/fsck ] && mv -f /var/log/fsck /var/log/fsck.dpkg-old
	;;
  abort-upgrade)
	exit 0
	;;
esac

#DEBHELPER#

: