Skip to content

Commit 01ddea2

Browse files
author
Alexander Paliarush
committed
- Added setup and upgrade cron scripts support
- Improved consistency of braces usage with conditional operators
1 parent 98a021e commit 01ddea2

12 files changed

+39
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2323

2424
### Added
2525

26+
- Added setup and upgrade cron scripts to crontab
2627
- Added logging of all emails in HTML format to `vagrant-magento/log/email`
2728
- Added host wrapper script for bin/magento command on guest
2829
- Added ability to modify guest config files (PHP, Apache etc) directly from host IDE

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,15 @@ Unique IP address, SSH port and domain name will be generated for each new insta
237237

238238
### Reset environment
239239

240-
It is possible to reset project environment to default state, which you usually get just after project initialization. The following command will delete vagrant box, vagrant project settings and PhpStorm project settings. After that it will initialize project from scratch. Magento 2 code base (`magento2ce` directory) and [etc/config.yaml](etc/config.yaml.dist) will stay untouched, but guest config files (located in [etc/guest](etc/guest)) will be removed.
240+
It is possible to reset project environment to default state, which you usually get just after project initialization. The following command will delete vagrant box and vagrant project settings. After that it will initialize project from scratch. Magento 2 code base (`magento2ce` directory) and [etc/config.yaml](etc/config.yaml.dist) and PhpStorm settings will stay untouched, but guest config files (located in [etc/guest](etc/guest)) will be cleared.
241241

242242
Go to 'vagrant-magento' created earlier and run in command line:
243243

244244
```
245245
bash init_project.sh -f
246246
```
247247

248-
You can reset project settings and Magento 2 code base at the same time. Magento 2 code base will be deleted and then cloned from the repositories specified in [etc/config.yaml](etc/config.yaml.dist)
249-
250-
Go to 'vagrant-magento' created earlier and run in command line:
248+
It is possible to reset Magento 2 code base at the same time. Magento 2 code base will be deleted and then cloned from the repositories specified in [etc/config.yaml](etc/config.yaml.dist)
251249

