update-noosfero-apache
1.39 KB
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
#!/bin/sh
set -e
# automatically update configuration, but if package noosfero is also installed
if test -x /usr/share/noosfero/script/apacheconf; then
datadir="/etc/noosfero/apache"
mongrel_file="$datadir/mongrel.conf"
cluster_file="$datadir/cluster.conf"
if test -e "$cluster_file"; then
echo "Overwriting $cluster_file ..."
fi
/usr/share/noosfero/script/apacheconf thin > "$cluster_file"
if test -e "$mongrel_file"; then
echo "Moving existing $mongrel_file away ..."
mv "$mongrel_file" "$mongrel_file".bak
(cd $datadir && ln -sf cluster.conf mongrel.conf)
fi
apache_site='/etc/apache2/sites-available/noosfero'
apache_site_configs='/etc/noosfero/apache.d'
if ! test -e "$apache_site"; then
echo "Generating apache virtual host ..."
cd /usr/share/noosfero && su noosfero -c "RAILS_ENV=production ./script/apacheconf virtualhosts" > "$apache_site"
if ! test -d "$apache_site_configs"; then
echo "Creating noosfero site config folder ..."
mkdir $apache_site_configs
fi
else
pattern="Include \/etc\/noosfero\/apache\/virtualhost.conf"
include="Include \/etc\/noosfero\/apache.d\/*"
if ! cat $apache_site | grep "^ *$include" > /dev/null ; then
sed -i "s/.*$pattern.*/ $include\n&/" $apache_site
fi
fi
echo 'Noosfero Apache configuration updated.'
echo "Run '/etc/init.d/apache2 reload' to activate new configuration!"
fi