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