forked from movim/movim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postinst
executable file
·162 lines (138 loc) · 4.5 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
#!/bin/sh
httpserver_init() {
db_get movim/httpserver
httpservers="$RET"
for httpserver in $httpservers; do
httpserver=${httpserver%,}
#if [ "$httpserver" = "nginx" ] ; then
# nginx_install
#else
apache_install $1 $httpserver
#fi
done
}
apache_install() {
server="apache2"
CONF="movim"
COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
. /usr/share/apache2/apache2-maintscript-helper
apache2_invoke enconf $CONF || exit $?
elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
[ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/$CONF.conf ] \
&& ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
reload_server $server
fi
}
#nginx_install() {
#server="apache2"
#CONF="movim"
#COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
#if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
#. /usr/share/apache2/apache2-maintscript-helper
#apache2_invoke enconf $CONF || exit $?
#elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
#[ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/$CONF.conf ] \
#&& ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
#reload_server $server
#fi
#}
#
# fixperms 0644 /usr/share/movim
#
fixperms () {
PERMS="$1"
FILE="$2"
chmod ${PERMS} "${FILE}"
}
#
# fixownership user:group /var/cache/movim
#
fixownership ()
{
OWNER="$1"
FILE="$2"
chown ${OWNER} "${FILE}"
}
fixownershipdir ()
{
OWNER="$1"
FILE="$2"
chown -R ${OWNER} "${FILE}"
}
reload_server() {
server=$1
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d $server reload 3>/dev/null || true
else
/etc/init.d/$server reload 3>/dev/null || true
fi
}
. /usr/share/debconf/confmodule
db_get movim/debconf_install
if [ "$RET" = false ]; then
exit 0;
fi
. /usr/share/dbconfig-common/dpkg/postinst
dbc_go movim $@
if [ "$dbc_dbtype" == 'mysql' ]; then
dbport='3306'
else
dbport='5432'
fi
# We create the Movim configuration file
#touch /etc/movim/db.inc.php
echo "<?php
# This is the database configuration of Movim
# You need to copy an rename this file to 'db.inc.php' and complete the values
\$conf = array(
# The type can be 'pgsql' or 'mysql'
'type' => '$dbc_dbtype',
# The database username
'username' => '$dbc_dbuser',
# The password
'password' => '$dbc_dbpass',
# Where can we find the database ?
'host' => 'localhost',
# The port number, 3306 for MySQL and 5432 for PostGreSQL
'port' => $dbport,
# The database name
'database' => '$dbc_dbname'
);
" > /etc/movim/db.inc.php
httpserver_init $1
# We create some links
ln -s /etc/movim/ /usr/share/movim/config 2>/dev/null
ln -s /var/lib/movim/lib /usr/share/movim/ 2>/dev/null
ln -s /var/lib/movim/locales /usr/share/movim/ 2>/dev/null
ln -s /var/lib/movim/themes /usr/share/movim/ 2>/dev/null
ln -s /var/lib/movim/vendor /usr/share/movim/ 2>/dev/null
ln -s /var/lib/movim/src /usr/share/movim/ 2>/dev/null
# We create the cache folder
mkdir -p /var/cache/movim/cache 2>/dev/null
ln -s /var/cache/movim/cache /usr/share/movim/cache 2>/dev/null
fixperms 0775 /usr/share/movim/cache
fixownershipdir "www-data:www-data" /var/cache/movim/cache
fixownershipdir "www-data:www-data" /usr/share/movim/cache
# We create the log folder
mkdir /var/log/movim 2>/dev/null
ln -s /var/log/movim /usr/share/movim/log 2>/dev/null
fixperms 0775 /var/log/movim
fixownership "root:www-data" /var/log/movim
# We create the user folder
mkdir /var/cache/movim/users 2>/dev/null
ln -s /var/cache/movim/users /usr/share/movim/users 2>/dev/null
fixperms 0775 /user/share/movim/users
fixownershipdir "www-data:www-data" /var/cache/movim/users
fixownershipdir "www-data:www-data" /usr/share/movim/users
# Fix rights
fixperms 0775 /usr/share/movim
fixownership "root:www-data" /usr/share/movim
fixperms 0775 /usr/share/movim/daemon.php
fixownership "root:www-data" /usr/share/movim/daemon.php
# And we install/update the Movim database
echo "Creating and/or updating the Movim database… please be patient"
chmod +x /usr/share/movim/mud.php
/usr/share/movim/mud.php db set
# We clean some log created by the install to prevent issues
rm -rf /usr/share/movim/log/* /usr/share/movim/cache/*