Enhancement of debian package

This commit is contained in:
Laurent Destailleur 2010-02-02 17:32:37 +00:00
parent 1afda34ad7
commit c4878edd11
8 changed files with 104 additions and 35 deletions

View File

@ -13,6 +13,7 @@
set -e
. /usr/share/debconf/confmodule
db_version 2.0
@ -24,8 +25,8 @@ echo Run the config script
if [ "$1" = "reconfigure" ] ; then
config="/etc/dolibarr/apache.conf"
for i in $(seq 8 -1 0) ; do
if [ -f ${config}.$i ]
then mv ${config}.$i ${config}.$(($i +1))
if [ -f ${config}.$i ] ; then
mv ${config}.$i ${config}.$(($i +1))
fi
done
mv ${config} ${config}.0
@ -35,11 +36,12 @@ fi
db_capb backup
db_title "dolibarr" || true
# Ask for web server type.
#db_input critical "dolibarr/webserver" || true
db_title "dolibarr" || true
if db_go ; then
okcancel="1"
else
@ -47,9 +49,6 @@ else
fi
# Ask on wich host the DBMS is installed.
#db_input critical "dolibarr/db/host" || true
# Get the database administrator name and password.
#db_beginblock
# db_input critical "dolibarr/db/admin/name" || true
@ -66,9 +65,12 @@ fi
#db_input critical "dolibarr/db/user/password" || true
# Ask for deleting all the database on package purge.
#db_input medium "dolibarr/postrm" || true
#onsuccess='finished="true"'
#db_input critical "dolibarr/postrm" || true
# Launch input screens
#db_go || true
onsuccess='finished="true"'
db_stop
exit 0

1
build/deb/examples Executable file
View File

@ -0,0 +1 @@
usr/share/dolibarr/htdocs/conf/conf.php.example

View File

@ -8,8 +8,8 @@ $force_install_createdatabase='1';
$force_install_databaselogin='dolibarrmysql';
$force_install_databasepass='';
$force_install_createuser='1';
$force_install_databaserootlogin='root';
$force_install_databaserootpass='';
$force_install_databaserootlogin='__SUPERUSERLOGIN__';
$force_install_databaserootpass='__SUPERUSERPASSWORD__';
$force_install_dolibarrlogin='admin';
$force_install_nophpinfo='1';
$force_install_lockinstall='1';

View File

@ -15,7 +15,9 @@ set -e
# <conflicting-package> <version>
# for details, see /usr/share/doc/packaging-manual/
. /usr/share/debconf/confmodule
db_version 2.0
#
@ -53,11 +55,23 @@ case "$1" in
mkdir -p /etc/dolibarr
cp -p $fileorig $config
# Copy install.forced.php
fileorig="/usr/share/dolibarr/build/deb/install.forced.php"
# Create install.forced.php
fileorig="/usr/share/dolibarr/build/deb/install.forced.php.install"
config="/usr/share/dolibarr/htdocs/install/install.forced.php"
cp -p $fileorig $config
superuserlogin=''
superuserpassword=''
if [ -f /etc/mysql/debian.cnf ] ; then
# Load superuser login and pass
superuserlogin=$(/bin/grep --max-count=1 "user" /etc/mysql/debian.cnf | /bin/sed -e 's/^user[ =]*//g')
superuserpassword=$(/bin/grep --max-count=1 "password" /etc/mysql/debian.cnf | /bin/sed -e 's/^password[ =]*//g')
fi
echo Mysql superuser found to use is $superuserlogin
if [ -z "$superuserlogin" ] ; then
cat $fileorig | sed -e 's/__SUPERUSERLOGIN__/root/g' | sed -e 's/__SUPERUSERPASSWORD__//g' > $config
else
cat $fileorig | sed -e 's/__SUPERUSERLOGIN__/'$superuserlogin'/g' | sed -e 's/__SUPERUSERPASSWORD__/'$superuserpassword'/g' > $config
fi
# Create empty conf.php
if [ ! -f /usr/share/dolibarr/htdocs/conf/conf.php ]
then
@ -150,14 +164,26 @@ case "$1" in
# perl -pi -e "s/DBPASS/$dbpass/" /usr/share/dolibarr/htdocs/conf/conf.php
#fi
# Restart servers
servers="apache2-ssl apache2 mysql"
. /usr/share/wwwconfig-common/restart.sh
if [ -f /usr/share/wwwconfig-common/restart.sh ] ;
then
. /usr/share/wwwconfig-common/restart.sh
else
# Another way to restart
for server in $servers ; do
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d $server reload || true
else
/etc/init.d/$server reload || true
fi
done
fi
echo "Launch Dolibarr on page http://localhost/dolibarr/ to complete the installation and use Dolibarr."
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)

View File

