forked from pawco/vagrant-lamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
129 lines (95 loc) · 4.76 KB
/
bootstrap.sh
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env bash
# Variables
MYSQL_PASS=$1
XDEBUG_IDEKEY=$2
# Set timezone to Belgrade/Serbia -> you will probably need to change this
sudo unlink /etc/localtime
sudo ln -s /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
sudo apt-get update >> /vagrant/build.log 2>&1
echo "-- Installing debianconf --"
sudo apt-get install -y debconf-utils >> /vagrant/build.log 2>&1
echo "-- Installing dirmngr --"
sudo apt-get install dirmngr >> /vagrant/build.log 2>&1
echo "-- Installing unzip --"
sudo apt-get install -y unzip >> /vagrant/build.log 2>&1
echo "-- Installing aptitude --"
sudo apt-get -y install aptitude >> /vagrant/build.log 2>&1
echo "-- Updating package lists --"
sudo aptitude update -y >> /vagrant/build.log 2>&1
#echo "-- Updating system --"
#sudo aptitude safe-upgrade -y >> /vagrant/build.log 2>&1
echo "-- Uncommenting alias for ll --"
sed -i "s/#alias ll='.*'/alias ll='ls -al'/g" /home/vagrant/.bashrc
echo "-- Installing curl --"
sudo aptitude install -y curl >> /vagrant/build.log 2>&1
echo "-- Installing apt-transport-https --"
sudo aptitude install -y apt-transport-https >> /vagrant/build.log 2>&1
echo "-- Adding GPG key for sury repo --"
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg >> /vagrant/build.log 2>&1
echo "-- Adding PHP 7 packages repo --"
echo 'deb https://packages.sury.org/php/ buster main' | sudo tee -a /etc/apt/sources.list >> /vagrant/build.log 2>&1
echo "-- Updating package lists again after adding sury --"
sudo aptitude update -y >> /vagrant/build.log 2>&1
echo "-- Installing Apache --"
sudo aptitude install -y apache2 >> /vagrant/build.log 2>&1
echo "-- Enabling mod rewrite --"
sudo a2enmod rewrite >> /vagrant/build.log 2>&1
echo "-- Configuring Apache --"
sudo sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf
echo "-- Adding MySQL GPG key --"
wget -O /tmp/RPM-GPG-KEY-mysql https://repo.mysql.com/RPM-GPG-KEY-mysql >> /vagrant/build.log 2>&1
sudo apt-key add /tmp/RPM-GPG-KEY-mysql >> /vagrant/build.log 2>&1
echo "-- Adding MySQL repo --"
echo "deb http://repo.mysql.com/apt/debian/ buster mysql-5.7" | sudo tee /etc/apt/sources.list.d/mysql.list >> /vagrant/build.log 2>&1
echo "-- Updating package lists after adding MySQL repo --"
sudo aptitude update -y >> /vagrant/build.log 2>&1
sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password $MYSQL_PASS"
sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password $MYSQL_PASS"
echo "-- Installing MySQL server --"
sudo aptitude install -y mysql-server >> /vagrant/build.log 2>&1
echo "-- Creating alias for quick access to the MySQL (just type: db) --"
echo "alias db='mysql -u root -p$MYSQL_PASS'" >> /home/vagrant/.bashrc
echo "-- Execute sql from quieris.sql --"
mysql -u root -p$MYSQL_PASS < /vagrant/queries.sql >> /vagrant/build.log 2>&1
echo "-- Installing PHP stuff --"
sudo aptitude install -y libapache2-mod-php7.3 php7.3 php7.3-pdo php7.3-mysql php7.3-mbstring php7.3-xml php7.3-intl php7.3-tokenizer php7.3-gd php7.3-imagick php7.3-curl php7.3-zip php7.3-bcmath >> /vagrant/build.log 2>&1
echo "-- Installing Xdebug --"
sudo aptitude install -y php-xdebug >> /vagrant/build.log 2>&1
echo "-- Installing libpng-dev (required for some node package) --"
sudo aptitude install -y libpng-dev >> /vagrant/build.log 2>&1
echo "-- Configuring xDebug (idekey = PHP_STORM) --"
sudo tee -a /etc/php/7.3/mods-available/xdebug.ini << END
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9001
xdebug.idekey=$XDEBUG_IDEKEY
END
echo "-- Restarting Apache --"
sudo /etc/init.d/apache2 restart >> /vagrant/build.log 2>&1
echo "-- Installing Git --"
sudo aptitude install -y git >> /vagrant/build.log 2>&1
echo "-- Installing Composer --"
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer >> /vagrant/build.log 2>&1
echo "-- Installing node.js --"
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - >> /vagrant/build.log 2>&1
sudo aptitude install -y nodejs >> /vagrant/build.log 2>&1
echo "-- Setting document root --"
if [ ! -L /var/www/html ]; then
if [ ! -d /vagrant/source/public ]; then
sudo mkdir -p /vagrant/source/public
fi
sudo rm -rf /var/www/html
sudo ln -fs /vagrant/source/public /var/www/html
fi
if [ -d /vagrant/source/node_modules ]; then
echo "-- Removing node_modules folder --"
sudo rm -rf /vagrant/source/node_modules
fi
echo "-- Creating node_modules folder outside synced folder --"
mkdir /home/vagrant/node_modules
echo "-- Linking node_modules folder --"
sudo ln -fs /home/vagrant/node_modules /vagrant/source/node_modules
if [ -d /vagrant/source/vendor ]; then
echo "-- Removing vendor folder --"
sudo rm -rf /vagrant/source/vendor
fi