/
postinst
187 lines (152 loc) · 5.59 KB
/
postinst
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
#!/bin/sh
# postinst script for dolibarr
#
# 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 /usr/share/doc/packaging-manual/
. /usr/share/debconf/confmodule
db_version 2.0
echo Run the dolibarr postinst script
case "$1" in
configure)
# Copy include for apache.conf
fileorig="/usr/share/dolibarr/build/deb/apache.conf"
config="/etc/dolibarr/apache.conf"
mkdir -p /etc/dolibarr
cp -p $fileorig $config
# Create install.forced.php
fileorig="/usr/share/dolibarr/build/deb/install.forced.php.install"
config="/usr/share/dolibarr/htdocs/install/install.forced.php"
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 /var/lib/dolibarr/documents
mkdir -p /var/lib/dolibarr/documents
chown -R www-data.www-data /var/lib/dolibarr/documents;
chmod -R 775 /var/lib/dolibarr/documents;
chmod -R g+s /var/lib/dolibarr/documents;
# Create empty conf.php
if [ ! -f /usr/share/dolibarr/htdocs/conf/conf.php ]
then
echo Create empty file /usr/share/dolibarr/htdocs/conf/conf.php
touch /usr/share/dolibarr/htdocs/conf/conf.php
chown -R www-data.www-data /usr/share/dolibarr/htdocs/conf/conf.php;
chmod -R 750 /usr/share/dolibarr/htdocs/conf/conf.php;
fi
#db_reset "dolibarr/webserver"
# Get the web server type (use db_get for interactive mode).
# db_get "dolibarr/webserver" # Read value for webserver.
# webserver="$RET"
case $webserver in
Apache) webservers="apache2" ;;
Apache-SSL) webservers="apache2-ssl" ;;
Both) webservers="apache2 apache2-ssl" ;;
*) webservers="apache2 apache2-ssl" ;;
esac
# Set up web server.
for server in $webservers ; do
echo Complete config of server $server
# Add info for PHP (obsolete)
#typestr='application/x-httpd-php'
#extension='.php'
#. /usr/share/wwwconfig-common/apache-addtype_all.sh
# Enable PHP module (obsolete)
#. /usr/share/wwwconfig-common/apache-php.sh
#echo Result of enabling PHP modules: $status
# Detect webuser and webgroup
webuser=
webgroup=
# Search in httpd.conf (obsolete)
#. /usr/share/wwwconfig-common/apache-run.get
#echo Web user.group found is $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
#
# That may lead to problems if apache & apache-ssl do
# not have the same user/group.
#
chown -R $webuser.$webgroup /usr/share/dolibarr
includefile="/etc/dolibarr/apache.conf"
#echo "$includefile $server"
. /usr/share/dolibarr/build/deb/apache-include_all.sh
test "$status" = "uncomment" -o "$status" = "include" && restart="$server $restart"
# (useless)
#for index in index.php; do
# . /usr/share/wwwconfig-common/apache-index_all.sh
# test "$status" = "added" && restart="$server $restart"
#done
done
# Copy icon file
#echo "Copy icon file"
#fileorig="/usr/share/dolibarr/doc/images/dolibarr.xpm"
#target="/usr/share/pixmaps/"
#cp -f $fileorig $target
#echo "Install menu entry"
# This one is for Gnome ubuntu
#fileorig="/usr/share/dolibarr/build/deb/dolibarr.desktop"
#target="/usr/share/applications/"
#cp -f $fileorig $target
# Not sure this is usefull
if test -x /usr/bin/update-menus; then
echo "update-menus"
update-menus;
fi
# TODO Create the file to force parameters in Web installer
#if grep DBHOST /usr/share/dolibarr/htdocs/conf/conf.php > /dev/null
#then
# perl -pi -e "s/DBHOST/$dbserver/" /usr/share/dolibarr/htdocs/conf/conf.php
# perl -pi -e "s/DBNAME/$dbname/" /usr/share/dolibarr/htdocs/conf/conf.php
# perl -pi -e "s/DBUSER/$dbuser/" /usr/share/dolibarr/htdocs/conf/conf.php
# perl -pi -e "s/DBPASS/$dbpass/" /usr/share/dolibarr/htdocs/conf/conf.php
#fi
# 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
# This on works with Debian (5.05,...) and Ubuntu (9.10,10.04,...)
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)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 0
;;
esac
db_stop
#DEBHELPER#
exit 0