-
Notifications
You must be signed in to change notification settings - Fork 52
/
ontowiki-virtuoso.postinst
executable file
·85 lines (71 loc) · 2.31 KB
/
ontowiki-virtuoso.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
#!/bin/sh -e
# postinst script for ontowiki-virtuoso
#
# see: dh_installdeb(1)
echo "---- starting postinst $@"
# check environment
if [ -d "/etc/virtuoso-opensource-6.1" ]; then
virtetc="/etc/virtuoso-opensource-6.1/"
fi
if [ -d "/etc/virtuoso-opensource" ]; then
virtetc="/etc/virtuoso-opensource/"
fi
virtuosoini="$virtetc/virtuoso.ini"
virtbdini="$virtetc/bd.ini"
odbcini="/etc/odbc.ini"
owini="/etc/ontowiki/config.ini"
dsn="OWVIRT"
# check if bd ini exists (a file with login credentials)
if [ -e $virtbdini ]; then
username=`cat $virtbdini | grep "^Username=" | cut -d "=" -f 2-`
password=`cat $virtbdini | grep "^Password=" | cut -d "=" -f 2-`
driver=`cat $virtbdini | grep "^Driver=" | cut -d "=" -f 2-`
address=`cat $virtbdini | grep "^Address=" | cut -d "=" -f 2-`
fi
# if we do not have the values we assume dba/dba and other well know values
if [ "$username" = "" ]; then
username="dba"
fi
if [ "$password" = "" ]; then
password="dba"
fi
if [ "$driver" = "" ]; then
driver="/usr/lib/odbc/virtodbc.so"
fi
if [ "$address" = "" ]; then
address="localhost:1111"
fi
### ODBC CONFIG
touch $odbcini
echo "# OntoWiki dsn start" >>$odbcini
echo "[$dsn]" >>$odbcini
echo Description=OntoWiki Virtuoso DSN >>$odbcini
echo Driver=$driver >>$odbcini
echo Address=$address >>$odbcini
echo "# OntoWiki dsn end" >>$odbcini
### ONTOWIKI CONFIG
chown www-data:www-data $owini
chmod 600 $owini
sed "s/%%DSN%%/$dsn/" -i $owini
sed "s/%%USERNAME%%/$username/" -i $owini
sed "s/%%PASSWORD%%/$password/" -i $owini
### VIRTUOSO CONFIG
# add ontowiki and erfurt directory to virtuoso.ini DirsAllowed
# try to remove the addition first in order to avoid double entries
if [ -e $virtuosoini ]; then
sed 's/^\(DirsAllowed.*\)\(, \/usr\/share\/ontowiki\)\(.*\)/\1\3/' -i $virtuosoini
sed 's/^\(DirsAllowed.*\)/\1, \/usr\/share\/ontowiki/' -i $virtuosoini
sed 's/^\(DirsAllowed.*\)\(, \/usr\/share\/php\/liberfurt-php\)\(.*\)/\1\3/' -i $virtuosoini
sed 's/^\(DirsAllowed.*\)/\1, \/usr\/share\/php\/liberfurt-php/' -i $virtuosoini
fi
### APACHE CONFIG
# remove and relink the config
rm -rf /etc/apache2/conf.d/ontowiki
ln -s /etc/ontowiki/apache.conf /etc/apache2/conf.d/ontowiki
# enable mods
a2enmod rewrite
a2enmod env
# restart apache
service apache2 restart
#DEBHELPER#
echo "---- ending postinst $@"