Projekt

Allgemein

Profil

Herunterladen (4,72 KB) Statistiken
| Zweig: | Markierung: | Revision:
#!/bin/bash
# postinst script for lx-office-erp-svn
#
# see: dh_installdeb(1)

# e = exit on error
set -e
# x = xtrace
#set -x
echo "! Postinst $1 !"

source /usr/share/debconf/confmodule

# 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>
# * <postinst> `abort-remove'
# * <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


config_postgresql_factory_script() {

echo "Starting factory postgresql config script: scripts/inst_postgres.sh.."

cd /usr/lib/lx-office-erp/

./scripts/inst_postgres_deb.sh

echo "Factory postgresql config script done."
}


config_postgresql_accounts_sec() {

POSTGRESQL_PG_HBA_CONF="/etc/postgresql/8.3/main/pg_hba.conf"

echo "# added by lx-office-erp postinst-script" >> $POSTGRESQL_PG_HBA_CONF
echo "host all lx_office_erp 127.0.0.1 255.255.255.0 password" >> $POSTGRESQL_PG_HBA_CONF

/etc/init.d/postgresql* reload
}


config_postgresql_roles() {

echo "CREATE USER lx_office_erp with CREATEDB ;" > /tmp/lxdb-install.sql

db_get lx-office-erp/lx-office-erp-user-postgresql-password
POSTGRES_LX_OFFICE_ERP_USER_PASSWORD="$RET"

echo "ALTER USER lx_office_erp PASSWORD '$POSTGRES_LX_OFFICE_ERP_USER_PASSWORD' ;" \
>> /tmp/lxdb-install.sql

echo "UPDATE pg_language SET lanpltrusted = true WHERE lanname = 'plpgsql';" >> /tmp/lxdb-instal.sql

su postgres -c "psql --dbname template1 < /tmp/lxdb-install.sql"

/etc/init.d/postgresql* reload
}



config_postgresql_sql_routines() {

PLPGSQL="/usr/lib/postgresql/8.3/lib/plpgsql.so"
echo "CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler" > /tmp/lxdb-install.sql
echo "AS '$PLPGSQL', 'plpgsql_call_handler'" >> /tmp/lxdb-install.sql
echo "LANGUAGE c;" >> /tmp/lxdb-install.sql
echo "CREATE PROCEDURAL LANGUAGE plpgsql HANDLER plpgsql_call_handler;" >> /tmp/lxdb-install.sql
su postgres -c "psql --dbname template1 < /tmp/lxdb-install.sql"

/etc/init.d/postgresql-8.3 reload
}


set_lx_office_erp_web_admin_password() {

db_get lx-office-erp/admin-password
ADMINPASSWORD="$RET"

cat /usr/lib/lx-office-erp/config/authentication.pl.default | \
sed --expression "s/\$self->{admin_password} = 'admin';/\$self->{admin_password} = '$ADMINPASSWORD';/g" \
> /tmp/1.txt

mv /tmp/1.txt /usr/lib/lx-office-erp/config/authentication.pl

chmod 0600 /usr/lib/lx-office-erp/config/authentication.pl
chown www-data:www-data /usr/lib/lx-office-erp/config/authentication.pl

}


set_lx_office_erp_authentication_db_password() {
db_get lx-office-erp/lx-office-erp-user-postgresql-password
PASSWORD="$RET"

cat /usr/lib/lx-office-erp/config/authentication.pl | \
sed --expression "s/'password' => '',/'password' => '$PASSWORD',/g" \
> /tmp/1.txt

mv /tmp/1.txt /usr/lib/lx-office-erp/config/authentication.pl

}

set_lx_office_erp_authentication_db_user() {
USER="lxoffice"

cat /usr/lib/lx-office-erp/config/authentication.pl | \
sed --expression "s/'user' => 'postgres',/'user' => '$USER',/g" \
> /tmp/1.txt

mv /tmp/1.txt /usr/lib/lx-office-erp/config/authentication.pl
}


disable_ipv6_on_lo_interface() {
# 2009-04-25
# Perls Libraries are not yet ipv6 read
echo "WICHTIG: ipv6 ist nunmehr auf dem Loopback-Interface deaktiviert, um die Funktionsfähigkeit von Lx-Office-ERP zu gewährleisten!"
ifconfig lo inet6 del ::1/128 2> /dev/null || true

# make the changes permanent (triggered on next reboot)
RCLOCAL="/etc/rc.local"
echo "# lx-office-erp: Perl libraries are not yet fully ipv6-ready" >> $RCLOCAL
echo "ifconfig lo inet6 del ::1/128" >> $RCLOCAL

}




case "$1" in
install)
echo "Install"

upgrade)
echo "Upgrade"

configure)

# config_postgresql_sql_routines
# config_postgresql_roles
# config_postgresql_accounts_sec

config_postgresql_factory_script

chown -R www-data:www-data /usr/lib/lx-office-erp/users
chown -R www-data:www-data /usr/lib/lx-office-erp/templates

set_lx_office_erp_web_admin_password
set_lx_office_erp_authentication_db_user
set_lx_office_erp_authentication_db_password
disable_ipv6_on_lo_interface

/etc/init.d/apache* reload

;;

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.



echo "done!!"

exit 0
(7-7/10)