fa804c96cbfa1c2183a82f0735e5c0b7426d0df7
[tine20] / scripts / vagrant / setup-tine20.sh
1 #!/usr/bin/env bash
2
3 # Tine 2.0 Vhost
4 tine20_vhost="
5 <VirtualHost *:80>\n
6     DocumentRoot   \"/vagrant/tine20.git/tine20/\"\n
7     ServerName      tine20.vagrant\n
8     ServerAlias     www.tine20.vagrant\n
9     \n
10     # Active Sync\n
11     RewriteEngine on\n
12     RewriteRule ^/Microsoft-Server-ActiveSync /index.php?frontend=activesync [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
13     \n
14     # WebDAV / CardDAV / CalDAV API\n
15     RewriteCond %{REQUEST_METHOD} !^(GET|POST)$\n
16     RewriteRule ^/$            /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
17     \n
18     RewriteRule ^/addressbooks /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
19     RewriteRule ^/calendars    /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
20     RewriteRule ^/principals   /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
21     RewriteRule ^/webdav       /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
22     RewriteRule ^/remote.php   /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
23     \n
24     php_value include_path "/vagrant/conf:/vagrant/tine20.git/tine20/"\n
25     \n
26     ErrorLog "/vagrant/logs/error_log"\n
27     CustomLog "/vagrant/logs/access_log" common\n
28     \n
29 </VirtualHost>\n"
30
31 echo -e $tine20_vhost > /etc/apache2/sites-available/tine20-vagrant
32
33 service apache2 restart
34
35 # Add database for tine20
36 mysql -u root -p"vagrant" -e "CREATE DATABASE tine20;"
37
38 # Enable tine20-vagrant for apache
39 a2ensite tine20-vagrant
40
41 # update dependencies
42 cd /vagrant/tine20.git/tine20
43 sudo -u vagrant composer install --dev --prefer-source --no-interaction
44
45 # setup directories
46 mkdir -p /vagrant/logs /vagrant/conf /vagrant/cache /vagrant/files /vagrant/tmp
47 chown www-data /vagrant/logs /vagrant/conf /vagrant/cache /vagrant/files /vagrant/tmp
48
49 # generate config.inc.php
50 tine20_config="
51 <?php return array(\n
52     'database' => array(\n
53         'host'          => 'localhost',\n
54         'dbname'        => 'tine20',\n
55         'username'      => 'root',\n
56         'password'      => 'vagrant',\n
57         'adapter'       => 'pdo_mysql',\n
58         'tableprefix'   => 'tine20_',\n
59     ),
60     'setupuser' => array(\n
61         'username'      => 'vagrant',\n
62         'password'      => 'vagrant'\n 
63     ),\n
64    'login' => array(\n
65        'username'      => 'vagrant',\n
66        'password'      => 'vagrant'\n
67     ),\n
68     \n
69     'caching' => array (\n
70         'active' => true,\n
71         'path' => '/vagrant/cache',\n
72         'lifetime' => 3600,\n
73     ),\n
74     \n
75     'logger' => array (\n
76         'active' => true,\n
77         'filename' => '/vagrant/logs/tine20.log',\n
78         'priority' => '7',\n
79     ),\n
80     'filesdir'  => '/vagrant/files',\n
81     'tmpdir' => '/vargrant/tmp',\n
82   );\n"
83
84 if [ ! -f /vagrant/conf/config.inc.php ]; then
85   echo -e $tine20_config > /vagrant/conf/config.inc.php
86 fi
87
88 # generate install.properties
89 tine20_installprops="
90 adminLoginName=vagrant\n
91 adminPassword=vagrant\n
92 adminEmailAddress=vagrant@tine20.vagrant\n
93 #authentication=\n
94 #accounts=\n
95 #imap=\n
96 #smtp=\n"
97
98 if [ ! -f /vagrant/conf/install.properties ]; then
99   echo -e $tine20_installprops > /vagrant/conf/install.properties
100 fi
101
102 cd /vagrant/tine20.git/tine20
103 sudo -u vagrant /vagrant/tine20.git/tine20/vendor/bin/phing -D configdir=/vagrant/conf/ tine-install