diff --git a/CHANGELOG.md b/CHANGELOG.md index 009a704..1a5ed79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ Things change, people change, everything changes. +## [0.5.0](https://github.com/elfacht/craft-deploy/compare/0.4.1...0.5.0) - 2019-07-03 +### Added +- Added `ROOT_PATH` constant for absolute server paths. **REQUIRED! PLEASE UPDATE!** +- Added `RESTART_PHP` constant for optional PHP restart command, in case symlinks are cached. + ## [0.4.1](https://github.com/elfacht/craft-deploy/compare/0.4.0...0.4.1) - 2019-06-23 ### Added - Added bug warning. @@ -44,4 +49,4 @@ Things change, people change, everything changes. ## 0.1.0 - 2019-06-18 ### Added -- Initial release \ No newline at end of file +- Initial release diff --git a/README.md b/README.md index 1583d8d..19fa29f 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,12 @@ A bash script for zero-downtime Craft CMS deployment to run on production servers. Inspired by the Capistrano routine. **This script is still beta! Please use it very carefully!** ---- - -**WARNING: There might be a bug where the current Craft installation stucks in an old release until this folder will be deleted.** - ---- - ## Usage - Copy the files to your project folde on the server. - Replace `[GIT_REPO_URL]` and `[ASSETS_DIR]` in [deploy.sh](deploy.sh) with your credentials. +- Add `ROOT_PATH` for server root path to project. **REQUIRED!** +- Add optional `PHP_RESTART` command, in case symlinks are cached. - Run `chmod +x deploy.sh setup.sh` to set execution permissions. - Run `./setup.sh` to create the initial folders. - Upload `.env` into `shared/`. @@ -72,4 +68,4 @@ When you don't want to spend money on deployment services and tools like Capistr ## License -Itsa [MIT](LICENSE.md)! \ No newline at end of file +Itsa [MIT](LICENSE.md)! diff --git a/deploy.sh b/deploy.sh index c7c474f..2366d5d 100755 --- a/deploy.sh +++ b/deploy.sh @@ -23,8 +23,10 @@ # - Git repo URL # - Assets directory name (web/[ASSETS_DIR]) ####################################### -GIT_REPO="[GIT_REPO_URL]" -ASSETS_DIR="[ASSETS_DIR]" +GIT_REPO="[GIT_REPO_URL]" # required +ROOT_PATH="[ROOT/PATH/TO/PROJECT/]" # Server root path – required +ASSETS_DIR="[ASSETS_DIR]" # Assets folder – required +RESTART_PHP="" # Restart PHP if symlinks are cached – optional ####################################### # Exit if any command fails @@ -83,7 +85,7 @@ fi # Run composer install and # create symlinks ####################################### -if composer install; then +if composer install --no-interaction --prefer-dist --optimize-autoloader; then ####################################### # Create symlinks of shared files # and folders. @@ -91,11 +93,11 @@ if composer install; then printf -- "- Create symlinks .." DONE=0; while [ $DONE -eq 0 ]; do - ln -sfn "../../shared/.env" - ln -sfn "../../shared/storage" . - cd web && ln -sfn "../../../shared/web/.htaccess" - ln -sfn "../../../shared/web/$ASSETS_DIR" - ln -sfn "../../../shared/web/cpresources" + ln -sfn "$ROOT_PATH/shared/.env" + ln -sfn "$ROOT_PATH/shared/storage" . + cd web && ln -sfn "$ROOT_PATH/shared/web/.htaccess" + ln -sfn "$ROOT_PATH/shared/web/$ASSETS_DIR" + ln -sfn "$ROOT_PATH/shared/web/cpresources" if [ "$?" = "0" ]; then DONE=1; fi; printf -- '.'; @@ -147,6 +149,24 @@ if composer install; then printf -- ' DONE!\n'; fi + + ####################################### + # Restart PHP + ####################################### + if ${RESTART_PHP}; then + printf -- "- Restart PHP .." + + DONE=0; + while [ $DONE -eq 0 ]; do + ${RESTART_PHP} + + if [ "$?" = "0" ]; then DONE=1; fi; + printf -- '.'; + sleep 1; + done + + printf -- ' DONE!\n'; + fi else #######################################