File: postinst

package info (click to toggle)
yard 1.17.patch1-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 600 kB
  • ctags: 74
  • sloc: perl: 1,729; sh: 250; makefile: 176; asm: 32
file content (98 lines) | stat: -rw-r--r-- 2,771 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh

set -e

timestamp=`date +"%y%m%d%H%M%S"`
YARDBIN="/usr/share/yard"
YARDBINBACK="/usr/share/yard.off"
YARDETC="/etc/yard"
YARDETCBACK="/etc/yard$timestamp"
YARDLOG="/var/log/yard"
YARDCONFLOG="$YARDLOG/yard.inst.log"
YARDDOC="/usr/share/doc/yard"
YARDFIRST="/sbin/make_root_fs"
goahead=0

install-info --description='Build a rescue disk system.' \
             --quiet /usr/info/yard.info

mkdir -p -m 0700 $YARDLOG

# even for a fake installation we need $YARDETC
if [ ! -e "$YARDETC" ]; then
	mkdir $YARDETC
fi

VERSION=`uname -r`
MAINVERSION=`expr substr $VERSION 1 1`

if [ "$MAINVERSION" -lt 2 ]; then
	echo "Sorry, kernel too old!" 1>&2
	exit -1
fi

# according to rules programme will be installed in /usr/share/yard
cd $YARDBIN

# use our prepared configuration
rm Bootdisk_Contents.in
mv Bootdisk_Contents.in.debian Bootdisk_Contents.in
rm Config.pl.in
mv Config.pl.in.debian Config.pl.in

if [ -L /vmlinuz ]; then
	kernelfile=`file /vmlinuz | cut -f5 -d" "`
	kernelfile="/$kernelfile"
	if [ "$VERSION" != "`file -b -m kernel.magic $kernelfile`" ]; then
		echo "Sorry, the next kernel you'll booting has a different version compared to"
		echo "                 the one you're currently running!"
		echo
		echo "Please reboot and start /usr/share/yard/conf_yard to finally configure it "
		echo "automatically. Please see also the docs for more details."
		echo
		echo "Press return to continue"
		read dummy
  	goahead=1
	fi
fi

if [ "$goahead" -eq "0" ]; then
	if [ ! -d "/lib/modules/$VERSION" ]; then
		echo "Sorry, the corresponding modules directory to your $VERSION kernel doesn't"
		echo "exist. If you are in the process of upgrading your kernel please reboot"
		echo "and configure yard by calling /usr/share/yard/conf_yard."
		echo "Otherwise please rename your modules directory to /lib/modules/$VERSION"
		echo "and start the configuration of yard again."
		echo "See docs for more details."
		echo
		echo "Press return to continue"
		read dummy
		goahead=1
	fi
fi

if [ "$goahead" -eq "0" ]; then
	if [ -e $YARDFIRST ]; then
		# ok, we have been installed before
		if [ -n `grep "not really YARD" $YARDFIRST` ]; then
			# reinstallation (last was successful)
			rm -f "$YARDFIRST.old"
			mv $YARDFIRST "$YARDFIRST".old
		else
			# reinstallation (last was unsuccessful)
			rm -f "$YARDFIRST"
		fi
	fi
	/usr/share/yard/conf_yard
else
	# move old binary away and replace it by cat of readme
	if [ ! -e "$YARDFIRST.old" ]; then
		if [ -e $YARDFIRST ]; then
			mv /sbin/make_root_fs /sbin/make_root_fs.old
		fi
	fi
	echo "#!/bin/sh" > $YARDFIRST
	echo "# not really YARD; call /usr/share/yard/conf_yard to configure yard and replace this file" >>  $YARDFIRST
	echo "cat $YARDDOC/README.Debian" >> $YARDFIRST
	chmod 0700 /sbin/make_root_fs
fi