]> git.mxchange.org Git - friendica.git/blob - util/vagrant_provision.sh
bug fix #1135, show more is usable again
[friendica.git] / util / vagrant_provision.sh
1 #!/bin/bash
2 #Script to setup the vagrant instance for running friendica
3 #
4 #DO NOT RUN on your physical machine as this won't be of any use 
5 #and f.e. deletes your /var/www/ folder!
6 echo "Friendica configuration settings"
7 sudo apt-get update
8
9 #Selfsigned cert
10 echo ">>> Installing *.xip.io self-signed SSL"
11 SSL_DIR="/etc/ssl/xip.io"
12 DOMAIN="*.xip.io"
13 PASSPHRASE="vaprobash"
14 SUBJ="
15 C=US
16 ST=Connecticut
17 O=Vaprobash
18 localityName=New Haven
19 commonName=$DOMAIN
20 organizationalUnitName=
21 emailAddress=
22 "
23 sudo mkdir -p "$SSL_DIR"
24 sudo openssl genrsa -out "$SSL_DIR/xip.io.key" 1024
25 sudo openssl req -new -subj "$(echo -n "$SUBJ" | tr "\n" "/")" -key "$SSL_DIR/xip.io.key" -out "$SSL_DIR/xip.io.csr" -passin pass:$PASSPHRASE
26 sudo openssl x509 -req -days 365 -in "$SSL_DIR/xip.io.csr" -signkey "$SSL_DIR/xip.io.key" -out "$SSL_DIR/xip.io.crt"
27
28
29 #Install apache2
30 echo ">>> Installing Apache2 webserver"
31 sudo add-apt-repository -y ppa:ondrej/apache2
32 sudo apt-key update
33 sudo apt-get update
34 sudo apt-get install -y apache2
35 sudo a2enmod rewrite actions ssl
36 sudo cp /vagrant/util/vagrant_vhost.sh /usr/local/bin/vhost
37 sudo chmod guo+x /usr/local/bin/vhost
38 sudo vhost -s 192.168.22.10.xip.io -d /var/www -p /etc/ssl/xip.io -c xip.io -a friendica.dev
39 sudo a2dissite 000-default
40 sudo service apache2 restart
41
42 #Install php
43 echo ">>> Installing PHP5"
44 sudo apt-get install -y php5 libapache2-mod-php5 php5-cli php5-mysql php5-curl php5-gd
45 sudo service apache2 restart
46
47 #Install mysql
48 echo ">>> Installing Mysql"
49 sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password root"
50 sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root"
51 sudo apt-get install -qq mysql-server
52 # enable remote access
53 # setting the mysql bind-address to allow connections from everywhere
54 sed -i "s/bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
55 # adding grant privileges to mysql root user from everywhere
56 # thx to http://stackoverflow.com/questions/7528967/how-to-grant-mysql-privileges-in-a-bash-script for this
57 MYSQL=`which mysql`
58 Q1="GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;"
59 Q2="FLUSH PRIVILEGES;"
60 SQL="${Q1}${Q2}"
61 $MYSQL -uroot -proot -e "$SQL"
62 service mysql restart
63
64 #make the vagrant directory the docroot
65 sudo rm -rf /var/www/
66 sudo ln -fs /vagrant /var/www
67
68 #delete .htconfig.php file if it exists to have a fresh friendica 
69 #installation
70 if [ -f /vagrant/.htconfig.php ]
71   then
72     sudo rm /vagrant/.htconfig.php
73 fi
74
75 #create the friendica database
76 echo "create database friendica" | mysql -u root -proot
77
78 #create cronjob
79 echo "*/10 * * * * cd /vagrant; /usr/bin/php include/poller.php" >> friendicacron
80 sudo crontab friendicacron
81 sudo rm friendicacron
82
83 #Optional: checkout addon repositroy
84 #sudo git clone https://github.com/friendica/friendica-addons.git /vagrant/addon