Newer
Older
#!/bin/sh
# postinst script for dolibarr
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 /usr/share/doc/packaging-manual/
lighttpd_install() {
if [ ! -f /etc/lighttpd/conf-available/50-dolibarr.conf ] ; then
if which lighty-enable-mod >/dev/null 2>&1 ; then
echo "Add link for Lighttpd config file"
ln -fs /etc/dolibarr/lighttpd.conf /etc/lighttpd/conf-available/50-dolibarr.conf
# We enabled it
lighty-enable-mod dolibarr fastcgi-php
else
echo "Lighttpd not installed, skipping"
fi
fi
}
apache_install() {
webserver=$1
if [ -d /etc/$webserver/conf.d ] && [ ! -e /etc/$webserver/conf.d/dolibarr.conf ]; then
echo "Add link for Apache config file"
ln -fs /etc/dolibarr/apache.conf /etc/$webserver/conf.d/dolibarr.conf
echo Run the dolibarr postinst script
installfileorig="/usr/share/dolibarr/build/debian/install.forced.php.install"
installconfig="/etc/dolibarr/install.forced.php"
config="/etc/dolibarr/conf.php"
# Remove lock file
rm -f $docdir/install.lock
# Create document directory for uploaded data files
mkdir -p $docdir
chown -R www-data:www-data $docdir
chmod -R 775 $docdir
chmod -R g+s $docdir
# Copy install config file (with matching Debian) values into target directory
superuserlogin=''
superuserpassword=''
if [ -f /etc/mysql/debian.cnf ] ; then
# Load superuser login and pass
superuserlogin=$(grep --max-count=1 "user" /etc/mysql/debian.cnf | sed -e 's/^user[ =]*//g')
superuserpassword=$(grep --max-count=1 "password" /etc/mysql/debian.cnf | sed -e 's/^password[ =]*//g')
fi
echo Mysql superuser found to use is $superuserlogin
if [ -z "$superuserlogin" ] ; then
cat $installfileorig | sed -e 's/__SUPERUSERLOGIN__/root/g' | sed -e 's/__SUPERUSERPASSWORD__//g' > $installconfig
cat $installfileorig | sed -e 's/__SUPERUSERLOGIN__/'$superuserlogin'/g' | sed -e 's/__SUPERUSERPASSWORD__/'$superuserpassword'/g' > $installconfig
chown -R root:www-data $installconfig
chmod -R 660 $installconfig
# Create an empty conf.php with permission to web server
echo Create empty file $config
touch $config
chmod -R 660 $config
chown -R root:www-data $config
else
# File already exist. We add params not found.
// Add new params to overwrite path to use shared libraries/fonts
grep -q -c "dolibarr_lib_ADODB_PATH" $config || echo "<?php \$dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; ?>" >> $config
grep -q -c "dolibarr_lib_FPDI_PATH" $config || echo "<?php \$dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi'; ?>" >> $config
grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "<?php \$dolibarr_lib_GEOIP_PATH=''; ?>" >> $config
grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || echo "<?php \$dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap'; ?>" >> $config
grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || echo "<?php \$dolibarr_lib_ODTPHP_PATHTOPCLZIP='/usr/share/php/libphp-pclzip'; ?>" >> $config
grep -q -c "dolibarr_lib_PHPEXCEL_PATH" $config || echo "<?php \$dolibarr_lib_PHPEXCEL_PATH=''; ?>" >> $config
grep -q -c "dolibarr_lib_TCPDF_PATH" $config || echo "<?php \$dolibarr_lib_TCPDF_PATH=''; ?>" >> $config
grep -q -c "dolibarr_js_CKEDITOR" $config || echo "<?php \$dolibarr_js_CKEDITOR='/javascript/ckeditor'; ?>" >> $config
grep -q -c "dolibarr_js_JQUERY" $config || echo "<?php \$dolibarr_js_JQUERY='/javascript/jquery'; ?>" >> $config
grep -q -c "dolibarr_js_JQUERY_UI" $config || echo "<?php \$dolibarr_js_JQUERY_UI='/javascript/jquery-ui'; ?>" >> $config
grep -q -c "dolibarr_js_JQUERY_FLOT" $config || echo "<?php \$dolibarr_js_JQUERY_FLOT='/javascript/flot'; ?>" >> $config
grep -q -c "dolibarr_font_DOL_DEFAULT_TTF_BOLD" $config || echo "<?php \$dolibarr_font_DOL_DEFAULT_TTF_BOLD='/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf'; ?>" >> $config
db_get dolibarr/reconfigure-webserver
webservers="$RET"
for webserver in $webservers ; do
webserver=${webserver%,}
echo Complete config of server $webserver
# Detect webuser and webgroup
webuser=
webgroup=
if [ -z "$webuser" ] ; then
webuser=www-data
fi
if [ -z "$webgroup" ] ; then
webgroup=www-data
fi
echo Web user.group used is $webuser.$webgroup
chown -R $webuser:$webgroup /usr/share/dolibarr
# Restart web server.
for webserver in $webservers; do
webserver=${webserver%,}
if [ "$webserver" = "lighttpd" ] ; then
lighttpd_install
else
apache_install $webserver
fi
# Reload webserver in any case, configuration might have changed
# Redirection of 3 is needed because Debconf uses it and it might
# be inherited by webserver. See bug #446324.
if [ -f /etc/init.d/$webserver ] ; then
if [ -x /usr/sbin/invoke-rc.d ]; then
echo Restart web server $server using invoke-rc.d
# This works with Debian (5.05,...) and Ubuntu (9.10,10.04,...)
invoke-rc.d $webserver reload 3>/dev/null || true
else
echo Restart web server $server using $server reload
/etc/init.d/$webserver reload 3>/dev/null || true
fi
fi
echo "Call Dolibarr page http://localhost/dolibarr/ to complete the setup and use Dolibarr."
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument $1" >&2
exit 0
;;
esac
#DEBHELPER#