@ -1,4 +1,4 @@
#! /bin/sh
#!/bin/sh
# postrm script for dolibarr
#
# see: dh_installdeb(1)
@ -16,10 +16,13 @@ set -e
# * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
# for details, see /usr/share/doc/packaging-manual/
. /usr/share/debconf/confmodule
db_version 2.0
echo Run the postrm script
#echo "postrm db_get dolibarr/webserver"
# We disable set -e to avoid premature end of script if error
set +e
@ -40,23 +43,40 @@ case "$1" in
purge)
echo "postrm purge webservers=$webservers includefile=$includefile"
#echo "postrm db_get dolibarr/postrm"
# Ask if we must delete database
echo "postrm db_input dolibarr/postrm"
db_input critical "dolibarr/postrm" || true
db_go || true
echo "postrm db_get dolibarr/postrm"
# We disable set -e to avoid premature end of script if error
set +e
db_get "dolibarr/postrm"
set -e
if [ "$RET" = "true" ] ; then
echo postrm Mysql database deletion
# Get database configuration
dbserver="localhost"
db_get "dolibarr/db/name"
dbname="$RET"
db_get "dolibarr/db/admin/name"
dbadmin="$RET"
db_get "dolibarr/db/admin/password"
dbadmpass="$RET"
dbname="dolibarr"
#db_get "dolibarr/db/name"
#dbname="$RET"
superuserlogin=''
superuserpassword=''
if [ -f /etc/mysql/debian.cnf ] ; then
# Load superuser login and pass
superuserlogin=$(/bin/grep --max-count=1 "user" /etc/mysql/debian.cnf | /bin/sed -e 's/^user[ =]*//g')
superuserpassword=$(/bin/grep --max-count=1 "password" /etc/mysql/debian.cnf | /bin/sed -e 's/^password[ =]*//g')
fi
echo postrm Mysql superuser found to use is $superuserlogin
dbadmin="$superuserlogin"
dbadmpass="$superuserpassword"
#db_get "dolibarr/db/admin/name"
#dbadmin="$RET"
#db_get "dolibarr/db/admin/password"
#dbadmpass="$RET"
dbtype="mysql"
. /usr/share/wwwconfig-common/${dbtype}-dropuser.sh
. /usr/share/wwwconfig-common/${dbtype}-dropdb.sh
fi
@ -84,36 +104,50 @@ case "$1" in
rm -rf /etc/dolibarr
# Restart
# Restart servers
servers="apache2-ssl apache2 mysql"
if [ -f /usr/share/wwwconfig-common/restart.sh ] ;
then
. /usr/share/wwwconfig-common/restart.sh
else
# Another way to restart
for server in $servers ; do
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d $server reload || true
else
/etc/init.d/$server reload || true
fi
done
fi
# Remove file and conf file
for dir in /usr/share/dolibarr ; do
if [ -d ${dir} ] ; then rm -rf ${dir} ; fi
done
db_reset "dolibarr/postrm"
db_purge
;;
remove)
echo "Force remove of /usr/share/dolibarr/htdocs/install"
echo "postrm Force remove of /usr/share/dolibarr/htdocs/install"
rm -fr /usr/share/dolibarr/htdocs/install
echo "Remove menu entry and image"
echo "postrm Remove menu entry and image"
fileorig="/usr/share/applications/dolibarr.desktop"
rm -f $fileorig
fileorig="/usr/share/pixmaps/dolibarr.xpm"
rm -f $fileorig
# Not sure this is usefulle
# Not sure this is usefull
if test -x /usr/bin/update-menus; then update-menus; fi
;;
upgrade)
;;
failed-upgrade|abort-install|abort-upgrade|disappear)
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
exit 0
@ -122,4 +156,6 @@ esac
db_stop
#DEBHELPER#
exit 0

View File

@ -96,7 +96,7 @@ Description: Please, insert the DBMS administrator password (if any):
Template: dolibarr/postrm
Type: boolean
Default: true
Description: Delete *ALL*?
Datas subjected to this question are the DBMS account, the DB and the
Dolibarr users ang group files. Do I have to delete *ALL* datas whenever
the Dolibarr package will be completely removed from the system?
Description: Delete database ?
Do I have to delete also the Dolibarr MySQL database and all its datas
(datas subjected to this quetion are the Dolibarr DBMS account and all
Dolibarr tables) ?

View File

@ -21,6 +21,8 @@ doc/wiki
document
documents
htdocs/conf/conf.php
htdocs/conf/conf.php.mysql
htdocs/conf/conf.php.postgres
htdocs/avoir
htdocs/document
htdocs/documents

View File

@ -20,6 +20,8 @@
*/document/*
*/documents/*
*/htdocs/conf/conf.php
*/htdocs/conf/conf.php.mysql
*/htdocs/conf/conf.php.postgres
*/htdocs/avoir/*
*/htdocs/document/*
*/htdocs/documents/*