This file is indexed.

postinst is in frontaccounting 2.2.10-3.

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
#!/bin/sh
# postinst script for frontaccounting

set -e

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

lighttpd_install() {
	if [ ! -f /etc/lighttpd/conf-available/50-frontaccounting.conf ] ; then
		if which lighty-enable-mod >/dev/null 2>&1 ; then
			ln -s /etc/frontaccounting/lighttpd.conf /etc/lighttpd/conf-available/50-frontaccounting.conf
		else
			echo "Lighttpd not installed, skipping"
		fi
	fi
}

apache_install() {
	webserver=$1
	if [ -d /etc/$webserver/conf.d ] && [ ! -e /etc/$webserver/conf.d/frontaccounting.conf ]; then
		ln -s /etc/frontaccounting/apache.conf /etc/$webserver/conf.d/frontaccounting.conf
	fi
}

get_db_params () {
        db_get "frontaccounting/db_host"
        dbserver="$RET"
        db_get "frontaccounting/db_name"
        dbname="$RET"
        db_get "frontaccounting/db_prefix"
        dbprefix="$RET"
        if [ "$RET" != "false" ]; then
                dbprefix="0_";
        else
                dbprefix="";
        fi
        db_get "frontaccounting/db_admin_user"
        dbadmin="$RET"
        db_get "frontaccounting/db_admin_pass"
        dbadmpass="$RET"
        db_get "frontaccounting/db_user"
        dbuser="$RET"
        db_get "frontaccounting/db_pass"
        dbpass="$RET"
        dbtype=mysql
        db_get "frontaccounting/company"
        company="$RET"
        db_get "frontaccounting/db_fadmin_pass"
        fa_pass="$RET"
        db_get "frontaccounting/db_fadmin_email"
        fa_email="$RET"
        db_get "frontaccounting/db_demo"
        if [ "$RET" != "false" ]; then
                coa_script="en_US-demo.sql";
        else
                coa_script="en_US-new.sql";
        fi
}


. /usr/share/debconf/confmodule

if [ -d /usr/share/frontaccounting/modules ]; then
	chown -R www-data:www-data /usr/share/frontaccounting/modules
fi

if [ -d /usr/share/frontaccounting/lang ]; then
	chown -R www-data:www-data /usr/share/frontaccounting/lang
fi

if [ -d /usr/share/frontaccounting/company ]; then
	chown -R www-data:www-data /usr/share/frontaccounting/company
fi

if [ "$1" = "configure" ]; then

	db_version 2.0

	config="/etc/frontaccounting/config_db.php"
	template="/usr/share/frontaccounting/config_db.php.template"


	# Configure webserver
	db_get frontaccounting/webserver

	webservers="$RET"

	. /usr/share/wwwconfig-common/php.get
        . /usr/share/wwwconfig-common/apache-run.get

	for webserver in $webservers; do
		webserver=${webserver%,}
		if [ "$webserver" = "lighttpd" ] ; then
			lighttpd_install
		else
			apache_install $webserver
		fi
		# Reload webserver
		if [ -x /usr/sbin/invoke-rc.d ]; then
			invoke-rc.d $webserver reload 3>/dev/null || true
		else
			/etc/init.d/$webserver reload 3>/dev/null || true
		fi
	done

		db_get "frontaccounting/restart-webserver"
		if [ "$RET" != "false" ]; then
			restart="${servers}"
			. /usr/share/wwwconfig-common/restart.sh
		fi

		# setup the db

                db_get "frontaccounting/db_initialized"
                dbinitialized="$RET" || true
                db_get "frontaccounting/skipdb"
                skipdb="$RET"
                if [ "$skipdb" != "true" ]; then 
                    get_db_params
                    if [ "$db_initialized" != "true" ]; then 
                        . /usr/share/wwwconfig-common/mysql-createdb.sh
                        . /usr/share/wwwconfig-common/mysql-createuser.sh
                        . /usr/share/wwwconfig-common/mysql.get
                        # Substitute table prefix
                        sqlfile="/usr/share/frontaccounting/sql/${coa_script}"
						varscript="s#0_#${dbprefix}#g;";
						sed $varscript < $sqlfile | $(eval $mysqlcmd -D ${dbname} -s)
                        # Expand our config file
                        varscript="s#{DB_USER}#${dbuser}#g;s#{DB_PASS}#${dbpass}#g;s#{DB_HOST}#${dbserver}#g;s#{DB_NAME}#${dbname}#g;s#{DB_PREFIX}#${dbprefix}#g;s#{DB_COMPANY}#${company}#g;";
                        sed $varscript < $template > $config
                        chown www-data:root $config
                        chmod 640 $config
						rm $template
                        db_set "frontaccounting/db_initialized" true
                    fi  # $db_initialized
					# update company name and FA admin password
                    dbadmin=${dbuser}
                    dbadmpass=${dbpass}
                    . /usr/share/wwwconfig-common/mysql.get
                    $(eval $mysqlcmd -D ${dbname} -e "'UPDATE ${dbprefix}users SET password = MD5(\"${fa_pass}\"), email = \"${fa_email}\" WHERE user_id =\"admin\";'" -s)
                    $(eval $mysqlcmd -D ${dbname} -e "'UPDATE ${dbprefix}company SET coy_name = \"${company}\" WHERE coy_code = 1;'" -s)
                fi # $skipdb

		# erase db admin password
		if [ "$skipdb" != "true" ]; then 
			db_reset "frontaccounting/db_admin_pass"
		fi
fi



db_stop

exit 0