├── .github └── FUNDING.yml ├── .gitignore ├── README.md ├── apc_clear.php ├── apc_clear_call.php ├── release-modman.sh └── release.sh /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [customgento] 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Deployment Scripts for Small- and Medium-Size Magento Shops 2 | =========================================================== 3 | "Simple" deployment scripts for small- and medium-sized Magento shops. More information in the related blog post under 4 | http://www.coderblog.de/deployment-for-small-and-medium-sized-magento-shops. 5 | 6 | Of course these scripts come with absolutely no warranty. Adapt them to your needs and test them extensively before 7 | using them in production. 8 | 9 | Happy deploying! 10 | 11 | Contribution 12 | ------------ 13 | Any contribution is highly appreciated. The best way to contribute code is to open a [pull request on GitHub](https://help.github.com/articles/using-pull-requests). 14 | 15 | Developer 16 | --------- 17 | Simon Sprankel 18 | [http://simonsprankel.com](http://simonsprankel.com) 19 | [@SimonSprankel](https://twitter.com/SimonSprankel) 20 | 21 | Licence 22 | ------- 23 | [OSL - Open Software Licence 3.0](http://opensource.org/licenses/osl-3.0.php) 24 | 25 | Copyright 26 | --------- 27 | (c) 2015 Simon Sprankel 28 | -------------------------------------------------------------------------------- /apc_clear.php: -------------------------------------------------------------------------------- 1 | true)); 13 | } 14 | -------------------------------------------------------------------------------- /apc_clear_call.php: -------------------------------------------------------------------------------- 1 | /dev/null 25 | then 26 | continue 27 | else 28 | echo "${command} command not found." 29 | exit 1 30 | fi 31 | done 32 | 33 | # check if all given directories exist 34 | directories="${SCRIPT_ROOT} ${HTML_ROOT} ${MODMAN_DIR}" 35 | 36 | for directory in ${directories} 37 | do 38 | if ! test -e "${directory}" 39 | then 40 | echo "${directory} command not found." 41 | exit 1 42 | fi 43 | done 44 | 45 | # get a new, clean version from the repository 46 | echo '... cloning git repository ...' 47 | git clone ${GIT_URI} ${MODMAN_DIR}-new 48 | cd ${MODMAN_DIR}-new 49 | 50 | # checkout files from given commit 51 | echo '... checking out given commit ...' 52 | git checkout ${COMMIT_HASH} 53 | rm -rf .git 54 | cd .. 55 | 56 | # clear the cache before enabling the maintenance mode to reduce the down time 57 | echo '... clearing the cache ...' 58 | php ${N98_MAGERUN} cache:flush 59 | 60 | # enable maintenance mode 61 | echo '... enabling maintenance mode ...' 62 | > ${HTML_ROOT}/maintenance.flag 63 | 64 | # point .modman directory to the new revision 65 | rm -rf ${MODMAN_DIR} 66 | mv ${MODMAN_DIR}-new ${MODMAN_DIR} 67 | 68 | # recreate all symlinks 69 | find ${HTML_ROOT} -type l -delete 70 | ${MODMAN} deploy-all 71 | 72 | cd ${HTML_ROOT} 73 | 74 | # clear the cache 75 | echo '... clearing the cache ...' 76 | php ${N98_MAGERUN} cache:flush 77 | # clear the APC cache 78 | php ${SCRIPT_ROOT}/apc_clear_call.php --url=${HTML_URL} --htmlroot=${HTML_ROOT} --scriptroot=${SCRIPT_ROOT} 79 | 80 | # run install/upgrade scripts, so that they are executed only once 81 | if [ "$dbupdate" = true ] 82 | then 83 | echo '... running setup scripts ...' 84 | php ${N98_MAGERUN} sys:setup:run 85 | fi 86 | 87 | # disable maintenance mode 88 | echo '... disabling maintenance mode ...' 89 | rm maintenance.flag 90 | -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Change these variables according to your environment. 3 | SCRIPT_ROOT=/files 4 | HTML_ROOT=/html/shop 5 | HTML_URL=http://page.tld 6 | GIT_URI=git@host.tld:username/repository.git 7 | COMMIT_HASH=HEAD 8 | N98_MAGERUN=${SCRIPT_ROOT}/n98-magerun.phar 9 | MEDIA_ROOT=/html/media 10 | 11 | # check the --nodbupdate command line option 12 | dbupdate=true 13 | if [ "$1" = '--nodbupdate' ] 14 | then 15 | dbupdate=false 16 | fi 17 | 18 | # check if all used commands are allowed in this environment (managed servers often block various commands) 19 | commands="git rm cp ln mv php ${N98_MAGERUN}" 20 | 21 | for command in ${commands} 22 | do 23 | if type -P "${command}" &>/dev/null 24 | then 25 | continue 26 | else 27 | echo "${command} command not found." 28 | exit 1 29 | fi 30 | done 31 | 32 | # check if all given directories exist 33 | directories="${SCRIPT_ROOT} ${HTML_ROOT} ${MEDIA_ROOT}" 34 | 35 | for directory in ${directories} 36 | do 37 | if ! test -e "${directory}" 38 | then 39 | echo "${directory} command not found." 40 | exit 1 41 | fi 42 | done 43 | 44 | # get a new, clean version from the repository 45 | echo '... cloning git repository ...' 46 | git clone ${GIT_URI} ${HTML_ROOT}-new 47 | cd ${HTML_ROOT}-new 48 | 49 | # checkout files from given commit 50 | echo '... checking out given commit ...' 51 | git checkout ${COMMIT_HASH} 52 | rm -rf .git 53 | cd .. 54 | 55 | # put local.xml to new revision 56 | cp ${SCRIPT_ROOT}/local.xml ${HTML_ROOT}-new/app/etc/local.xml 57 | # symlink media directory 58 | ln -s ${MEDIA_ROOT} ${HTML_ROOT}-new/media 59 | 60 | # clear the cache before enabling the maintenance mode to reduce the down time 61 | echo '... clearing the cache ...' 62 | php ${N98_MAGERUN} cache:flush 63 | 64 | # enable maintenance mode 65 | echo '... enabling maintenance mode ...' 66 | > ${HTML_ROOT}/maintenance.flag 67 | > ${HTML_ROOT}-new/maintenance.flag 68 | 69 | # copy session files if they are stored in the file system 70 | echo '... copying session files ...' 71 | if test -e ${HTML_ROOT}/var/session/ 72 | then 73 | cp -R ${HTML_ROOT}/var/session/ ${HTML_ROOT}-new/var/session/ 74 | fi 75 | 76 | # point directory to the new revision 77 | # since removing can take too long, first move and delete later to increase performance 78 | mv ${HTML_ROOT} ${HTML_ROOT}-old 79 | mv ${HTML_ROOT}-new ${HTML_ROOT} 80 | 81 | cd ${HTML_ROOT} 82 | 83 | # clear the cache 84 | echo '... clearing the cache ...' 85 | php ${N98_MAGERUN} cache:flush 86 | # clear the APC cache 87 | php ${SCRIPT_ROOT}/apc_clear_call.php --url=${HTML_URL} --htmlroot=${HTML_ROOT} --scriptroot=${SCRIPT_ROOT} 88 | 89 | # run install/upgrade scripts, so that they are executed only once 90 | if [ "$dbupdate" = true ] 91 | then 92 | echo '... running setup scripts ...' 93 | php ${N98_MAGERUN} sys:setup:run 94 | fi 95 | 96 | # disable maintenance mode 97 | echo '... disabling maintenance mode ...' 98 | rm maintenance.flag 99 | 100 | # delete old HTML root 101 | echo '... deleting old html root ...' 102 | rm -rf ${HTML_ROOT}-old 103 | --------------------------------------------------------------------------------