252250
```
253251
bash init_project.sh -fc
@@ -257,6 +255,10 @@ To reset PhpStorm project configuration, in addition to `-f` specify `-p` option
257255

258256
```
259257
bash init_project.sh -fp
260-
OR
258+
```
259+
260+
Ultimate project reset can be achieved by combining all available flags:
261+
262+
```
261263
bash init_project.sh -fcp
262264
```

m-switch-to-ce

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh")
99
# Enable trace printing and exit on the first error
1010
set -ex
1111

12-
if [ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]; then
12+
if [[ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]]; then
1313
echo "EE codebase is not available"
1414
exit 0
1515
fi
1616

17-
if [ ! -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then
17+
if [[ ! -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then
1818
echo "Already switched to CE"
1919
exit 0
2020
fi
@@ -27,10 +27,10 @@ git checkout composer.lock
2727

2828
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
2929
# Prevent issues on Windows with incorrect symlinks to files
30-
if [ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then
30+
if [[ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then
3131
rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json
3232
fi
33-
if [ -f ${magento_ce_dir}/app/etc/enterprise/di.xml ] && [ ! -L ${magento_ce_dir}/app/etc/enterprise ]; then
33+
if [[ -f ${magento_ce_dir}/app/etc/enterprise/di.xml ]] && [[ ! -L ${magento_ce_dir}/app/etc/enterprise ]]; then
3434
rm ${magento_ce_dir}/app/etc/enterprise/di.xml
3535
rmdir ${magento_ce_dir}/app/etc/enterprise
3636
fi

m-switch-to-ee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh")
99
# Enable trace printing and exit on the first error
1010
set -ex
1111

12-
if [ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]; then
12+
if [[ ! -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]]; then
1313
echo "EE codebase is not available"
1414
exit 0
1515
fi
1616

17-
if [ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then
17+
if [[ -f ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then
1818
echo "Already switched to EE"
1919
exit 0
2020
fi
@@ -26,11 +26,11 @@ cp ${magento_ee_dir}/composer.lock ${magento_ce_dir}/composer.lock
2626

2727
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs") == 0 ]]; then
2828
# Prevent issues on Windows with incorrect symlinks to files
29-
if [ -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ] && [ -L ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]; then
29+
if [[ -f ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ]] && [[ -L ${magento_ce_dir}/app/etc/aliases_to_classes_map.json ]]; then
3030
rm ${magento_ce_dir}/app/etc/aliases_to_classes_map.json
3131
cp ${magento_ee_dir}/app/etc/aliases_to_classes_map.json ${magento_ce_dir}/app/etc/aliases_to_classes_map.json
3232
fi
33-
if [ -f ${magento_ee_dir}/app/etc/enterprise/di.xml ] && [ -L ${magento_ce_dir}/app/etc/enterprise ]; then
33+
if [[ -f ${magento_ee_dir}/app/etc/enterprise/di.xml ]] && [[ -L ${magento_ce_dir}/app/etc/enterprise ]]; then
3434
rm ${magento_ce_dir}/app/etc/enterprise
3535
mkdir ${magento_ce_dir}/app/etc/enterprise
3636
cp ${magento_ee_dir}/app/etc/enterprise/di.xml ${magento_ce_dir}/app/etc/enterprise/di.xml

scripts/guest/link_configs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ function process_configs () {
55
configs=$2
66
for config in "${configs[@]}"
77
do
8-
if [ ! -d /vagrant/etc/guest/${config} ] && [ ! -f /vagrant/etc/guest/${config} ]; then
9-
if [ -d ${configs_path}/${config} ] || [ -f ${configs_path}/${config} ]; then
8+
if [[ ! -d /vagrant/etc/guest/${config} ]] && [[ ! -f /vagrant/etc/guest/${config} ]]; then
9+
if [[ -d ${configs_path}/${config} ]] || [[ -f ${configs_path}/${config} ]]; then
1010
sudo rm -rf "${configs_path}/${config}.back"
1111
sudo cp -rp ${configs_path}/${config} "${configs_path}/${config}.back"
1212
sudo mv ${configs_path}/${config} /vagrant/etc/guest/${config}

scripts/guest/log_email

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bash
22

33
email_log_dir=$1
4-
if [ ! -d ${email_log_dir} ]; then
5-
mkdir -p ${email_log_dir}
4+
if [[ ! -d ${email_log_dir} ]]; then
5+
mkdir -p "${email_log_dir}"
66
fi
77

88
# Construct email file path

scripts/guest/m-reinstall

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ install_cmd="./bin/magento setup:install \
6363
--use-rewrites=1"
6464

6565
# Configure Rabbit MQ
66-
if [ -f "${MAGENTO_ROOT}/app/etc/enterprise/di.xml" ] && [ -d "${MAGENTO_ROOT}/app/code/Magento/Amqp" ]; then
66+
if [[ -f "${MAGENTO_ROOT}/app/etc/enterprise/di.xml" ]] && [[ -d "${MAGENTO_ROOT}/app/code/Magento/Amqp" ]]; then
6767
install_cmd="${install_cmd} \
6868
--amqp-host=${setupOptions[amqp_host]} \
6969
--amqp-port=${setupOptions[amqp_port]} \
@@ -78,7 +78,9 @@ php ${install_cmd}
7878
# php -d xdebug.remote_host=192.168.10.1 -d xdebug.idekey=PHPSTORM -d xdebug.remote_connect_back=0 -d xdebug.remote_autostart=1 ${install_cmd}
7979

8080
# Enable Magento cron jobs
81-
echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &" | crontab -u vagrant -
81+
echo "* * * * * php ${MAGENTO_ROOT}/bin/magento cron:run &
82+
* * * * * php ${MAGENTO_ROOT}/update/cron.php &
83+
* * * * * php ${MAGENTO_ROOT}/bin/magento setup:cron:run &" | crontab -u vagrant -
8284

8385
use_nfs=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs")
8486
is_windows_host=${IS_WINDOWS_HOST}

scripts/guest/unlink_configs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ function process_configs () {
55
configs=$2
66
for config in "${configs[@]}"
77
do
8-
if [ -L ${config_dir}/${config} ] && [ -e ${config_dir}/${config} ]; then
8+
if [[ -L ${config_dir}/${config} ]] && [[ -e ${config_dir}/${config} ]]; then
99
sudo rm ${config_dir}/${config}
1010
sudo mv /vagrant/etc/guest/${config} ${config_dir}/${config}
11-
elif [ ! -e ${config_dir}/${config} ] && [ -e "${config_dir}/${config}.back" ]; then
11+
elif [[ ! -e ${config_dir}/${config} ]] && [[ -e "${config_dir}/${config}.back" ]]; then
1212
sudo rm -rf ${config_dir}/${config}
1313
sudo cp -rp "${config_dir}/${config}.back" ${config_dir}/${config}
1414
fi

scripts/host/configure_php_storm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ rm -f "${vagrant_dir}/.idea/.name.back"
3838
mv "${vagrant_dir}/.idea/host_name.iml" "${vagrant_dir}/.idea/${magento_host_name}.iml"
3939

4040
repository_url_ee=$(bash "${vagrant_dir}/scripts/get_config_value.sh" "repository_url_ee")
41-
if [ -z ${repository_url_ee} ]; then
41+
if [[ -z ${repository_url_ee} ]]; then
4242
mv "${vagrant_dir}/.idea/vcs.ce.xml" "${vagrant_dir}/.idea/vcs.xml"
4343
rm "${vagrant_dir}/.idea/vcs.ee.xml"
4444
else

scripts/host/get_host_os.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/env bash
22

3-
if [ "$(uname)" == "Darwin" ]; then
3+
if [[ "$(uname)" == "Darwin" ]]; then
44
echo "OSX"
5-
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
5+
elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then
66
echo "Linux"
7-
elif [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]; then
7+
elif [[ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]]; then
88
echo "Windows"
9-
elif [ "$(expr substr $(uname -s) 1 6)" == "CYGWIN" ]; then
9+
elif [[ "$(expr substr $(uname -s) 1 6)" == "CYGWIN" ]]; then
1010
echo "Windows"
1111
else
1212
echo "Unknown host OS"

0 commit comments

Comments
 (0)