+#!/bin/bash
+set -e
+
+# check MariaDB or MySQL
+maria=$(mysql -V |grep MariaDB) || true
+
+# check, whether mkrimi user exists
+if ! mysql -umkrimi -pmkrimi mkrimi -e";"
+then
+ echo "Installation of mkrimi user ..."
+ # unix_socket authentification for MariaDB 10
+ if [ -n "$maria" ]
+ then
+ mysql <<END
+create user mkrimi@localhost identified by 'mkrimi';
+create database mkrimi;
+grant all on mkrimi.* to mkrimi@localhost;
+END
+ else
+ echo "Password of mysql root:"
+ read pw
+ mysql -uroot -p$pw <<END1
+create user mkrimi@localhost identified by 'mkrimi';
+create database mkrimi;
+grant all on mkrimi.* to mkrimi@localhost;
+END1
+ fi
+fi
+
+# check schema
+if ! mysql -umkrimi -pmkrimi mkrimi -e"select * from medium;" >/dev/null 2>&1
+then
+ echo "Installation of mkrimi schema ..."
+ mysql -umkrimi -pmkrimi mkrimi </usr/share/php/verleihnix/Verleihnix/impl/data/build/sql/schema.sql
+fi
+
+# Apache configuration
+sctl=$(which systemctl) || sctl=$(which sysd2sysv) || (echo "install sysd2sysv"; exit 1)
+
+a2ensite verleihnix
+$sctl reload apache2
+