├── .gitignore
├── .htaccess
├── README.md
├── app
└── static-content-deploy.sh.sample
└── run
/.gitignore:
--------------------------------------------------------------------------------
1 | instance
2 | app/static-content-deploy.sh
3 | app/env.php
4 | test.sh
5 |
--------------------------------------------------------------------------------
/.htaccess:
--------------------------------------------------------------------------------
1 |
2 | order allow,deny
3 | deny from all
4 |
5 | = 2.4>
6 | Require all denied
7 |
8 |
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [Magento 2 Zero Downtime deploy](https://magefan.com/blog/magento-2-zero-downtime-deployment) by [Magefan](https://magefan.com/magento2-extensions)
2 |
3 |
4 |
5 |
6 |
7 | ## Attention! This script is deprecated, we strongly recommend to use [Magento 2 Zero Downtime Deployment Extension](https://magefan.com/magento-2-zero-downtime-deployment).
8 |
9 |
10 | 
11 |
12 |
13 | * [Installation](https://magefan.com/blog/magento-2-zero-downtime-deployment#installation)
14 | * [Configuration](https://magefan.com/blog/magento-2-zero-downtime-deployment#configuration)
15 | * [Usage](https://magefan.com/blog/magento-2-zero-downtime-deployment#usage)
16 |
17 | ## [Magento 2 Extensions](https://magefan.com/magento-2-extensions) by Magefan
18 |
19 | ### [Magento 2 Google Extensions](https://magefan.com/magento-2-extensions/google-extensions)
20 |
21 | * [Magento 2 Google Indexing](https://magefan.com/magento-2-google-indexing-api)
22 | * [Magento 2 Google Analytics 4](https://magefan.com/magento-2-google-analytics-4)
23 | * [Magento 2 Google Tag Manager](https://magefan.com/magento-2-google-tag-manager)
24 | * [Magento 2 Google Shopping Feed](https://magefan.com/magento-2-google-shopping-feed-extension)
25 | * [Magento 2 Google Customer Reviews](https://magefan.com/magento-2-google-customer-reviews)
26 |
27 | ### Magento 2 SEO Extensions
28 |
29 | * [Magento 2 SEO Extension](https://magefan.com/magento-2-seo-extension)
30 | * [Magento 2 Rich Snippets](https://magefan.com/magento-2-rich-snippets)
31 | * [Magento 2 HTML Sitemap](https://magefan.com/magento-2-html-sitemap-extension)
32 | * [Magento 2 XML Sitemap](https://magefan.com/magento-2-xml-sitemap-extension)
33 | * [Magento 2 Facebook Open Graph](https://magefan.com/magento-2-open-graph-extension-og-tags)
34 | * [Magento 2 Twitter Cards](https://magefan.com/magento-2-twitter-cards-extension)
35 |
36 |
37 | ### [Magento 2 Speed Optimization Extensions](https://magefan.com/magento-2-extensions/speed-optimization)
38 |
39 | * [Magento 2 Google Page Speed Optimizer](https://magefan.com/magento-2-google-page-speed-optimizer)
40 | * [Magento 2 Full Page Cache Warmer](https://magefan.com/magento-2-full-page-cache-warmer)
41 | * [Magento 2 Image Lazy Load](https://magefan.com/magento-2-image-lazy-load-extension)
42 | * [Magento 2 WebP Images](https://magefan.com/magento-2-webp-optimized-images)
43 | * [Magento 2 Rocket JavaScript](https://magefan.com/rocket-javascript-deferred-javascript)
44 |
45 | ### [Magento 2 Admin Panel Extensions](https://magefan.com/magento-2-extensions/admin-extensions)
46 |
47 | * [Magento 2 Size Chart Extension](https://magefan.com/magento-2-size-chart)
48 | * [Magento 2 Security Extension](https://magefan.com/magento-2-security-extension)
49 | * [Magento 2 Admin Action Log](https://magefan.com/magento-2-admin-action-log)
50 | * [Magento 2 Order Editor](https://magefan.com/magento-2-edit-order-extension)
51 | * [Magento 2 Better Order Grid](https://magefan.com/magento-2-better-order-grid-extension)
52 | * [Magento 2 Extended Product Grid](https://magefan.com/magento-2-product-grid-inline-editor)
53 | * [Magento 2 Product Tabs](https://magefan.com/magento-2/extensions/product-tabs)
54 | * [Magento 2 Facebook Pixel](https://magefan.com/magento-2-facebook-pixel-extension)
55 | * [Magento 2 Email Attachments](https://magefan.com/magento-2-email-attachments)
56 | * [Magento 2 Admin View](https://magefan.com/magento-2-admin-view-extension)
57 | * [Magento 2 Admin Email Notifications](https://magefan.com/magento-2-admin-email-notifications)
58 | * [Magento 2 Login As Customer](https://magefan.com/login-as-customer-magento-2-extension)
59 |
60 | ### Magento 2 Blog Extensions
61 |
62 | * [Magento 2 Blog](https://magefan.com/magento2-blog-extension)
63 | * [Magento 2 Multi Blog](https://magefan.com/magento-2-multi-blog-extension)
64 | * [Magento 2 Product Widget](https://magefan.com/magento-2-product-widget)
65 |
66 | ### [Magento 2 Marketing Automation Extensions](https://magefan.com/magento-2-extensions/marketing-automation)
67 |
68 | * [Magento 2 Cookie Consent](https://magefan.com/magento-2-cookie-consent)
69 | * [Magento 2 Product Labels](https://magefan.com/magento-2-product-labels)
70 | * [Magento 2 Base Price](https://magefan.com/magento-2-base-price)
71 | * [Magento 2 Dynamic Categories](https://magefan.com/magento-2-dynamic-categories)
72 | * [Magento 2 Dynamic Blocks and Pages Extension](https://magefan.com/magento-2-cms-display-rules-extension)
73 | * [Magento 2 Automatic Related Products](https://magefan.com/magento-2-automatic-related-products)
74 | * [Magento 2 Price History](https://magefan.com/magento-2-price-history)
75 | * [Magento 2 Mautic Integration](https://magefan.com/magento-2-mautic-extension)
76 | * [Magento 2 YouTube Video](https://magefan.com/magento2-youtube-extension)
77 |
78 | ### [Magento 2 Cart Extensions](https://magefan.com/magento-2-extensions/cart-extensions)
79 |
80 | * [Magento 2 Checkout Extension](https://magefan.com/better-magento-2-checkout-extension)
81 | * [Magento 2 Coupon Code](https://magefan.com/magento-2-coupon-code-link)
82 | * [Magento 2 Guest to Customer](https://magefan.com/magento2-convert-guest-to-customer)
83 |
84 | ### [Magento 2 Multi-Language Extensions](https://magefan.com/magento-2-extensions/multi-language-extensions)
85 |
86 | * [Magento 2 Hreflang Tags](https://magefan.com/magento2-alternate-hreflang-extension)
87 | * [Magento 2 Auto Currency Switcher](https://magefan.com/magento-2-currency-switcher-auto-currency-by-country)
88 | * [Magento 2 Auto Language Switcher](https://magefan.com/magento-2-auto-language-switcher)
89 | * [Magento 2 GeoIP Store Switcher](https://magefan.com/magento-2-geoip-switcher-extension)
90 | * [Magento 2 Translation](https://magefan.com/magento-2-translation-extension)
91 |
92 | ### [Developers Tools](https://magefan.com/magento-2-extensions/developer-tools)
93 |
94 | * [Magento 2 Cron Schedule](https://magefan.com/magento-2-cron-schedule)
95 | * [Magento 2 CLI Extension](https://magefan.com/magento2-cli-extension)
96 | * [Magento 2 Conflict Detector](https://magefan.com/magento2-conflict-detector)
97 |
98 | ## [Shopify Apps](https://magefan.com/shopify/apps) by Magefan
99 |
100 | * [Shopify Login As Customer](https://apps.shopify.com/login-as-customer)
101 | * [Shopify Blog](https://apps.shopify.com/magefan-blog)
102 | * [Shopify Size Chart](https://magefan.com/shopify/apps/size-chart)
103 | * [Shopify Google Indexer](https://magefan.com/shopify/apps/google-indexing)
104 | * [Shopify Product Feeds](https://magefan.com/shopify/apps/product-feed)
105 |
--------------------------------------------------------------------------------
/app/static-content-deploy.sh.sample:
--------------------------------------------------------------------------------
1 | cd $INSTANCE
2 | bin/magento setup:static-content:deploy -f
3 | #bin/magento setup:static-content:deploy -f --theme=Vendor/theme_name nl_NL
4 |
--------------------------------------------------------------------------------
/run:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | CURRENT_VERSION=1.0.2
3 |
4 | usage()
5 | {
6 | echo "usage: bash deploy/run.sh [-a] | [-u] | [-d] | [-s] | [-m] | [-v]"
7 | }
8 |
9 | vercomp () {
10 | if [[ $1 == $2 ]]
11 | then
12 | return 0
13 | fi
14 | local IFS=.
15 | local i ver1=($1) ver2=($2)
16 | # fill empty fields in ver1 with zeros
17 | for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
18 | do
19 | ver1[i]=0
20 | done
21 | for ((i=0; i<${#ver1[@]}; i++))
22 | do
23 | if [[ -z ${ver2[i]} ]]
24 | then
25 | # fill empty fields in ver2 with zeros
26 | ver2[i]=0
27 | fi
28 | if ((10#${ver1[i]} > 10#${ver2[i]}))
29 | then
30 | return 1
31 | fi
32 | if ((10#${ver1[i]} < 10#${ver2[i]}))
33 | then
34 | return 2
35 | fi
36 | done
37 | return 0
38 | }
39 |
40 | NEW_VERSION=$(curl -s "https://api.github.com/repos/magefan/magento2-zero-downtime-deploy/releases/latest" | awk -F '"' '/tag_name/{print $4}')
41 | if [ $NEW_VERSION ]; then
42 | vercomp $NEW_VERSION $CURRENT_VERSION
43 | case $? in
44 | 1)
45 | echo -e "\e[32m${1}There is a new Zero Downtime v$NEW_VERSION available. Your current version is $CURRENT_VERSION \e[0m"
46 | echo -e "\e[32m${1}To install the newest version remove the current one and install the script again:\e[0m"
47 | echo -e "\e[32m${1}https://magefan.com/blog/magento-2-zero-downtime-deployment\e[0m"
48 |
49 | ;;
50 | esac
51 | fi
52 |
53 | if [ $# -gt 0 ]; then
54 | echo ''
55 | else
56 | SETUP_ALL=1
57 | fi
58 |
59 |
60 | LAST_OPTION='';
61 | SETUP_MODULES=''
62 | while [ "$1" != "" ]; do
63 | case $1 in
64 | -a | --all | -u | --upgrade )
65 | SETUP_ALL=1
66 | ;;
67 | -d | --di )
68 | SETUP_DI=1
69 | ;;
70 | -s | --static-content )
71 | SETUP_STATIC_CONTENT=1
72 | ;;
73 | -v | --version )
74 | echo $CURRENT_VERSION
75 | exit
76 | ;;
77 | -m | --modules )
78 | #do nothing here
79 | ;;
80 | -h | --help )
81 | usage
82 | exit
83 | ;;
84 | * )
85 | if [ "$LAST_OPTION" != -m ] && [ "$LAST_OPTION" != --modules ]; then
86 | usage
87 | exit 1
88 | else
89 | SETUP_MODULES="$SETUP_MODULES $1"
90 | shift
91 | continue
92 | fi
93 | esac
94 | LAST_OPTION=$1
95 | shift
96 | done
97 |
98 | if [ "$SETUP_MODULES" ]; then
99 | SETUP_ALL=1
100 | fi
101 |
102 | MDIR="$PWD"
103 | DIR="$PWD/deploy"
104 | cd $DIR
105 | INSTANCE="$PWD/instance"
106 | MAGE_INIT_PARAMS="--magento-init-params=MAGE_DIRS[base][path]=$INSTANCE&MAGE_DIRS[cache][path]=$INSTANCE/var/cache"
107 |
108 | SEK=SECONDS
109 | echo 'Remove old files ...'
110 | rm -rf $INSTANCE
111 | echo 'Create new instance folders and files ...'
112 | mkdir -p $INSTANCE;
113 | cd $INSTANCE
114 |
115 | mkdir -p generated;
116 | mkdir -p pub;
117 | mkdir -p pub/static;
118 | mkdir -p var;
119 |
120 | cp -rf $MDIR/app app
121 | cp -rf $MDIR/bin bin
122 | cp -rf $MDIR/dev dev
123 | cp -rf $MDIR/lib lib
124 | cp -rf $MDIR/setup setup
125 | cp -rf $MDIR/vendor vendor
126 | cp -rf $MDIR/phpserver phpserver
127 | cp -rf $MDIR/update update
128 | cp -rf $MDIR/composer.json composer.json
129 | cp -rf $MDIR/composer.lock composer.lock
130 |
131 |
132 | # temporary copy env.php file with save cache local
133 | rm app/etc/env.php
134 | cp -rf $DIR/app/env.php app/etc/env.php
135 |
136 | if [ "$SETUP_MODULES" ]; then
137 | echo 'Enabling modules ...'
138 | bin/magento module:enable $SETUP_MODULES $MAGE_INIT_PARAMS
139 | fi
140 |
141 | echo 'Start deploying ...'
142 |
143 | if [ $SETUP_ALL ] || [ $SETUP_DI ]; then
144 | bin/magento setup:di:compile
145 | fi
146 |
147 | if [ $SETUP_ALL ] || [ $SETUP_STATIC_CONTENT ]; then
148 | #$INSTANCE/bin/magento setup:static-content:deploy
149 | . "$DIR/app/static-content-deploy.sh"
150 | cd $INSTANCE
151 | fi
152 |
153 |
154 | if [ $SETUP_ALL ]; then
155 | cd $MDIR
156 | bin/magento maintenance:enable
157 | cd $INSTANCE
158 | bin/magento setup:upgrade --keep-generated $MAGE_INIT_PARAMS
159 | fi
160 |
161 |
162 | if [ $SETUP_ALL ]; then
163 | GENERATED_FOLDERS=( "app/etc/config.php" "generated" "pub/static/adminhtml" "pub/static/frontend" "pub/static/deployed_version.txt" "var/view_preprocessed" )
164 | else
165 | GENERATED_FOLDERS=( "app/etc/config.php" )
166 | if [ $SETUP_DI ]; then
167 | GENERATED_FOLDERS+=( "generated")
168 | fi
169 | if [ $SETUP_STATIC_CONTENT ]; then
170 | GENERATED_FOLDERS+=( "pub/static/adminhtml" "pub/static/frontend" "pub/static/deployed_version.txt" "var/view_preprocessed" )
171 | fi
172 | fi
173 |
174 |
175 | echo 'Copy new files into Magento ... '
176 | for i in "${GENERATED_FOLDERS[@]}"
177 | do
178 | :
179 | cp -rf $i "$MDIR/$i-deploy"
180 | done
181 |
182 | echo 'Replace files in Magento ... '
183 | for i in "${GENERATED_FOLDERS[@]}"
184 | do
185 | :
186 | mv "$MDIR/$i" "$MDIR/$i-old-deploy"
187 | mv "$MDIR/$i-deploy" "$MDIR/$i"
188 | done
189 |
190 | echo 'Remove magento pub/static/_cache ... '
191 | rm -rf "$MDIR/pub/static/_cache"
192 |
193 | echo 'Replace old Magento files ... '
194 | for i in "${GENERATED_FOLDERS[@]}"
195 | do
196 | :
197 | rm -rf "$MDIR/$i-old-deploy"
198 | done
199 |
200 | if [ $SETUP_ALL ]; then
201 | cd $MDIR
202 | bin/magento maintenance:disable
203 | fi
204 |
205 | cd $MDIR
206 | bin/magento c:e
207 | bin/magento c:f
208 |
209 | echo 'Remove tmp files ...'
210 | rm -rf $INSTANCE
211 |
212 | echo 'Finished.'
213 |
--------------------------------------------------------------------------------