-
Notifications
You must be signed in to change notification settings - Fork 52
/
ontowiki-mysql.postinst
executable file
·45 lines (32 loc) · 1.23 KB
/
ontowiki-mysql.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
#!/bin/sh -e
# postinst script for ontowiki
#
# see: dh_installdeb(1)
echo "---- starting postinst $@"
mysql_run="mysql --defaults-extra-file=/etc/mysql/debian.cnf"
ow_user="ontowiki_deb"
ow_db="$ow_user"
#ow_pass=`pwgen -1`
ow_pass="usepwgenhere"
#service mysql start
echo "create ontowiki user"
echo "CREATE USER '$ow_user'@'localhost' IDENTIFIED BY '$ow_pass';" | $mysql_run || echo "user $ow_user already exist"
echo "grant usage for ontowiki user"
echo "GRANT USAGE ON * . * TO '$ow_user'@'localhost' IDENTIFIED BY '$ow_pass' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;" | $mysql_run
echo "create database"
echo "CREATE DATABASE IF NOT EXISTS $ow_db ;" | $mysql_run
echo "grant privileges to ontowiki user"
echo "GRANT ALL PRIVILEGES ON $ow_db . * TO '$ow_user'@'localhost';" | $mysql_run
echo "flush privileges"
echo "FLUSH PRIVILEGES ;" | $mysql_run
### APACHE CONFIG
chown www-data:www-data /etc/ontowiki/config.ini
chmod 600 /etc/ontowiki/config.ini
# remove and relink the config
rm -rf /etc/apache2/conf.d/ontowiki
ln -s /etc/ontowiki/apache.conf /etc/apache2/conf.d/ontowiki
a2enmod rewrite
a2enmod env
service apache2 restart
#DEBHELPER#
echo "---- ending postinst $@"