Blame view

vagrant/provision/once-as-root.sh 1.84 KB
4ca21c3e   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  #!/usr/bin/env bash
  
  #== Import script args ==
  
  timezone=$(echo "$1")
  
  #== Bash helpers ==
  
  function info {
    echo " "
    echo "--> $1"
    echo " "
  }
  
  #== Provision script ==
  
  info "Provision-script user: `whoami`"
  
  info "Allocate swap for MySQL 5.6"
  fallocate -l 2048M /swapfile
  chmod 600 /swapfile
  mkswap /swapfile
  swapon /swapfile
  echo '/swapfile none swap defaults 0 0' >> /etc/fstab
  
  info "Configure locales"
  update-locale LC_ALL="C"
  dpkg-reconfigure locales
  
  info "Configure timezone"
  echo ${timezone} | tee /etc/timezone
  dpkg-reconfigure --frontend noninteractive tzdata
  
  info "Prepare root password for MySQL"
  debconf-set-selections <<< "mysql-server-5.6 mysql-server/root_password password \"''\""
  debconf-set-selections <<< "mysql-server-5.6 mysql-server/root_password_again password \"''\""
  echo "Done!"
  
  info "Update OS software"
  apt-get update
  apt-get upgrade -y
  
  info "Install additional software"
  apt-get install -y git php5-curl php5-cli php5-intl php5-mysqlnd php5-gd php5-fpm nginx mysql-server-5.6
  
  info "Configure MySQL"
  sed -i "s/.*bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
  echo "Done!"
  
  info "Configure PHP-FPM"
  sed -i 's/user = www-data/user = vagrant/g' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/group = www-data/group = vagrant/g' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/owner = www-data/owner = vagrant/g' /etc/php5/fpm/pool.d/www.conf
  echo "Done!"
  
  info "Configure NGINX"
  sed -i 's/user www-data/user vagrant/g' /etc/nginx/nginx.conf
  echo "Done!"
  
  info "Enabling site configuration"
  ln -s /app/vagrant/nginx/app.conf /etc/nginx/sites-enabled/app.conf
  echo "Done!"
  
  info "Initailize databases for MySQL"
  mysql -uroot <<< "CREATE DATABASE yii2advanced"
  mysql -uroot <<< "CREATE DATABASE yii2_advanced_tests"
  echo "Done!"
  
  info "Install composer"
  curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer