This file is indexed.

postinst is in netmrg 0.20-7.

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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#! /bin/sh
# postinst script for netmrg
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#

. /usr/share/debconf/confmodule

if [ "$DPKG_DEBUG" = "developer" ]; then
	set -x
fi

if ! id netmrg > /dev/null 2>&1; then
	adduser --system --ingroup www-data --home /var/lib/netmrg --shell /bin/bash --gecos netmrg netmrg
else
	# There has been previous inoffical version where the shell had been
	# set to /bin/false. This causes problems when running the crontab entry.
	chsh -s /bin/bash netmrg
fi

get_db_params () {
  db_get "netmrg/db/host"
  dbserver="$RET"
  db_get "netmrg/db/name"
  dbname="$RET"
  db_get "netmrg/db/admin/name"
  dbadmin="$RET"
  db_get "netmrg/db/admin/password"
  dbadmpass="$RET"
  db_get "netmrg/db/user/name"
  dbuser="$RET"
  db_get "netmrg/db/user/password"
  dbpass="$RET"
  db_get "netmrg/web/host"
  webhost="$RET"
  db_get "netmrg/company/name"
  companyname="$RET"
  db_get "netmrg/company/link"
  companylink="$RET"
}

case "$1" in
    configure)

			chown -R netmrg:www-data /var/lib/netmrg
			chown -R netmrg:www-data /var/log/netmrg
			if [ ! -d "/var/lib/netmrg/sessions" ] ; then
				mkdir -p /var/lib/netmrg/sessions
			fi
			chown -R www-data:www-data /var/lib/netmrg/sessions
			chmod 700 /var/lib/netmrg/sessions

			config="/etc/netmrg/netmrg.xml"
			if [ -s $config ] ; then
				template=$config
			else
				template="/usr/share/netmrg/netmrg.xml.sample"
			fi

			# Get the web server type.
			db_get "netmrg/webserver"
			webserver="$RET"
			case $webserver in
				Apache2)		webservers="apache2" ;;
				Apache)		webservers="apache" ;;
				Apache-SSL)	webservers="apache-ssl" ;;
				All)		webservers="apache2 apache apache-ssl" ;;
				*)		webservers="" ;;
			esac
			. /usr/share/wwwconfig-common/php.get
			. /usr/share/wwwconfig-common/apache-run.get

			# Set up web server.
			for server in $webservers ; do
				# prefer conf.d over monolithic form
				if [ -d "/etc/${server}/conf.d" ] ; then
					rm -f "/etc/${server}/conf.d/netmrg.conf"
					if [ ! -e "/etc/${server}/conf.d/netmrg.conf" ] ; then
						ln -s /etc/netmrg/netmrg.conf "/etc/${server}/conf.d/netmrg.conf"
					fi
					restart="$server $restart"
				else
					includefile="/etc/netmrg/netmrg.conf"
					. /usr/share/wwwconfig-common/apache-include_all.sh
					test "$status" = "uncomment" -o "$status" = "include" && restart="$server $restart"
				fi
				
				for index in index.php; do
					. /usr/share/wwwconfig-common/apache-index_all.sh
					test "$status" = "added" && restart="$server $restart"
				done
			done

			# Setup the database.
			get_db_params
			. /usr/share/wwwconfig-common/mysql-createdb.sh
			dbcreatestatus=$status
			if [ "$status" = "create" ]; then
				if eval $mysqlcmd -f mysql -e '"select User from user;"' | grep $dbuser >/dev/null 2>&1 ; then
					userexists=true
				else
					userexists=false
				fi
				. /usr/share/wwwconfig-common/mysql-createuser.sh
				if [ "$status" != "error" ]; then
					# Check for one table
					if ! eval $mysqlcmd $dbname -e '"show tables;"' | grep graphs >/dev/null 2>&1 ; then
						if ! eval $mysqlcmd $dbname < /usr/share/netmrg/db/netmrg.mysql > /dev/null 2>&1 ; then
							status=error
						else
							status=exec
						fi
						if [ "$status" != "exec" ]; then
							db_fset netmrg/db/tablegen_error seen false
							db_input high netmrg/db/tablegen_error || true
							db_go
							. /usr/share/wwwconfig-common/mysql-dropdb.sh
							if [ "$userexists" != "true" ]; then
								. /usr/share/wwwconfig-common/mysql-dropuser.sh
							fi
						fi
					fi

				else
					db_reset "netmrg/db/admin/password"
					db_fset netmrg/db/usergen_error seen false
					db_input high netmrg/db/usergen_error || true
					db_go
					# Only delete the database when it was created in this script
					if [ $dbcreatestatus = "create" ] ; then
						. /usr/share/wwwconfig-common/mysql-dropdb.sh
					fi
				fi

			elif [ "$status" = "nothing" ]; then
				# run createuser in case the password has been changed during
				# a reconfiguration of the package
				. /usr/share/wwwconfig-common/mysql-createuser.sh
				oldvers=$(eval "$mysqlcmd $dbname -e 'select module, version from versioninfo'" | grep Main | awk '{print $2}')
				if [ -f /usr/share/doc/netmrg/update-from-$oldvers.sql ] ; then
					echo "Updating from version $oldvers."
					sqlfile=/usr/share/doc/netmrg/update-from-$oldvers.sql
					. /usr/share/wwwconfig-common/mysql-exec.sh
					if [ $status = "execerror" ] ; then
						echo "Updating from version $oldvers failed!"
					fi
				else
					echo "No update for database needed."
				fi
			else
				db_reset "netmrg/db/admin/password"
				db_fset netmrg/db/generation_error seen false
				db_input high netmrg/db/generation_error || true
				db_go
			fi

			# Everything fine so far. Now create an new config file
			TEMPFILE=`tempfile -s .netmrg_install.tmp` && chown root:www-data $TEMPFILE && chmod 640 $TEMPFILE
			sed "s:^\(.*\)<host>\(.*\)</host>:\1<host>$dbserver</host>:g" $template | \
			sed "s:^\(.*\)<user>\(.*\)</user>:\1<user>$dbuser</user>:g" | \
			sed "s|^\(.*\)<password>\(.*\)</password>|\1<password>$dbpass</password>|g" | \
			sed "s:^\(.*\)<db>\(.*\)</db>:\1<db>$dbname</db>:g" | \
			sed "s|^\(.*\)<webhost>\(.*\)</webhost>|\1<webhost>$webhost</webhost>|g" | \
			sed "s|^\(.*\)<webroot>\(.*\)</webroot>|\1<webroot>/netmrg</webroot>|g" | \
			sed "s|^\(.*\)<company>\(.*\)</company>|\1<company>$companyname</company>|g" | \
			sed "s|^\(.*\)<companylink>\(.*\)</companylink>|\1<companylink>$companylink</companylink>|g" > \
			$TEMPFILE && mv $TEMPFILE $config

			# Restart the servers that need to be restarted
			servers="apache-ssl apache apache2 mysql"
			. /usr/share/wwwconfig-common/restart.sh

    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.



exit 0