This repository has been archived by the owner on Oct 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 113
/
bootstrap.sh
118 lines (98 loc) · 3.6 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
#!/usr/bin/env bash
SAMPLE_DATA=$1
MAGE_VERSION="1.9.1.0"
DATA_VERSION="1.9.0.0"
# Update Apt
# --------------------
apt-get update
# Install Apache & PHP
# --------------------
apt-get install -y apache2
apt-get install -y php5
apt-get install -y libapache2-mod-php5
apt-get install -y php5-mysqlnd php5-curl php5-xdebug php5-gd php5-intl php-pear php5-imap php5-mcrypt php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php-soap
php5enmod mcrypt
# Delete default apache web dir and symlink mounted vagrant dir from host machine
# --------------------
rm -rf /var/www/html
mkdir /vagrant/httpdocs
ln -fs /vagrant/httpdocs /var/www/html
# Replace contents of default Apache vhost
# --------------------
VHOST=$(cat <<EOF
NameVirtualHost *:8080
Listen 8080
<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName localhost
<Directory "/var/www/html">
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "/var/www/html"
ServerName localhost
<Directory "/var/www/html">
AllowOverride All
</Directory>
</VirtualHost>
EOF
)
echo "$VHOST" > /etc/apache2/sites-enabled/000-default.conf
a2enmod rewrite
service apache2 restart
# Mysql
# --------------------
# Ignore the post install questions
export DEBIAN_FRONTEND=noninteractive
# Install MySQL quietly
apt-get -q -y install mysql-server-5.5
mysql -u root -e "CREATE DATABASE IF NOT EXISTS magentodb"
mysql -u root -e "GRANT ALL PRIVILEGES ON magentodb.* TO 'magentouser'@'localhost' IDENTIFIED BY 'password'"
mysql -u root -e "FLUSH PRIVILEGES"
# Magento
# --------------------
# http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/installing_magento_via_shell_ssh
# Download and extract
if [[ ! -f "/vagrant/httpdocs/index.php" ]]; then
cd /vagrant/httpdocs
wget http://www.magentocommerce.com/downloads/assets/${MAGE_VERSION}/magento-${MAGE_VERSION}.tar.gz
tar -zxvf magento-${MAGE_VERSION}.tar.gz
mv magento/* magento/.htaccess .
chmod -R o+w media var
chmod o+w app/etc
# Clean up downloaded file and extracted dir
rm -rf magento*
fi
# Sample Data
if [[ $SAMPLE_DATA == "true" ]]; then
cd /vagrant
if [[ ! -f "/vagrant/magento-sample-data-${DATA_VERSION}.tar.gz" ]]; then
# Only download sample data if we need to
wget http://www.magentocommerce.com/downloads/assets/${DATA_VERSION}/magento-sample-data-${DATA_VERSION}.tar.gz
fi
tar -zxvf magento-sample-data-${DATA_VERSION}.tar.gz
cp -R magento-sample-data-${DATA_VERSION}/media/* httpdocs/media/
cp -R magento-sample-data-${DATA_VERSION}/skin/* httpdocs/skin/
mysql -u root magentodb < magento-sample-data-${DATA_VERSION}/magento_sample_data_for_${DATA_VERSION}.sql
rm -rf magento-sample-data-${DATA_VERSION}
fi
# Run installer
if [ ! -f "/vagrant/httpdocs/app/etc/local.xml" ]; then
cd /vagrant/httpdocs
sudo /usr/bin/php -f install.php -- --license_agreement_accepted yes \
--locale en_US --timezone "America/Los_Angeles" --default_currency USD \
--db_host localhost --db_name magentodb --db_user magentouser --db_pass password \
--url "http://127.0.0.1:8080/" --use_rewrites yes \
--use_secure no --secure_base_url "http://127.0.0.1:8080/" --use_secure_admin no \
--skip_url_validation yes \
--admin_lastname Owner --admin_firstname Store --admin_email "[email protected]" \
--admin_username admin --admin_password password123123
/usr/bin/php -f shell/indexer.php reindexall
fi
# Install n98-magerun
# --------------------
cd /vagrant/httpdocs
wget https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar
chmod +x ./n98-magerun.phar
sudo mv ./n98-magerun.phar /usr/local/bin/