-#delete .htconfig.php file if it exists to have a fresh friendica
-#installation
-if [ -f /vagrant/.htconfig.php ]
- then
- rm /vagrant/.htconfig.php
-fi
+#Install mysql
+echo ">>> Installing Mysql"
+sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password root"
+sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root"
+sudo apt-get install -qq mysql-server
+# enable remote access
+# setting the mysql bind-address to allow connections from everywhere
+sed -i "s/bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
+# adding grant privileges to mysql root user from everywhere
+# thx to http://stackoverflow.com/questions/7528967/how-to-grant-mysql-privileges-in-a-bash-script for this
+MYSQL=`which mysql`
+Q1="GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;"
+Q2="FLUSH PRIVILEGES;"
+SQL="${Q1}${Q2}"
+$MYSQL -uroot -proot -e "$SQL"
+service mysql restart
+
+
+#configure rudimentary mail server (local delivery only)
+#add Friendica accounts for local user accounts, use email address like vagrant@friendica.dev, read the email with 'mail'.
+debconf-set-selections <<< "postfix postfix/mailname string friendica.dev"
+debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Local Only'"
+sudo apt-get install -y postfix mailutils libmailutils-dev
+sudo echo -e "friendica1: vagrant\nfriendica2: vagrant\nfriendica3: vagrant\nfriendica4: vagrant\nfriendica5: vagrant" >> /etc/aliases && sudo newaliases
+
+#make the vagrant directory the docroot
+sudo rm -rf /var/www/
+sudo ln -fs /vagrant /var/www