This file is indexed.

preinst is in ipplan 4.92a-2.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

 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
99
#!/bin/sh
set -e

# check if we upgrade from a version we have mixed our config with shiped config
if [ "$1" = "upgrade" ] && [ "$2" ] && dpkg --compare-versions "$2" le "4.92a-1"; then
	TMP=`mktemp -d`
	MCONFDIR="/usr/share/ipplan/mconf/"
	OLDCONFFILE="/etc/ipplan/config.php"
	OLDCONFFILETEMP=$TMP"/"`basename $OLDCONFFILE`
	# we do have a config backup, but no origin config
	if [ ! -f "$OLDCONFFILE" -a -f "$OLDCONFFILE".dpkg-bak ]; then
		# so copy the backup to origin config
		cp "$OLDCONFFILE".dpkg-bak "$OLDCONFFILE"
	fi

	# get values from existing config
	confdbtype=`grep DBF_TYPE $OLDCONFFILE | awk -F"'" {'print $2'}`
	confdbserver=`grep DBF_HOST $OLDCONFFILE | awk -F"'" {'print $2'}`
	confdbuser=`grep DBF_USER $OLDCONFFILE | awk -F"'" {'print $2'}`
	confdbname=`grep DBF_NAME $OLDCONFFILE | awk -F"'" {'print $2'}`
	confdbpass=`grep DBF_PASSWORD $OLDCONFFILE | awk -F"'" {'print $2'}`

	# create directory for our own config
	if [ ! -d $MCONFDIR ]; then
		mkdir -p $MCONFDIR
		chown root $MCONFDIR
		chmod 700 $MCONFDIR
	fi

	# create our config files and set secure permissions
	touch $MCONFDIR/db.php
	chown root $MCONFDIR/db.php
	chmod 600 $MCONFDIR/db.php

	# write settings to seperate db.php
	echo "<?php" >> $MCONFDIR/db.php
	echo "// Please don't edit this file, use local_conf.php to overwrite" >> $MCONFDIR/db.php
	echo "// You can change this settings with 'dpkg-reconfigure -plow ipplan'." >> $MCONFDIR/db.php
	# if we got all data
	if [ $confdbtype = "mysql" ] && [ $confdbserver ] && [ $confdbuser ] && [ $confdbname ] && [ $confdbpass ]; then
		# migrate previous settings to seperate db.php
		echo "defined(\"DBF_TYPE\")|| define(\"DBF_TYPE\", '$confdbtype');" >> $MCONFDIR/db.php
		echo "defined(\"DBF_HOST\")|| define(\"DBF_HOST\", '$confdbserver');" >> $MCONFDIR/db.php
		echo "defined(\"DBF_USER\")|| define(\"DBF_USER\", '$confdbuser');" >> $MCONFDIR/db.php
		echo "defined(\"DBF_NAME\")|| define(\"DBF_NAME\", '$confdbname');" >> $MCONFDIR/db.php
		echo "defined(\"DBF_PASSWORD\")|| define(\"DBF_PASSWORD\", '$confdbpass');" >> $MCONFDIR/db.php

		# remove these settings from the existing config
		sed '/^define("DBF_TYPE/d' $OLDCONFFILE > $OLDCONFFILETEMP
		sed -i '/^define("DBF_HOST/d' $OLDCONFFILETEMP
		sed -i '/^define("DBF_USER/d' $OLDCONFFILETEMP
		sed -i '/^define("DBF_NAME/d' $OLDCONFFILETEMP
		sed -i '/^define("DBF_PASSWORD/d' $OLDCONFFILETEMP
	else
		echo "//">> $MCONFDIR/db.php
		echo "// Sorry, wasn't able to migrate your database settings!">> $MCONFDIR/db.php
		echo "// Your database settings should be found in local_conf.php.">> $MCONFDIR/db.php
	fi
	echo "?>" >> $MCONFDIR/db.php

	# if we have a config and was able to strip of database settings
	if [ -r $OLDCONFFILETEMP ]; then
		# create md5sum of our actual config
		md5sum="$(md5sum $OLDCONFFILETEMP | sed -e 's/ .*//')"
		# list of md5sums of all configs since etch (with removed database config)
		old_md5sums="97e0ae5b01f24cf473617dec6fc3fe60 1c9f7955ddc76c300232555a8b3ca80c 25efefcea64c5c87afbe4a7522329d8d a5d713989df3ea8f23f7364c61fa3e26 ff511785e7b164a1d43466d07046c0fb 2be7834668f7b8cfd82331c3adde0402"
		# check if one of our md5sums matches
		for old_md5sum in $old_md5sums; do
			if [ "$md5sum" = "$old_md5sum" ]; then
				unmodified="1"
			fi
		done
	fi
	# migrate config
	echo "<?php" > /etc/ipplan/local_conf.php
	echo "// This file is intended to overwrite system settings by the user" >> /etc/ipplan/local_conf.php
	echo "// Please make your config changes in THIS file" >> /etc/ipplan/local_conf.php
	# config file modified by user
	if [ ! "${unmodified:-0}" = "1" ]; then
		echo "Obsolete conffile $OLDCONFFILE has been modified by you."
		echo "Saving as /etc/ipplan/local_conf.php ..."
		echo "" >> /etc/ipplan/local_conf.php
		echo "// The following settings was taken from your old config and you should" >> /etc/ipplan/local_conf.php
		echo "// consider to keep only lines differing from /usr/share/ipplan/config.php" >> /etc/ipplan/local_conf.php
		# if we got the db settings
		if [ -r $OLDCONFFILETEMP ]; then
			tail --lines=+2 $OLDCONFFILETEMP | grep -v "^//" | grep -v "^$" >> /etc/ipplan/local_conf.php
		# db settings not extracted
		else
			tail --lines=+2 $OLDCONFFILE | grep -v "^//" | grep -v "^$" >> /etc/ipplan/local_conf.php
		fi
		mv -f "$OLDCONFFILE" "$OLDCONFFILE".dpkg-bak
	# config file unmodified by user
	else
		echo "Removing obsolete conffile $OLDCONFFILE ..."
		echo "?>" >> /etc/ipplan/local_conf.php
		mv -f "$OLDCONFFILE" "$OLDCONFFILE".dpkg-del
	fi
fi