2 #Script to setup the vagrant instance for running friendica
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"
10 echo ">>> Installing *.xip.io self-signed SSL"
11 SSL_DIR="/etc/ssl/xip.io"
13 PASSPHRASE="vaprobash"
18 localityName=New Haven
20 organizationalUnitName=
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"
30 echo ">>> Installing Apache2 webserver"
31 # The package python-software-properties provides add-apt-repository on Ubuntu Precise Server
32 sudo apt-get install python-software-properties
33 sudo add-apt-repository -y ppa:ondrej/apache2
36 sudo apt-get install -y apache2
37 sudo a2enmod rewrite actions ssl
38 sudo cp /vagrant/util/vagrant_vhost.sh /usr/local/bin/vhost
39 sudo chmod guo+x /usr/local/bin/vhost
40 sudo vhost -s 192.168.22.10.xip.io -d /var/www -p /etc/ssl/xip.io -c xip.io -a friendica.dev
41 sudo a2dissite 000-default
42 sudo service apache2 restart
45 echo ">>> Installing PHP5"
46 sudo apt-get install -y php5 libapache2-mod-php5 php5-cli php5-mysql php5-curl php5-gd
47 sudo service apache2 restart
50 echo ">>> Installing Mysql"
51 sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password root"
52 sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root"
53 sudo apt-get install -qq mysql-server
54 # enable remote access
55 # setting the mysql bind-address to allow connections from everywhere
56 sed -i "s/bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
57 # adding grant privileges to mysql root user from everywhere
58 # thx to http://stackoverflow.com/questions/7528967/how-to-grant-mysql-privileges-in-a-bash-script for this
60 Q1="GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;"
61 Q2="FLUSH PRIVILEGES;"
63 $MYSQL -uroot -proot -e "$SQL"
67 #configure rudimentary mail server (local delivery only)
68 #add Friendica accounts for local user accounts, use email address like vagrant@friendica.dev, read the email with 'mail'.
69 debconf-set-selections <<< "postfix postfix/mailname string friendica.dev"
70 debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Local Only'"
71 sudo apt-get install -y postfix mailutils libmailutils-dev
72 sudo echo -e "friendica1: vagrant\nfriendica2: vagrant\nfriendica3: vagrant\nfriendica4: vagrant\nfriendica5: vagrant" >> /etc/aliases && sudo newaliases
74 #make the vagrant directory the docroot
76 sudo ln -fs /vagrant /var/www
78 # initial config file for friendica in vagrant
79 cp /vagrant/util/htconfig.vagrant.php /vagrant/.htconfig.php
81 # create the friendica database
82 echo "create database friendica" | mysql -u root -proot
83 # import test database
84 $MYSQL -uroot -proot friendica < /vagrant/friendica_test_data.sql
87 echo "*/10 * * * * cd /vagrant; /usr/bin/php include/poller.php" >> friendicacron
88 sudo crontab friendicacron
91 #Optional: checkout addon repositroy
92 #sudo git clone https://github.com/friendica/friendica-addons.git /vagrant/addon