Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
4.3 KiB

  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. #Selfsigned cert
  9. echo ">>> Installing *.xip.io self-signed SSL"
  10. SSL_DIR="/etc/ssl/xip.io"
  11. DOMAIN="*.xip.io"
  12. PASSPHRASE="vaprobash"
  13. SUBJ="
  14. C=US
  15. ST=Connecticut
  16. O=Vaprobash
  17. localityName=New Haven
  18. commonName=$DOMAIN
  19. organizationalUnitName=
  20. emailAddress=
  21. "
  22. sudo mkdir -p "$SSL_DIR"
  23. sudo openssl genrsa -out "$SSL_DIR/xip.io.key" 4096
  24. 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
  25. sudo openssl x509 -req -days 365 -in "$SSL_DIR/xip.io.csr" -signkey "$SSL_DIR/xip.io.key" -out "$SSL_DIR/xip.io.crt"
  26. #Install apache2
  27. echo ">>> Installing Apache2 webserver"
  28. sudo apt-get install -y apache2
  29. sudo a2enmod rewrite actions ssl
  30. sudo cp /vagrant/util/vagrant_vhost.sh /usr/local/bin/vhost
  31. sudo chmod guo+x /usr/local/bin/vhost
  32. if [ $( lsb_release -c | cut -f 2 ) == "trusty" ]; then
  33. sudo vhost -s 192.168.22.10.xip.io -d /var/www -p /etc/ssl/xip.io -c xip.io -a friendica-trusty.dev
  34. sudo a2dissite 000-default
  35. sudo service apache2 restart
  36. elif [ $( lsb_release -c | cut -f 2 ) == "xenial" ]; then
  37. sudo vhost -s 192.168.22.11.xip.io -d /var/www -p /etc/ssl/xip.io -c xip.io -a friendica-xenial.dev
  38. sudo a2dissite 000-default
  39. sudo systemctl restart apache2
  40. fi
  41. #Install php
  42. if [ $( lsb_release -c | cut -f 2 ) == "trusty" ]; then
  43. echo ">>> Installing PHP5"
  44. sudo apt-get install -y php5 libapache2-mod-php5 php5-cli php5-mysql php5-curl php5-gd
  45. sudo apt-get install -y imagemagick
  46. sudo apt-get install -y php5-imagick
  47. sudo service apache2 restart
  48. elif [ $( lsb_release -c | cut -f 2 ) == "xenial" ]; then
  49. echo ">>> Installing PHP7"
  50. sudo apt-get install -y php libapache2-mod-php php-cli php-mysql php-curl php-gd
  51. sudo apt-get install -y imagemagick
  52. sudo apt-get install -y php-imagick
  53. sudo systemctl restart apache2
  54. fi
  55. #Install mysql
  56. echo ">>> Installing Mysql"
  57. sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password root"
  58. sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root"
  59. sudo apt-get install -qq mysql-server
  60. # enable remote access
  61. # setting the mysql bind-address to allow connections from everywhere
  62. sed -i "s/bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
  63. # adding grant privileges to mysql root user from everywhere
  64. # thx to http://stackoverflow.com/questions/7528967/how-to-grant-mysql-privileges-in-a-bash-script for this
  65. MYSQL=`which mysql`
  66. Q1="GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;"
  67. Q2="FLUSH PRIVILEGES;"
  68. SQL="${Q1}${Q2}"
  69. $MYSQL -uroot -proot -e "$SQL"
  70. if [ $( lsb_release -c | cut -f 2 ) == "trusty" ]; then
  71. service mysql restart
  72. elif [ $( lsb_release -c | cut -f 2 ) == "xenial" ]; then
  73. systemctl restart mysql
  74. fi
  75. #configure rudimentary mail server (local delivery only)
  76. #add Friendica accounts for local user accounts, use email address like vagrant@friendica.dev, read the email with 'mail'.
  77. if [ $( lsb_release -c | cut -f 2 ) == "trusty" ]; then
  78. debconf-set-selections <<< "postfix postfix/mailname string friendica-trusty.dev"
  79. elif [ $( lsb_release -c | cut -f 2 ) == "xenial" ]; then
  80. debconf-set-selections <<< "postfix postfix/mailname string friendica-xenial.dev"
  81. fi
  82. debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Local Only'"
  83. sudo apt-get install -y postfix mailutils libmailutils-dev
  84. sudo echo -e "friendica1: vagrant\nfriendica2: vagrant\nfriendica3: vagrant\nfriendica4: vagrant\nfriendica5: vagrant" >> /etc/aliases && sudo newaliases
  85. #make the vagrant directory the docroot
  86. sudo rm -rf /var/www/
  87. sudo ln -fs /vagrant /var/www
  88. # initial config file for friendica in vagrant
  89. cp /vagrant/util/htconfig.vagrant.php /vagrant/.htconfig.php
  90. # create the friendica database
  91. echo "create database friendica" | mysql -u root -proot
  92. # import test database
  93. $MYSQL -uroot -proot friendica < /vagrant/friendica_test_data.sql
  94. #create cronjob
  95. echo "*/10 * * * * cd /vagrant; /usr/bin/php include/poller.php" >> friendicacron
  96. sudo crontab friendicacron
  97. sudo rm friendicacron
  98. #Optional: checkout addon repositroy
  99. #sudo git clone https://github.com/friendica/friendica-addons.git /vagrant/addon