-
Notifications
You must be signed in to change notification settings - Fork 4
/
script.sh
executable file
·138 lines (112 loc) · 3.7 KB
/
script.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
130
131
132
133
134
135
136
137
138
#!/bin/bash
set -xe
PHP_VERSION=${1:-7.2}
PR=$2
BRANCH=${3:-develop}
NO_INSTALL=$4
export DEBIAN_FRONTEND=noninteractive
executeCommand() {
sudo -E su vagrant -c "${1}"
}
apt -y install apt-transport-https lsb-release ca-certificates curl
# Install php source
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
# Install nodejs source
curl -sL https://deb.nodesource.com/setup_10.x | bash -
# update
apt update
apt install -y apache2 vim emacs-nox git unzip default-mysql-server imagemagick make nodejs
# Create database and user
mysql -u root -e 'CREATE DATABASE prestashop;' || true
mysql -u root -e "CREATE USER 'prestashop'@'localhost' IDENTIFIED BY 'prestashop';" || true
mysql -u root -e "GRANT ALL ON *.* TO 'prestashop'@'localhost';"
mysql -u root -e "FLUSH PRIVILEGES;"
# Install all wanted php versions
for version in '7.1' '7.2' '7.3' '7.4'; do
apt install -y \
libapache2-mod-php${version} \
php${version} \
php${version}-bcmath \
php${version}-bz2 \
php${version}-cli \
php${version}-common \
php${version}-curl \
php${version}-fpm \
php${version}-gd \
php${version}-imagick \
php${version}-intl \
php${version}-json \
php${version}-ldap \
php${version}-mbstring \
php${version}-mysql \
php${version}-opcache \
php${version}-pgsql \
php${version}-readline \
php${version}-xdebug \
php${version}-xml \
php${version}-xsl \
php${version}-zip
a2dismod php${version}
done
a2enmod php${PHP_VERSION}
a2enmod rewrite
# Prepare phpmyadmin & gitconfig
pushd /tmp
cp gitconfig /root/.gitconfig
cp phpmyadmin.conf /etc/apache2/conf-available/phpmyadmin.conf
a2enconf phpmyadmin.conf
if [ ! -d /usr/share/phpmyadmin ]; then
wget https://files.phpmyadmin.net/phpMyAdmin/4.9.4/phpMyAdmin-4.9.4-all-languages.zip
unzip phpMyAdmin-4.9.4-all-languages.zip
mv phpMyAdmin-4.9.4-all-languages /usr/share/phpmyadmin
fi
popd
# Prepare composer
if [ ! -f /usr/local/bin/composer ]; then
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
chmod +x /usr/local/bin/composer
fi
# Make sure
sed -i "s/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=vagrant/" /etc/apache2/envvars
sed -i "s/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=vagrant/" /etc/apache2/envvars
# restart apache because of a2enmod commands
service apache2 restart
# Prepare the git repository backup
pushd /var/www
if [ ! -d backup/prestashop ]; then
mkdir backup
pushd backup
git clone https://github.com/PrestaShop/PrestaShop.git prestashop
pushd prestashop
git config core.fileMode false
popd
popd
fi
# Fetch origin
pushd backup/prestashop
git fetch -p
popd
# prepare the new PrestaShop directory
pushd html
rm -rf prestashop
cp -R /var/www/backup/prestashop .
chown -hR vagrant:vagrant ./
chmod -R ug+rwx ./
pushd prestashop
if [ ! -z "${PR}" ] && [ ! -z "${BRANCH}" ]; then
executeCommand "git pr origin ${PR} ${BRANCH} || (git rebase --abort && git prm origin ${PR} ${BRANCH})"
elif [ ! -z "${BRANCH}" ]; then
executeCommand "git checkout ${BRANCH}"
fi
if [ -f Makefile ]; then
executeCommand "make install"
else
executeCommand "composer install"
fi
# install PrestaShop
if [ -z "${NO_INSTALL}" ]; then
executeCommand "php${PHP_VERSION} install-dev/index_cli.php --language=en --country=fr --domain=192.168.42.42 --base_uri=prestashop --db_server=127.0.0.1 --db_user=prestashop --db_password=prestashop --db_name=prestashop --db_create=1 --name=prestashop [email protected] --password=prestashop_demo"
fi
popd
popd