upgrade vagrant box to saucy 64 bit with php5.5
[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   \"/usr/local/share/tine20.git/tine20/\"\n
7     ServerName      tine20.vagrant\n
8     ServerAlias     www.tine20.vagrant\n
9     \n
10      <Directory /usr/local/share/tine20.git/tine20/>\n
11        AllowOverride None\n
12        Require all granted\n
13      </Directory>\n
14      \n
15     # Active Sync\n
16     RewriteEngine on\n
17     RewriteRule ^/Microsoft-Server-ActiveSync /index.php?frontend=activesync [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
18     \n
19     # WebDAV / CardDAV / CalDAV API\n
20     RewriteCond %{REQUEST_METHOD} !^(GET|POST)$\n
21     RewriteRule ^/$            /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
22     \n
23     RewriteRule ^/addressbooks /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
24     RewriteRule ^/calendars    /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
25     RewriteRule ^/principals   /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
26     RewriteRule ^/webdav       /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
27     RewriteRule ^/remote.php   /index.php?frontend=webdav [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]\n
28     \n
29     php_value include_path "/etc/tine20:/usr/local/share/tine20.git/tine20/"\n
30     \n
31     ErrorLog "/var/log/tine20/error_log"\n
32     CustomLog "/var/log/tine20/access_log" common\n
33     \n
34 </VirtualHost>\n"
35
36 echo -e $tine20_vhost > /etc/apache2/sites-available/tine20-vagrant.conf
37
38 service apache2 restart
39
40 # Add database for tine20
41 mysql -u root -p"vagrant" -e "CREATE DATABASE tine20;"
42
43 # Enable tine20-vagrant for apache
44 a2ensite tine20-vagrant
45
46 # update dependencies
47 cd /usr/local/share/tine20.git/tine20
48 sudo -u vagrant composer install --dev --prefer-source --no-interaction
49
50 # setup directories
51 mkdir -p /var/lib/tine20/cache /var/lib/tine20/files /var/lib/tine20/tmp
52 mkdir -p /etc/tine20
53 mkdir -p /var/log/tine20
54 chown -R vagrant /var/lib/tine20
55 chown -R vagrant /var/log/tine20
56
57 # generate config.inc.php
58 tine20_config="
59 <?php return array(\n
60     'database' => array(\n
61         'host'          => 'localhost',\n
62         'dbname'        => 'tine20',\n
63         'username'      => 'root',\n
64         'password'      => 'vagrant',\n
65         'adapter'       => 'pdo_mysql',\n
66         'tableprefix'   => 'tine20_',\n
67     ),
68     'setupuser' => array(\n
69         'username'      => 'vagrant',\n
70         'password'      => 'vagrant'\n 
71     ),\n
72    'login' => array(\n
73        'username'      => 'vagrant',\n
74        'password'      => 'vagrant'\n
75     ),\n
76     \n
77     'caching' => array (\n
78         'active' => true,\n
79         'path' => '/var/lib/tine20/cache',\n
80         'lifetime' => 3600,\n
81     ),\n
82     \n
83     'logger' => array (\n
84         'active' => true,\n
85         'filename' => '/var/log/tine20/tine20.log',\n
86         'priority' => '7',\n
87     ),\n
88     'filesdir'  => '/var/lib/tine20/files',\n
89     'tmpdir' => '/var/lib/tine20/tmp',\n
90   );\n"
91
92 if [ ! -f /etc/tine20/config.inc.php ]; then
93   echo -e $tine20_config > /etc/tine20/config.inc.php
94 fi
95
96 # generate install.properties
97 tine20_installprops="
98 adminLoginName=vagrant\n
99 adminPassword=vagrant\n
100 adminEmailAddress=vagrant@tine20.vagrant\n
101 #authentication=\n
102 #accounts=\n
103 #imap=\n
104 #smtp=\n"
105
106 if [ ! -f /etc/tine20/install.properties ]; then
107   echo -e $tine20_installprops > /etc/tine20/install.properties
108 fi
109
110 cd /usr/local/share/tine20.git/tine20
111 sudo -u vagrant /usr/local/share/tine20.git/tine20/vendor/bin/phing -D configdir=/etc/tine20/ tine-install
112
113 echo "
114 ##################################################################################
115 # Welcome to tine20.vagrant
116 #
117 # 1. make sure you have a tine20.vagrant entry in you /etc/hosts file
118 #    with your vagrant machine ip (10.10.10.10 per default)
119 # 2. navigate in your browser to
120 #      http://tine20.vagrant (normal login)
121 #      http://tine20.vagrant/setup.php (setup)
122 #        username: vagrant
123 #        password: vagrant
124 # 3. to run phpunit tests:
125        vagrant ssh
126        cd /usr/local/share/tine20.git/tests/tine20
127        /usr/local/share/tine20.git/tine20/vendor/bin/phpunit \
128  -d include_path=/etc/tine20 -d memory_limit=-1 AllTests.php
129 #
130 # 4. Happy codeing! :-)
131 ##################################################################################
132 "