]> git.mxchange.org Git - friendica.git/blob - bin/dev/vagrant_provision.sh
The worker is split into several classes
[friendica.git] / bin / dev / 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 #
7 # Run as root by vagrant
8 #
9 ##
10
11 ADMIN_NICK="admin"
12 ADMIN_PASSW="admin"
13
14 USER_NICK="user"
15 USER_PASSW="user"
16
17 ##
18
19 echo "Friendica configuration settings"
20 apt-get update
21
22 #Selfsigned cert
23 echo ">>> Installing *.xip.io self-signed SSL"
24 SSL_DIR="/etc/ssl/xip.io"
25 DOMAIN="*.xip.io"
26 EXTRADOMAIN="friendica.local"
27 PASSPHRASE="vaprobash"
28 SUBJ="
29 C=US/
30 ST=Connecticut/
31 O=Vaprobash/
32 localityName=New Haven/
33 commonName=$DOMAIN/
34 subjectAltName=DNS:$EXTRADOMAIN
35 "
36 mkdir -p "$SSL_DIR"
37 openssl genrsa -out "$SSL_DIR/xip.io.key" 4096
38 openssl req -new -subj "$(echo -n "$SUBJ" | tr "\n" "/")" -key "$SSL_DIR/xip.io.key" -out "$SSL_DIR/xip.io.csr" -passin pass:$PASSPHRASE
39 openssl x509 -req -days 365 -in "$SSL_DIR/xip.io.csr" -signkey "$SSL_DIR/xip.io.key" -out "$SSL_DIR/xip.io.crt"
40
41
42 #Install apache2
43 echo ">>> Installing Apache2 webserver"
44 apt-get install -qq apache2
45 a2enmod rewrite actions ssl
46 cp /vagrant/bin/dev/vagrant_vhost.sh /usr/local/bin/vhost
47 chmod guo+x /usr/local/bin/vhost
48 vhost -s 192.168.22.10.xip.io -d /var/www -p /etc/ssl/xip.io -c xip.io -a friendica.local
49 a2dissite 000-default
50 service apache2 restart
51
52 #Install php
53 echo ">>> Installing PHP7"
54 apt-get install -qq php libapache2-mod-php php-cli php-mysql php-curl php-gd php-mbstring php-xml imagemagick php-imagick php-zip
55 systemctl restart apache2
56
57 echo ">>> Installing PHP8"
58 apt-get install -qq -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg
59 echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
60 wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
61 apt update
62 apt-get install -qq php8.0 php8.0-cli php8.0-mysql php8.0-curl php8.0-gd php8.0-mbstring php8.0-xml php8.0-imagick php8.0-zip
63 systemctl restart apache2
64
65 #Install mysql
66 echo ">>> Installing Mysql"
67 debconf-set-selections <<< "mariadb-server mariadb-server/root_password password root"
68 debconf-set-selections <<< "mariadb-server mariadb-server/root_password_again password root"
69 apt-get install -qq mariadb-server
70 # enable remote access
71 # setting the mysql bind-address to allow connections from everywhere
72 sed -i "s/bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
73 # adding grant privileges to mysql root user from everywhere
74 # thx to http://stackoverflow.com/questions/7528967/how-to-grant-mysql-privileges-in-a-bash-script for this
75 MYSQL=`which mysql`
76 Q1="GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;"
77 Q2="FLUSH PRIVILEGES;"
78 SQL="${Q1}${Q2}"
79 $MYSQL -uroot -proot -e "$SQL"
80 # add a separate database user for friendica
81 $MYSQL -uroot -proot -e "CREATE USER 'friendica'@'localhost' identified by 'friendica';"
82 $MYSQL -uroot -proot -e "GRANT ALL PRIVILEGES ON friendica.* TO 'friendica'@'localhost';"
83 $MYSQL -uroot -proot -e "FLUSH PRIVILEGES"
84 systemctl restart mysql
85
86
87 #configure rudimentary mail server (local delivery only)
88 #add Friendica accounts for local user accounts, use email address like vagrant@friendica.local, read the email with 'mail'.
89 echo ">>> Installing 'Local Only' postfix"
90 debconf-set-selections <<< "postfix postfix/mailname string friendica.local"
91 debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Local Only'"
92 apt-get install -qq postfix mailutils libmailutils-dev
93 echo -e "$ADMIN_NICK:   vagrant\n$USER_NICK:    vagrant" >> /etc/aliases && newaliases
94
95 # Friendica needs git for fetching some dependencies
96 echo ">>> Installing git"
97 apt-get install -qq git
98
99 #make the vagrant directory the docroot
100 echo ">>> Symlink /var/www to /vagrant"
101 rm -rf /var/www/
102 ln -fs /vagrant /var/www
103
104 # Setup Friendica
105 cd /var/www
106 echo ">>> Setup Friendica"
107
108 # copy the .htaccess-dist file to .htaccess so that rewrite rules work
109 cp /vagrant/.htaccess-dist /vagrant/.htaccess
110
111 # create the friendica database
112 echo "create database friendica DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" | $MYSQL -u root -proot
113
114 # install friendica
115 bin/console autoinstall -f /vagrant/mods/local.config.vagrant.php
116
117 # add users
118 # (disable a bunch of validation because this is a dev install, deh, it needs invalid emails and stupid passwords)
119 bin/console config system disable_email_validation 1
120 bin/console config system disable_password_exposed 1
121 bin/console user add "$ADMIN_NICK" "$ADMIN_NICK" "$ADMIN_NICK@friendica.local" en
122 bin/console user password "$ADMIN_NICK" "$ADMIN_PASSW"
123 bin/console user add "$USER_NICK" "$USER_NICK" "$USER_NICK@friendica.local" en
124 bin/console user password "$USER_NICK" "$USER_PASSW"
125
126 # create cronjob - activate if you have enough memory in you dev VM
127 # cronjob runs as www-data user
128 echo ">>> Installing cronjob"
129 echo "*/10 * * * *    www-data    cd /vagrant; /usr/bin/php bin/worker.php" >> /etc/cron.d/friendica
130
131 # friendica needs write access to /tmp
132 chmod 777 /tmp