├── .github └── CODEOWNERS ├── LICENSE ├── README.md ├── adminer ├── README.md ├── adminer ├── adminer.filelist ├── adminer.post-install ├── adminer.pre-install ├── adminer.pre-uninstall └── conf │ ├── adminer.yml │ └── designs.php ├── andock ├── README.md ├── andock ├── andock.filelist ├── andock.post-install ├── andock.pre-install ├── andock.pre-uninstall └── conf │ └── andock.yml ├── artisan └── artisan ├── blt ├── README.md └── blt ├── codeclimate ├── README.md └── codeclimate ├── dbeaver ├── README.md └── dbeaver ├── example ├── README.md ├── example ├── example.filelist ├── example.post-install ├── example.post-uninstall ├── example.pre-install ├── example.pre-uninstall └── some-additional-files │ └── somefile ├── mailpit ├── README.md ├── conf │ └── mailpit.yml ├── mailpit ├── mailpit.filelist ├── mailpit.post-install ├── mailpit.pre-install └── mailpit.pre-uninstall ├── meilisearch ├── conf │ └── meiliesearch.yml ├── meilisearch ├── meilisearch.filelist ├── meilisearch.post-install ├── meilisearch.pre-install └── meilisearch.pre-uninstall ├── mkcert ├── README.md ├── mkcert ├── mkcert.filelist └── mkcert.pre-install ├── phpcs ├── README.md └── phpcs ├── phpunit ├── README.md └── phpunit ├── pma ├── README.md ├── conf │ └── pma.yml ├── pma ├── pma.filelist ├── pma.post-install ├── pma.pre-install └── pma.pre-uninstall ├── pull ├── README.md └── pull ├── rabbitmq ├── README.md ├── conf │ └── rabbitmq.yml ├── rabbitmq ├── rabbitmq.filelist ├── rabbitmq.post-install ├── rabbitmq.pre-install └── rabbitmq.pre-uninstall ├── redis ├── README.md ├── conf │ └── redis.yml ├── redis ├── redis.filelist ├── redis.post-install ├── redis.pre-install └── redis.pre-uninstall ├── sequelace ├── README.md └── sequelace ├── sequelpro ├── README.md └── sequelpro ├── simpletest ├── README.md └── simpletest ├── sitediff ├── README.md ├── conf │ └── sitediff.yml ├── sitediff ├── sitediff.post-install ├── sitediff.pre-install └── sitediff.pre-uninstall ├── socketi ├── README.md ├── conf │ └── socketi.yml ├── socketi ├── socketi.filelist ├── socketi.post-install ├── socketi.pre-install └── socketi.pre-uninstall ├── solr ├── README.md ├── conf │ └── solr.yml ├── solr ├── solr.filelist ├── solr.post-install ├── solr.pre-install └── solr.pre-uninstall ├── tableplus ├── README.md └── tableplus ├── uli ├── README.md └── uli ├── wkhtmltopdf └── wkhtmltopdf └── xdebug └── xdebug /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Learn how to add code owners here: 2 | # https://help.github.com/en/articles/about-code-owners 3 | 4 | * @addons-owners 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Docksal 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docksal addons 2 | 3 | Required fin version is 1.7.0 or higher. 4 | 5 | Addons is a **community driven** project. If you have an addon idea, we will gladly welcome the new addon. 6 | 7 | DISCLAMER: since it is a community driven project it is only smoke-tested and code is only reviewed for vulnerabilities. Addons may not always be up to date with the latest Docksal practices or might have bugs. Feel free to raise issues or pull requests to fix those bugs. 8 | 9 | # Addons list 10 | 11 | | Name | Description | Requirements | 12 | |----------------------------|---------------|-----------------| 13 | | **[example](example)** | A working documentation on what is Docksal addon and how it works | | 14 | | [adminer](adminer) | [Adminer](https://www.adminer.org/) database management tool | MySQL | 15 | | [andock](andock) | [Andock](https://andock.readthedocs.io/en/latest/) makes it dead simple to get Docksal environments up on your server. | Docksal | 16 | | [artisan](artisan) | Runs [Laravel's Artisan](https://laravel.com/docs/artisan) command in `cli`. **Requires** artisan pre-installed inside `cli`. | Laravel, Artisan | 17 | | [blt](blt) | Acquia BLT tool launcher (requires [BLT installation](https://blog.docksal.io/docksal-and-acquia-blt-1552540a3b9f)) | Drupal | 18 | | [codeclimate](codeclimate) | [CodeClimate](https://codeclimate.com/) code quality tool | | 19 | | [dbeaver](dbeaver) | Launches [DBeaver](https://dbeaver.io/) with the connection information for current project. | macOS, Linux | 20 | | [mailpit](mailpit) | [Mailpit](https://github.com/axllent/mailpit) email capture service for current project | | 21 | | [meilisearch](meilisearch) | [Meilisearch](https://www.meilisearch.com/) search for local development | | 22 | | [mkcert](mkcert) | [mkcert](https://github.com/FiloSottile/mkcert) addon for Docksal | | 23 | | [phpcs](phpcs) | PHP Code Sniffer and Code Beautifier | | 24 | | [phpunit](phpunit) | Creates a phpunit.xml file and runs PHPUnit tests | Drupal | 25 | | [pma](pma) | [PhpMyAdmin](https://www.phpmyadmin.net/) database management tool | MySQL | 26 | | [pull](pull) | Pull assets from hosting environment to local | Drupal | 27 | | [rabbitmq](rabbitmq) | [RabbitMQ](https://www.rabbitmq.com/) Message Broker | RabbitMQ | 28 | | [redis](redis) | Add [Redis](https://redis.io/) to current project | | 29 | | [sequelace](sequelace) | Launches [SequelAce](https://github.com/Sequel-Ace/Sequel-Ace) with the connection information for current project. | macOS | 30 | | [sequelpro](sequelpro) | Launches [SequelPro](https://www.sequelpro.com) with the connection information for current project. | macOS | 31 | | [simpletest](simpletest) | Runs SimpleTest tests in Drupal 7 and 8 | Drupal | 32 | | [sitediff](sitediff) | Runs Sitediff tests in your Docksal project | | 33 | | [soketi](soketi) | [Socketi](https://docs.soketi.app/) Soketi is your simple, fast, and resilient open-source WebSockets server | | 34 | | [solr](solr) | [Apache Solr](http://lucene.apache.org/solr/) search service for current project | | 35 | | [tableplus](tableplus) | Launches [TablePlus](https://www.tableplus.com) with the connection information for current project. | macOS | 36 | | [uli](uli) | Generate one time login url for current site | Drupal | 37 | | [wkhtmltopdf](wkhtmltopdf) | Installs wkhtmltopdf 0.12.5 with QT compiled in. | | 38 | | [xdebug](xdebug) | Turns [xdebug](https://docs.docksal.io/tools/xdebug/) on or off and restarts docksal | | 39 | -------------------------------------------------------------------------------- /adminer/README.md: -------------------------------------------------------------------------------- 1 | # Adminer - Docksal addon 2 | 3 | Easily install [Adminer](https://www.adminer.org/) for your Docksal project. Make it easy to access the database and examine directly rather then through the CLI. 4 | 5 | Adminer (formerly phpMinAdmin) is a full-featured database management tool written in PHP. It consist of a single file that is required to deploy to the target server. Also see: [Introduction to Adminer video](https://www.youtube.com/watch?v=KutqUc1vJUY) 6 | 7 | ```bash 8 | fin addon install adminer 9 | ``` 10 | 11 | ## URL 12 | 13 | After the installation using the default `*.docksal` domain name, Adminer will be available at `http://adminer-.docksal`. 14 | 15 | ## Command line reference 16 | 17 | - `fin adminer disable` to disable 18 | - `fin adminer enable` to re-enable 19 | 20 | ## Customization 21 | 22 | You can customize your adminer installation with the following environmental variables. 23 | 24 | * `ADMINER_DEFAULT_SERVER=db` 25 | * **db** is the default database container or hostname to connect to. 26 | * `ADMINER_PLUGINS=tables-filter tinymce` 27 | * To load [Adminer plugins](https://github.com/vrana/adminer/tree/master/plugins) you can pass a list of filenames. 28 | * `ADMINER_DESIGN=price` 29 | * To use a bundled [Adminer design](https://github.com/vrana/adminer/tree/master/designs) you can pass its name. 30 | 31 | ## Regressions 32 | Previously the url for Adminer could be found at `http://adminer..docksal`. This change was made to make it easier to use a LetsEncrypt wildcard certificate, as it is only valid for one level of subdomains. 33 | -------------------------------------------------------------------------------- /adminer/adminer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Enable/disable adminer for current project 4 | ## 5 | ## Sub-commands: 6 | ## enable Enable adminer 7 | ## disable Disable adminer 8 | 9 | # Console colors 10 | red='\033[0;91m' 11 | red_bg='\033[101m' 12 | yellow_bg='\033[43;90m' 13 | green='\033[0;32m' 14 | green_bg='\033[42m' 15 | yellow='\033[0;33m' 16 | yellow_bold='\033[1;33m' 17 | NC='\033[0m' 18 | 19 | echo-red () { echo -e "${red}$1${NC}"; } 20 | echo-green () { echo -e "${green}$1${NC}"; } 21 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 22 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 23 | die () { echo -e "$1"; exit 1; } 24 | 25 | DOCKSAL_YML=".docksal/docksal.yml" 26 | DOCKSAL_YML_NEW=".docksal/docksal.yml.new" 27 | DOCKSAL_ENV=".docksal/docksal.env" 28 | DOCKSAL_STACKS="$HOME/.docksal/stacks" 29 | ADMINER_YML="$ADDON_ROOT/conf/adminer.yml" 30 | 31 | #----------------------------------- YML & config functions ------------------------------------------ 32 | 33 | # Check whether given string is in config 34 | # $1 - string to find 35 | in_config () 36 | { 37 | fin config 2>/dev/null | grep "$1" >/dev/null 38 | } 39 | 40 | # Check that docksal.yml is valid 41 | yml_is_valid () 42 | { 43 | [[ -f "$DOCKSAL_YML" ]] && $(cat "$DOCKSAL_YML" 2>/dev/null | grep "services" >/dev/null) 44 | } 45 | 46 | # Prepares stack to editing docksal.yml config 47 | yml_prepare () 48 | { 49 | # Get yml version to use for a new file from existing stacks 50 | YML_VERSION=$(head "$DOCKSAL_STACKS/volumes-bind.yml" | grep "version") 51 | YML_DEFAULT_BODY="${YML_VERSION}\nservices:" 52 | NEW_STACK='DOCKSAL_STACK="default"' 53 | 54 | # Source docksal.env 55 | source "$DOCKSAL_ENV" >/dev/null 2>&1 56 | 57 | # If DOCKSAL_STACK is not set, then... 58 | if [[ -z "$DOCKSAL_STACK" ]]; then 59 | echo " Configuring to use DOCKSAL_STACK=\"default\"..." 60 | # ...set stack to default so we could use docksal.yml 61 | echo -e "$NEW_STACK" >> "$DOCKSAL_ENV" 62 | fi 63 | 64 | # Create docksal.yml if needed 65 | yml_is_valid || echo -e "$YML_DEFAULT_BODY" >> "$DOCKSAL_YML" 66 | } 67 | 68 | # Install tool required to edit yml from command line 69 | yml_install_tools () 70 | { 71 | fin exec "which yaml >/dev/null 2>&1 || npm install --silent -g yaml-cli >/dev/null" 72 | } 73 | 74 | # Add a service to docksal.yml from another yml 75 | # $1 - filename of yml get service from 76 | yml_add_service () 77 | { 78 | [[ -z "$1" ]] && echo "File not found: $1" && return 1 79 | # TODO: use https://www.npmjs.com/package/merge-yaml 80 | cat "$1" >> "$DOCKSAL_YML" 81 | } 82 | 83 | # Removes a service from docksal.yml 84 | # $1 - service name 85 | yml_remove_service () 86 | { 87 | [[ -z "$1" ]] && echo "Provide a service name to remove" && return 1 88 | local service="$1" 89 | read -r -d '' CODE_TO_EXEC <<-EOF 90 | yaml set $DOCKSAL_YML services.$service | grep -v '$service:' | tee $DOCKSAL_YML_NEW >/dev/null; 91 | [[ -z "\$(yaml get $DOCKSAL_YML_NEW services)" ]] && rm '$DOCKSAL_YML' || mv $DOCKSAL_YML_NEW $DOCKSAL_YML 92 | EOF 93 | # Remove service. If no services left after that, then remove docksal.yml 94 | fin exec "$CODE_TO_EXEC" 95 | } 96 | 97 | #-------------------------------------- adminer functions --------------------------------------------- 98 | 99 | # Set/remove proper setting into php.ini 100 | # $1 - enable/disable 101 | # Enable container and settings 102 | adminer_enable () 103 | { 104 | # Check that adminer is not already enabled 105 | if (in_config "image: adminer"); then 106 | echo " Adminer support is already enabled." && exit 107 | fi 108 | 109 | echo " Enabling adminer..." 110 | yml_prepare 111 | # Add adminer service to docksal.yml 112 | yml_add_service "$ADMINER_YML" 113 | # Apply stack changes. 114 | fin stop cli 115 | fin up 116 | } 117 | 118 | # Disable container and settings 119 | adminer_disable () 120 | { 121 | echo " Running checks..." 122 | # Make sure cli container is running 123 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 124 | echo " ERROR: Start the project with fin start first" && exit 1 125 | fi 126 | 127 | # Make sure adminer is installed 128 | if ! in_config "image: adminer"; then 129 | echo " Adminer support is not enabled at the moment." && exit 130 | fi 131 | 132 | echo " Preparing to remove adminer service..." 133 | yml_install_tools 134 | # Remove adminer service from docksal.yml 135 | yml_remove_service "adminer" 136 | # Apply stack changes 137 | COMPOSE_FILE="" fin stop cli 138 | fin up 139 | } 140 | 141 | #------------------------------------------ Runtime ----------------------------------------------- 142 | 143 | cd "$PROJECT_ROOT" 144 | 145 | case "$1" in 146 | enable) 147 | adminer_enable 148 | ;; 149 | disable) 150 | adminer_disable 151 | ;; 152 | *) 153 | echo "Usage: fin adminer " 154 | exit 1 155 | ;; 156 | esac 157 | -------------------------------------------------------------------------------- /adminer/adminer.filelist: -------------------------------------------------------------------------------- 1 | # Hooks 2 | adminer.pre-install 3 | adminer.post-install 4 | adminer.pre-uninstall 5 | 6 | # Container config 7 | conf/adminer.yml 8 | 9 | # Adminer designs plugin config 10 | conf/designs.php 11 | -------------------------------------------------------------------------------- /adminer/adminer.post-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Console colors 4 | red='\033[0;91m' 5 | red_bg='\033[101m' 6 | yellow_bg='\033[43;90m' 7 | green='\033[0;32m' 8 | green_bg='\033[42m' 9 | yellow='\033[0;33m' 10 | yellow_bold='\033[1;33m' 11 | NC='\033[0m' 12 | 13 | 14 | echo-red () { echo -e "${red}$1${NC}"; } 15 | echo-green () { echo -e "${green}$1${NC}"; } 16 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 17 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 18 | fin adminer enable 19 | 20 | echo-green "Adminer UI:${yellow} http://adminer-$VIRTUAL_HOST${NC}" 21 | -------------------------------------------------------------------------------- /adminer/adminer.pre-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Check Docksal running 4 | if [[ "$DOCKER_RUNNING" != "true" ]]; then 5 | echo "[PRE-INSTALL] ERROR: Docksal and project should be running" 6 | exit 1 7 | fi 8 | 9 | # Check Docksal running 10 | if [[ "$ADDON_GLOBAL" == "true" ]]; then 11 | echo -e "[PRE-INSTALL] ERROR: Adminer addon should not be installed globally" 12 | exit 1 13 | fi 14 | 15 | 16 | # Check project running 17 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 18 | echo "[PRE-INSTALL] ERROR: Start the project with fin start first" 19 | exit 1 20 | fi 21 | 22 | # Get fin config 23 | fin_config=$(fin config) 24 | if [[ $? != 0 ]]; then 25 | echo "[PRE-INSTALL] ERROR: 'fin config' command was not successful. Check your fin config" 26 | exit 1 27 | fi 28 | 29 | # Check there is no adminer already 30 | if (echo "$fin_config" | grep "image: adminer"); then 31 | echo "[PRE-INSTALL] ERROR: Adminer seems to be already enabled for this project" 32 | exit 1 33 | fi 34 | 35 | # Check there is no adminer already 36 | if (echo "$fin_config" | grep " adminer:"); then 37 | echo "[PRE-INSTALL] ERROR: Container named 'adminer' already exists. Remove it to continue." 38 | exit 1 39 | fi 40 | 41 | # All good 42 | exit 0 43 | -------------------------------------------------------------------------------- /adminer/adminer.pre-uninstall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin adminer disable 4 | -------------------------------------------------------------------------------- /adminer/conf/adminer.yml: -------------------------------------------------------------------------------- 1 | # Adminer 2 | adminer: 3 | hostname: adminer 4 | image: adminer 5 | environment: 6 | - ADMINER_DEFAULT_SERVER=db # db is the default database container 7 | - ADMINER_PLUGINS=tables-filter tinymce # To load Adminer plugins 8 | - ADMINER_DESIGN=price # To use a bundled Adminer design 9 | labels: 10 | - io.docksal.virtual-host=adminer-${VIRTUAL_HOST} 11 | -------------------------------------------------------------------------------- /adminer/conf/designs.php: -------------------------------------------------------------------------------- 1 | /dev/null | grep "$1" >/dev/null 34 | } 35 | 36 | # Check that docksal.yml is valid 37 | yml_is_valid () 38 | { 39 | [[ -f "$DOCKSAL_LOCAL_YML" ]] && $(cat "$DOCKSAL_LOCAL_YML" 2>/dev/null | grep "services" >/dev/null) 40 | } 41 | 42 | # Prepares stack to editing docksal.yml config 43 | yml_prepare () 44 | { 45 | # Get yml version to use for a new file from existing stacks 46 | YML_VERSION=$(head "$DOCKSAL_STACKS/volumes-bind.yml" | grep "version") 47 | YML_DEFAULT_BODY="${YML_VERSION}\nservices:" 48 | NEW_STACK='DOCKSAL_STACK="default"' 49 | 50 | # Source docksal.env 51 | source "$DOCKSAL_ENV" >/dev/null 2>&1 52 | 53 | # If DOCKSAL_STACK is not set, then... 54 | if [[ -z "$DOCKSAL_STACK" ]]; then 55 | echo " Configuring to use DOCKSAL_STACK=\"default\"..." 56 | # ...set stack to default so we could use docksal.yml 57 | echo -e "$NEW_STACK" >> "$DOCKSAL_ENV" 58 | fi 59 | 60 | # Create docksal.yml if needed 61 | yml_is_valid || echo -e "$YML_DEFAULT_BODY" >> "$DOCKSAL_LOCAL_YML" 62 | } 63 | 64 | # Install tool required to edit yml from command line 65 | yml_install_tools () 66 | { 67 | fin exec "which yaml >/dev/null 2>&1 || npm install --silent -g yaml-cli >/dev/null" 68 | } 69 | 70 | # Add a service to docksal.yml from another yml 71 | # $1 - filename of yml get service from 72 | yml_add_service () 73 | { 74 | [[ -z "$1" ]] && echo "File not found: $1" && return 1 75 | # TODO: use https://www.npmjs.com/package/merge-yaml 76 | cat "$1" >> "$DOCKSAL_LOCAL_YML" 77 | } 78 | 79 | # Removes a service from docksal.yml 80 | # $1 - service name 81 | yml_remove_service () 82 | { 83 | [[ -z "$1" ]] && echo "Provide a service name to remove" && return 1 84 | local service="$1" 85 | read -r -d '' CODE_TO_EXEC <<-EOF 86 | yaml set $DOCKSAL_LOCAL_YML services.$service | grep -v '$service:' | tee $DOCKSAL_LOCAL_YML_NEW >/dev/null; 87 | [[ -z "\$(yaml get $DOCKSAL_LOCAL_YML_NEW services)" ]] && rm '$DOCKSAL_LOCAL_YML' || mv $DOCKSAL_LOCAL_YML_NEW $DOCKSAL_LOCAL_YML 88 | EOF 89 | # Remove service. If no services left after that, then remove docksal.yml 90 | fin exec "$CODE_TO_EXEC" 91 | } 92 | 93 | #-------------------------------------- andock functions --------------------------------------------- 94 | 95 | # Enable container and settings 96 | andock_enable () 97 | { 98 | # Check that andock is not already enabled 99 | if (in_config "image: andockio\/andock"); then 100 | echo " andock is already enabled." && exit 101 | fi 102 | 103 | echo " Enabling andock ..." 104 | yml_prepare 105 | # Add andock service to docksal.yml 106 | yml_add_service "$andock_YML" 107 | # Apply stack changes. 108 | fin up 109 | echo " andock is enabled successfully." 110 | echo " Run fin andock to see a list of commands." 111 | } 112 | 113 | # Disable container and settings 114 | andock_disable () 115 | { 116 | echo " Running checks..." 117 | # Make sure cli container is running 118 | if ! (fin ps | grep "_andock_" | grep "Up" >/dev/null); then 119 | echo " ERROR: Start the project with fin start first" && exit 1 120 | fi 121 | 122 | # Make sure andock is installed 123 | if ! in_config "image: andockio\/andock"; then 124 | echo " andock is not enabled at the moment." && exit 125 | fi 126 | 127 | echo " Preparing to remove andock service..." 128 | yml_install_tools 129 | # Remove andock service from docksal.yml 130 | yml_remove_service "andock" 131 | # Apply stack changes 132 | fin up 133 | } 134 | 135 | #------------------------------------------ Runtime ----------------------------------------------- 136 | 137 | cd "$PROJECT_ROOT" 138 | 139 | case "$1" in 140 | enable) 141 | andock_enable 142 | ;; 143 | disable) 144 | andock_disable 145 | ;; 146 | *) 147 | 148 | # Make sure andock is installed. 149 | if ! in_config "image: andockio\/andock"; then 150 | echo "Usage: fin andock " && exit 1 151 | fi 152 | 153 | # Make sure andock is up. 154 | if ! (fin ps | grep "_andock_" | grep "Up" >/dev/null); then 155 | echo " ERROR: Start the project with fin start first" && exit 1 156 | fi 157 | 158 | # Set ANDOCK_PROJECT_NAME to the basename. 159 | # This can not be done inside the docker image. 160 | # @see config generate. 161 | ANDOCK_PROJECT_NAME=$(basename "$PWD") 162 | cmd="andock" 163 | 164 | # Prepare the subcommand. 165 | if [[ $2 != "" ]]; then 166 | cmd="$cmd "$(printf " %q" "$@") 167 | else 168 | cmd="$cmd $*" 169 | fi 170 | 171 | # Execute the command as docker user. 172 | fin exec --in=andock gosu docker /bin/bash -c "export ANDOCK_INSIDE_DOCKSAL=true; export ANDOCK_PROJECT_NAME=${ANDOCK_PROJECT_NAME}; $cmd" 173 | ;; 174 | esac 175 | -------------------------------------------------------------------------------- /andock/andock.filelist: -------------------------------------------------------------------------------- 1 | # Hooks 2 | andock.pre-install 3 | andock.post-install 4 | andock.pre-uninstall 5 | 6 | # Container config 7 | conf/andock.yml 8 | -------------------------------------------------------------------------------- /andock/andock.post-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin andock enable 4 | -------------------------------------------------------------------------------- /andock/andock.pre-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Check Docksal running 4 | if [[ "$DOCKER_RUNNING" != "true" ]]; then 5 | echo "[PRE-INSTALL] ERROR: Docksal and project should be running" 6 | exit 1 7 | fi 8 | 9 | # Check Docksal running 10 | if [[ "$ADDON_GLOBAL" == "true" ]]; then 11 | echo -e "[PRE-INSTALL] ERROR: andock addon should not be installed globally" 12 | exit 1 13 | fi 14 | 15 | 16 | # Check project running 17 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 18 | echo "[PRE-INSTALL] ERROR: Start the project with fin start first" 19 | exit 1 20 | fi 21 | 22 | # Get fin config 23 | fin_config=$(fin config) 24 | if [[ $? != 0 ]]; then 25 | echo "[PRE-INSTALL] ERROR: 'fin config' command was not successful. Check your fin config" 26 | exit 1 27 | fi 28 | 29 | # Check there is no andock already 30 | if (echo "$fin_config" | grep "image: docksal\/andock"); then 31 | echo "[PRE-INSTALL] ERROR: Andock seems to be already enabled for this project" 32 | exit 1 33 | fi 34 | 35 | # Check there is no andock already 36 | if (echo "$fin_config" | grep " andock:"); then 37 | echo "[PRE-INSTALL] ERROR: Container named 'andock' already exists. Remove it to continue." 38 | exit 1 39 | fi 40 | 41 | 42 | # All good 43 | exit 0 44 | -------------------------------------------------------------------------------- /andock/andock.pre-uninstall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin andock disable 4 | -------------------------------------------------------------------------------- /andock/conf/andock.yml: -------------------------------------------------------------------------------- 1 | 2 | # andock 3 | andock: 4 | hostname: andock 5 | image: ${ANDOCK_IMAGE:-andockio/andock:1.0} 6 | volumes: 7 | - project_root:/var/www:rw,nocopy # Project root volume 8 | - docksal_ssh_agent:/.ssh-agent:ro 9 | environment: 10 | - GIT_USER_EMAIL 11 | - GIT_USER_NAME 12 | - HOST_UID 13 | - HOST_GID 14 | -------------------------------------------------------------------------------- /artisan/artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Run Laravel Artisan Commands 4 | ## 5 | ## Artisan is the command-line interface included with Laravel. 6 | ## It provides a number of helpful commands that can assist you while you build your application. 7 | ## To view a list of all available Artisan commands, you may use the list command: 8 | ## fin artisan list 9 | ## 10 | ## Usage: 11 | ## artisan [args] Run artisan see https://laravel.com/docs/master/artisan 12 | 13 | # run the command in the container. 14 | cd "$(dirname "$PROJECT_ROOT/$DOCROOT")" 15 | fin exec php artisan "$@" 16 | -------------------------------------------------------------------------------- /blt/README.md: -------------------------------------------------------------------------------- 1 | # BLT alias for fin 2 | 3 | [Acquia BLT](http://blt.readthedocs.io) (Build and Launch Tool) is an automation 4 | layer for building, testing, and deploying Drupal 8 applications. 5 | Execute blt commands within the container with `fin blt [command]`. 6 | 7 | This command requires that BLT is installed. Please [read the blog post](https://blog.docksal.io/docksal-and-acquia-blt-1552540a3b9f) on how to set up BLT in a Docksal environment. Also [read the BLT docs](http://blt.readthedocs.io) on how use BLT. 8 | -------------------------------------------------------------------------------- /blt/blt: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Run a BLT command inside the cli container. 4 | ## 5 | ## Usage: fin blt [command] 6 | 7 | fin exec /var/www/vendor/bin/blt "$@" 8 | -------------------------------------------------------------------------------- /codeclimate/README.md: -------------------------------------------------------------------------------- 1 | # CodeClimate CLI 2 | 3 | CodeClimate code quality SaaS (https://codeclimate.com) has it's own CLI tool that does code linting, and it's open source https://github.com/codeclimate/codeclimate. 4 | 5 | The CLI tool uses exactly the same format as the SaaS solution, so it makes it possible to use the CodeClimate SaaS and also lint code locally. 6 | 7 | CodeClimate CLI uses docker containers as linter engines, which makes it easy to use with Docksal. 8 | 9 | The addon will invoke a codeclimate command reusing host docker socket. The codeclimate CLI itself will run other docker containers using same docker socket and collect data into a report. 10 | 11 | The addon should make it possible for teams to easily add codeclimate command into their docksal commands stack. 12 | 13 | ## Installing CodeClimate addon 14 | 15 | ```bash 16 | fin addon install codeclimate 17 | ``` 18 | 19 | ## Usage 20 | 21 | - `fin codeclimate` for a list of commands 22 | - `fin codeclimate --no-check-version analyze -f html > codeclimate.html` to export HTML report into local directory 23 | 24 | ## More documentation 25 | 26 | Find more documentation on official codeclimate repo: 27 | https://github.com/codeclimate/codeclimate 28 | -------------------------------------------------------------------------------- /codeclimate/codeclimate: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Run CodeClimate against the project code 4 | ## 5 | ## Usage: 6 | ## fin codeclimate - list of commands 7 | ## fin codeclimate --no-check-version analyze -f html > codeclimate.html - export HTML report into local directory 8 | 9 | # Determine if tty is supported. 10 | if [[ "$(/usr/bin/tty || true)" != "not a tty" ]] 11 | then 12 | TTY_OPT='--tty' 13 | else 14 | TTY_OPT='' 15 | fi 16 | 17 | docker run \ 18 | --interactive $TTY_OPT --rm \ 19 | --env CODECLIMATE_CODE="$PROJECT_ROOT" \ 20 | --volume "$PROJECT_ROOT":/code \ 21 | --volume /var/run/docker.sock:/var/run/docker.sock \ 22 | --volume /tmp/cc:/tmp/cc \ 23 | codeclimate/codeclimate $@ 24 | -------------------------------------------------------------------------------- /dbeaver/README.md: -------------------------------------------------------------------------------- 1 | # DBeaver - Docksal addon 2 | 3 | This Docksal addon launches [DBeaver][1] with the connection information from the current project. 4 | DBeaver is a multi-platform database tool that supports popular database engines like MySQL, PostgreSQL, and more. 5 | 6 | This addon tries to detect the database engine and launches DBeaver with the correct connection settings. 7 | Currently, only the following database engines can be detected: 8 | 9 | * MySQL 10 | * PostgreSQL 11 | 12 | ## Installation 13 | The addon can be installed using the following command: 14 | 15 | ```bash 16 | fin addon install dbeaver 17 | ``` 18 | 19 | ## Usage 20 | Run `fin dbeaver` to launch DBeaver with the connection information from the current project. 21 | 22 | ```bash 23 | fin dbeaver 24 | ``` 25 | 26 | If the database service name is not `db` or the project has multiple database services, 27 | a service name can be provided as the first parameter. 28 | 29 | ```bash 30 | fin dbeaver database_container 31 | ``` 32 | 33 | Note: on macOS AppleScript is used to determine the installation location of DBeaver. 34 | When running this script for the first time, a pop-up might ask if it's allowed to execute the AppleScript. 35 | 36 | [1]: https://dbeaver.io 37 | 38 | -------------------------------------------------------------------------------- /dbeaver/dbeaver: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Opens DBeaver 4 | ## 5 | ## Usage: fin dbeaver [container (default: db)] 6 | 7 | # Abort if anything fails 8 | set -e 9 | 10 | info() { 11 | echo -e "\033[0;32m${1}\033[0m" 12 | } 13 | 14 | error() { 15 | echo -e "\033[1;31m${1}\033[0m" 16 | } 17 | 18 | function getContainerId() { 19 | CONTAINER_ID=$(docker ps --all --filter "label=com.docker.compose.service=${DB_SERVICE}" --filter "label=com.docker.compose.project=${COMPOSE_PROJECT_NAME_SAFE}" --format '{{.ID}}') 20 | if [ -z "${CONTAINER_ID}" ]; then 21 | error "Error: Unable to detect database container with name \"${DB_SERVICE}\"." 22 | exit 1 23 | fi 24 | } 25 | 26 | function detectContainerPort() { 27 | CONTAINER_PORT=$(docker ps --filter "id=${CONTAINER_ID}" --format "{{.Ports}}" | sed 's/.*0.0.0.0://g' | sed 's/->.*//g') 28 | } 29 | 30 | function detectDatabaseType() { 31 | local ENV_SETTINGS 32 | ENV_SETTINGS=$(docker inspect -f '{{range $index, $value := .Config.Env}}{{println $value}}{{end}}' "${CONTAINER_ID}") 33 | 34 | local ENV_SPLIT 35 | # shellcheck disable=SC2206 36 | IFS=$'\n' ENV_SPLIT=($ENV_SETTINGS) 37 | 38 | local KEY 39 | for VALUE in "${ENV_SPLIT[@]}" 40 | do 41 | KEY=$(echo "${VALUE}" | cut -d '=' -f1) 42 | 43 | if [[ "${KEY}" = "MYSQL_DATABASE" ]]; then 44 | DB_TYPE=mysql 45 | DB_DATABASE=$(echo "${ENV_SETTINGS}" | awk -F'=' '/^MYSQL_DATABASE/ {print $2}') 46 | DB_USER=$(echo "${ENV_SETTINGS}" | awk -F'=' '/^MYSQL_USER/ {print $2}') 47 | DB_PASSWORD=$(echo "${ENV_SETTINGS}" | awk -F'=' '/^MYSQL_PASSWORD/ {print $2}') 48 | return 49 | fi 50 | 51 | if [[ "${KEY}" = "POSTGRES_DB" ]]; then 52 | DB_TYPE=postgresql 53 | DB_DATABASE=$(echo "${ENV_SETTINGS}" | awk -F'=' '/^POSTGRES_DB/ {print $2}') 54 | DB_USER=$(echo "${ENV_SETTINGS}" | awk -F'=' '/^POSTGRES_USER/ {print $2}') 55 | DB_PASSWORD=$(echo "${ENV_SETTINGS}" | awk -F'=' '/^POSTGRES_PASSWORD/ {print $2}') 56 | return 57 | fi 58 | done 59 | } 60 | 61 | function startDBeaver() { 62 | local OS 63 | OS=$(uname | tr '[:upper:]' '[:lower:]') 64 | case $OS in 65 | linux*) 66 | startLinux 67 | ;; 68 | darwin*) 69 | startDarwin 70 | ;; 71 | *) 72 | echo "Unknown system: ${OS} is currently not supported!" 73 | exit 1 74 | ;; 75 | esac 76 | } 77 | 78 | function startLinux() { 79 | command -v dbeaver >/dev/null || { error "dbeaver command not found."; exit 1; } 80 | dbeaver -con "${CONNECTION}" > /dev/null 2>&1 & 81 | } 82 | 83 | function startDarwin() { 84 | open -a DBeaver --args -con "${CONNECTION}" 85 | } 86 | 87 | DB_SERVICE=${1:-db} 88 | getContainerId 89 | detectContainerPort 90 | detectDatabaseType 91 | 92 | if [[ -z "${DB_TYPE}" ]]; then 93 | error "Error: Unable to detect database engine used inside the db container." 94 | exit 1 95 | fi 96 | 97 | if [[ -z "${CONTAINER_PORT}" ]]; then 98 | error "Error: Unable to detect database mapped port." 99 | exit 1 100 | fi 101 | 102 | CONNECTION="driver=${DB_TYPE}|host=localhost|database=${DB_DATABASE:-default}|name=${COMPOSE_PROJECT_NAME}|port=${CONTAINER_PORT}|user=${DB_USER:-user}|password=${DB_PASSWORD:-user}|openConsole=true|connect=true|create=false" 103 | 104 | startDBeaver 105 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # Example Docksal addon 2 | 3 | This is an example of an installable Docksal addon. It's purpose is to show a sample folder structure and concepts of creating installable addons. 4 | 5 | ## Name 6 | 7 | Addon name is the name of the folder containing it. In this case addon name is `example`. 8 | 9 | ## Required files 10 | 11 | Each addon should have a main script that is named as the addon. In this case the main script name is `example`. It should be located in the addon root directory. 12 | 13 | ## Optional files 14 | 15 | If there is a need to include more files, then these files should be described in `addon.filelist` one file per line. 16 | 17 | See contents of `example.filelist` for details. 18 | 19 | ### Hooks 20 | 21 | Hooks are special additional files that executed automatically upon certain events. Hook files should be named as `addon`.`hook` and described in `addon.filelist`. 22 | 23 | Supported hooks: 24 | 25 | - `pre-install` executed before installation, can cancel installation if returns non-zero exit code 26 | - `post-install` executed after installation 27 | - `pre-uninstall` executed before uninstallation, can cancel uninstallation if returns non-zero exit code 28 | - `post-uninstall` executed after uninstallation 29 | 30 | Examples of all these hooks can be found here. 31 | -------------------------------------------------------------------------------- /example/example: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERSION="1.0" 4 | 5 | ## Example addon 6 | ## 7 | ## This is an example addon. It's purpose is to show sample folder structure 8 | ## and concepts of creating addons. 9 | ## 10 | ## fin example 11 | ## 12 | ## Usage: 13 | ## hello Display contents of 'somefile' 14 | ## version Display addon version 15 | 16 | 17 | case "$1" in 18 | hello) 19 | cat "$ADDON_ROOT/some-additional-files/somefile" 20 | ;; 21 | version|-v) 22 | echo "$VERSION" 23 | ;; 24 | *) 25 | fin help example 26 | ;; 27 | esac 28 | -------------------------------------------------------------------------------- /example/example.filelist: -------------------------------------------------------------------------------- 1 | # If you want to include more than a single script file 2 | # You do it by creating addon.filelist file 3 | # where all additional files should be described. 4 | # One line per file, paths relative to current folder. 5 | 6 | # Here is additional files 7 | some-additional-files/somefile 8 | 9 | # If you want to use hooks they should also be included here 10 | # or they won't get downloaded and executed 11 | example.pre-install 12 | example.post-install 13 | example.pre-uninstall 14 | example.post-uninstall 15 | -------------------------------------------------------------------------------- /example/example.post-install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo " This is an example post-install script output." 4 | echo " Use post-install hook to perform additional tasks after addon installation," 5 | echo " that can not be performed before addon installation." 6 | sleep 1 7 | -------------------------------------------------------------------------------- /example/example.post-uninstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo " This is an example post-uninstall script output." 4 | echo " Use post-uninstall to perform a cleanup if needed." 5 | echo " Addon code is gone by this moment." 6 | sleep 2 7 | -------------------------------------------------------------------------------- /example/example.pre-install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo " This is an example pre-install script output..." 4 | echo " Use pre-install shook to check for dependencies or pre-requisites..." 5 | echo " If exit code is non-zero, then addon installation will not continue." 6 | sleep 2 7 | -------------------------------------------------------------------------------- /example/example.pre-uninstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo " This is an example pre-uninstall hook output" 4 | echo " Use pre-uninstall to ask for additional confirmations or to warn about outcome." 5 | echo " If exit code will be non-zero, then uninstallation will not happen." 6 | sleep 2 7 | -------------------------------------------------------------------------------- /example/some-additional-files/somefile: -------------------------------------------------------------------------------- 1 | Hello, Docksal! 2 | -------------------------------------------------------------------------------- /mailpit/README.md: -------------------------------------------------------------------------------- 1 | # mailpit 2 | 3 | Easily install Mailpit email catcher for your Docksal project 4 | 5 | ```bash 6 | fin addon install mailpit 7 | ``` 8 | 9 | ## Usage once installed 10 | 11 | - `fin mailpit disable` to disable 12 | - `fin mailpit enable` to re-enable 13 | -------------------------------------------------------------------------------- /mailpit/conf/mailpit.yml: -------------------------------------------------------------------------------- 1 | # Mailpit 2 | mail: 3 | extends: 4 | file: ${HOME}/.docksal/stacks/services.yml 5 | service: mail 6 | -------------------------------------------------------------------------------- /mailpit/mailpit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Enable/disable mailpit for current project 4 | ## 5 | ## Sub-commands: 6 | ## enable Enable mailpit 7 | ## disable Disable mailpit 8 | 9 | red='\033[0;31m' 10 | green='\033[0;32m' 11 | green_bg='\033[42m' 12 | yellow='\033[1;33m' 13 | NC='\033[0m' 14 | 15 | echo-red () { echo -e "${red}$1${NC}"; } 16 | echo-green () { echo -e "${green}$1${NC}"; } 17 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 18 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 19 | die () { echo -e "$1"; exit 1; } 20 | 21 | DOCKSAL_YML=".docksal/docksal.yml" 22 | DOCKSAL_YML_NEW=".docksal/docksal.yml.new" 23 | DOCKSAL_ENV=".docksal/docksal.env" 24 | DOCKSAL_STACKS="$HOME/.docksal/stacks" 25 | MAILPIT_YML="$ADDON_ROOT/conf/mailpit.yml" 26 | 27 | #----------------------------------- YML & config functions ------------------------------------------ 28 | 29 | # Check whether given string is in config 30 | # $1 - string to find 31 | in_config () 32 | { 33 | fin config 2>/dev/null | grep "$1" >/dev/null 34 | } 35 | 36 | # Check that docksal.yml is valid 37 | yml_is_valid () 38 | { 39 | [[ -f "$DOCKSAL_YML" ]] && $(cat "$DOCKSAL_YML" 2>/dev/null | grep "services" >/dev/null) 40 | } 41 | 42 | # Prepares stack to editing docksal.yml config 43 | yml_prepare () 44 | { 45 | # Get yml version to use for a new file from existing stacks 46 | YML_VERSION=$(head "$DOCKSAL_STACKS/volumes-bind.yml" | grep "version") 47 | YML_DEFAULT_BODY="${YML_VERSION}\nservices:" 48 | NEW_STACK='DOCKSAL_STACK="default"' 49 | 50 | # Source docksal.env 51 | source "$DOCKSAL_ENV" >/dev/null 2>&1 52 | 53 | # If DOCKSAL_STACK is not set, then... 54 | if [[ -z "$DOCKSAL_STACK" ]]; then 55 | echo " Configuring to use DOCKSAL_STACK=\"default\"..." 56 | # ...set stack to default so we could use docksal.yml 57 | echo -e "$NEW_STACK" >> "$DOCKSAL_ENV" 58 | fi 59 | 60 | # Create docksal.yml if needed 61 | yml_is_valid || echo -e "$YML_DEFAULT_BODY" >> "$DOCKSAL_YML" 62 | } 63 | 64 | # Install tool required to edit yml from command line 65 | yml_install_tools () 66 | { 67 | fin exec "which yaml >/dev/null 2>&1 || npm install --silent -g yaml-cli >/dev/null" 68 | } 69 | 70 | # Add a service to docksal.yml from another yml 71 | # $1 - filename of yml get service from 72 | yml_add_service () 73 | { 74 | [[ -z "$1" ]] && echo "File not found: $1" && return 1 75 | # TODO: use https://www.npmjs.com/package/merge-yaml 76 | cat "$1" >> "$DOCKSAL_YML" 77 | } 78 | 79 | # Removes a service from docksal.yml 80 | # $1 - service name 81 | yml_remove_service () 82 | { 83 | [[ -z "$1" ]] && echo "Provide a service name to remove" && return 1 84 | local service="$1" 85 | read -r -d '' CODE_TO_EXEC <<-EOF 86 | yaml set $DOCKSAL_YML services.$service | grep -v '$service:' | tee $DOCKSAL_YML_NEW >/dev/null; 87 | [[ -z "\$(yaml get $DOCKSAL_YML_NEW services)" ]] && rm '$DOCKSAL_YML' || mv $DOCKSAL_YML_NEW $DOCKSAL_YML 88 | EOF 89 | # Remove service. If no services left after that, then remove docksal.yml 90 | fin exec "$CODE_TO_EXEC" 91 | } 92 | 93 | #-------------------------------------- mailpit functions --------------------------------------------- 94 | 95 | 96 | # Enable container and settings 97 | mailpit_enable () 98 | { 99 | # Check that mailpit is not already enabled 100 | if (in_config "image: axllent\/mailpit"); then 101 | echo " Mailpit support is already enabled." && exit 102 | fi 103 | 104 | echo " Enabling mailpit..." 105 | yml_prepare 106 | # Add mailpit service to docksal.yml 107 | yml_add_service "$MAILPIT_YML" 108 | # Apply stack changes. 109 | fin stop cli 110 | fin up 111 | } 112 | 113 | # Disable container and settings 114 | mailpit_disable () 115 | { 116 | echo " Running checks..." 117 | # Make sure cli container is running 118 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 119 | echo " ERROR: Start the project with fin start first" && exit 1 120 | fi 121 | 122 | # Make sure mailpit is installed 123 | if ! in_config "image: axllent\/mailpit"; then 124 | echo " Mailpit support is not enabled at the moment." && exit 125 | fi 126 | 127 | echo " Preparing to remove mailpit service..." 128 | yml_install_tools 129 | # Remove mailpit service from docksal.yml 130 | yml_remove_service "mail" 131 | # Apply stack changes 132 | COMPOSE_FILE="" fin stop cli 133 | fin up 134 | } 135 | 136 | #------------------------------------------ Runtime ----------------------------------------------- 137 | 138 | cd "$PROJECT_ROOT" 139 | 140 | case "$1" in 141 | enable) 142 | mailpit_enable 143 | ;; 144 | disable) 145 | mailpit_disable 146 | ;; 147 | *) 148 | echo "Usage: fin mailpit " 149 | exit 1 150 | ;; 151 | esac 152 | -------------------------------------------------------------------------------- /mailpit/mailpit.filelist: -------------------------------------------------------------------------------- 1 | # Hooks 2 | mailpit.pre-install 3 | mailpit.post-install 4 | mailpit.pre-uninstall 5 | 6 | # Container config 7 | conf/mailpit.yml 8 | -------------------------------------------------------------------------------- /mailpit/mailpit.post-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin mailpit enable 4 | 5 | echo -e "${green}Mailpit UI:${NC} http://mail..docksal" 6 | echo -e "${green}More documentation:${NC} https://docs.docksal.io/service/other/mailpit/" 7 | -------------------------------------------------------------------------------- /mailpit/mailpit.pre-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Check Docksal running 4 | if [[ "$DOCKER_RUNNING" != "true" ]]; then 5 | echo "[PRE-INSTALL] ERROR: Docksal and project should be running" 6 | exit 1 7 | fi 8 | 9 | # Check Docksal running 10 | if [[ "$ADDON_GLOBAL" == "true" ]]; then 11 | echo -e "[PRE-INSTALL] ERROR: Mailpit addon should not be installed globally" 12 | exit 1 13 | fi 14 | 15 | 16 | # Check project running 17 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 18 | echo "[PRE-INSTALL] ERROR: Start the project with fin start first" 19 | exit 1 20 | fi 21 | 22 | # Get fin config 23 | fin_config=$(fin config) 24 | if [[ $? != 0 ]]; then 25 | echo "[PRE-INSTALL] ERROR: 'fin config' command was not successful. Check your fin config" 26 | exit 1 27 | fi 28 | 29 | # Check there is no mailpit already 30 | if (echo "$fin_config" | grep "image: axllent\/mailpit"); then 31 | echo "[PRE-INSTALL] ERROR: Mailpit seems to be already enabled for this project" 32 | exit 1 33 | fi 34 | 35 | # Check there is no mailpit already 36 | if (echo "$fin_config" | grep " mail:"); then 37 | echo "[PRE-INSTALL] ERROR: Container named 'mail' already exists. Remove it to continue." 38 | exit 1 39 | fi 40 | 41 | 42 | # All good 43 | exit 0 -------------------------------------------------------------------------------- /mailpit/mailpit.pre-uninstall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin mailpit disable 4 | -------------------------------------------------------------------------------- /meilisearch/conf/meiliesearch.yml: -------------------------------------------------------------------------------- 1 | # Meilisearch 2 | meilisearch: 3 | hostname: meilisearch 4 | image: getmeili/meilisearch 5 | labels: 6 | - io.docksal.virtual-host=meilisearch.${VIRTUAL_HOST} 7 | ports: 8 | - "${MEILISEARCH_PORT_MAPPING:-7700}" 9 | volumes: 10 | - project_root:/var/www:ro,nocopy,cached # Project root volume (read-only) 11 | - db_data:/data.ms # Database data volume 12 | -------------------------------------------------------------------------------- /meilisearch/meilisearch: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Enable/disable meiliesearch for current project 4 | ## 5 | ## Sub-commands: 6 | ## enable Enable meiliesearch 7 | ## disable Disable meiliesearch 8 | 9 | # Console colors 10 | red='\033[0;91m' 11 | red_bg='\033[101m' 12 | yellow_bg='\033[43;90m' 13 | green='\033[0;32m' 14 | green_bg='\033[42m' 15 | yellow='\033[0;33m' 16 | yellow_bold='\033[1;33m' 17 | NC='\033[0m' 18 | 19 | echo-red () { echo -e "${red}$1${NC}"; } 20 | echo-green () { echo -e "${green}$1${NC}"; } 21 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 22 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 23 | die () { echo -e "$1"; exit 1; } 24 | 25 | DOCKSAL_YML=".docksal/docksal.yml" 26 | DOCKSAL_YML_NEW=".docksal/docksal.yml.new" 27 | DOCKSAL_ENV=".docksal/docksal.env" 28 | DOCKSAL_STACKS="$HOME/.docksal/stacks" 29 | MEILISEARCH_YML="$ADDON_ROOT/conf/meiliesearch.yml" 30 | 31 | #----------------------------------- YML & config functions ------------------------------------------ 32 | 33 | # Check whether given string is in config 34 | # $1 - string to find 35 | in_config () 36 | { 37 | fin config 2>/dev/null | grep "$1" >/dev/null 38 | } 39 | 40 | # Check that docksal.yml is valid 41 | yml_is_valid () 42 | { 43 | [[ -f "$DOCKSAL_YML" ]] && $(cat "$DOCKSAL_YML" 2>/dev/null | grep "services" >/dev/null) 44 | } 45 | 46 | # Prepares stack to editing docksal.yml config 47 | yml_prepare () 48 | { 49 | # Get yml version to use for a new file from existing stacks 50 | YML_VERSION=$(head "$DOCKSAL_STACKS/volumes-bind.yml" | grep "version") 51 | YML_DEFAULT_BODY="${YML_VERSION}\nservices:" 52 | NEW_STACK='DOCKSAL_STACK="default"' 53 | 54 | # Source docksal.env 55 | source "$DOCKSAL_ENV" >/dev/null 2>&1 56 | 57 | # If DOCKSAL_STACK is not set, then... 58 | if [[ -z "$DOCKSAL_STACK" ]]; then 59 | echo " Configuring to use DOCKSAL_STACK=\"default\"..." 60 | # ...set stack to default so we could use docksal.yml 61 | echo -e "$NEW_STACK" >> "$DOCKSAL_ENV" 62 | fi 63 | 64 | # Create docksal.yml if needed 65 | yml_is_valid || echo -e "$YML_DEFAULT_BODY" >> "$DOCKSAL_YML" 66 | } 67 | 68 | # Install tool required to edit yml from command line 69 | yml_install_tools () 70 | { 71 | fin exec "which yaml >/dev/null 2>&1 || npm install --silent -g yaml-cli >/dev/null" 72 | } 73 | 74 | # Add a service to docksal.yml from another yml 75 | # $1 - filename of yml get service from 76 | yml_add_service () 77 | { 78 | [[ -z "$1" ]] && echo "File not found: $1" && return 1 79 | # TODO: use https://www.npmjs.com/package/merge-yaml 80 | cat "$1" >> "$DOCKSAL_YML" 81 | } 82 | 83 | # Removes a service from docksal.yml 84 | # $1 - service name 85 | yml_remove_service () 86 | { 87 | [[ -z "$1" ]] && echo "Provide a service name to remove" && return 1 88 | local service="$1" 89 | read -r -d '' CODE_TO_EXEC <<-EOF 90 | yaml set $DOCKSAL_YML services.$service | grep -v '$service:' | tee $DOCKSAL_YML_NEW >/dev/null; 91 | [[ -z "\$(yaml get $DOCKSAL_YML_NEW services)" ]] && rm '$DOCKSAL_YML' || mv $DOCKSAL_YML_NEW $DOCKSAL_YML 92 | EOF 93 | # Remove service. If no services left after that, then remove docksal.yml 94 | fin exec "$CODE_TO_EXEC" 95 | } 96 | 97 | #-------------------------------------- meiliesearch functions --------------------------------------------- 98 | 99 | # Set/remove proper setting into php.ini 100 | # $1 - enable/disable 101 | # Enable container and settings 102 | meiliesearch_enable () 103 | { 104 | # Check that meiliesearch is not already enabled 105 | if (in_config "image: getmeili/meilisearch"); then 106 | echo " meiliesearch support is already enabled." && exit 107 | fi 108 | 109 | echo " Enabling meiliesearch..." 110 | yml_prepare 111 | # Add meiliesearch service to docksal.yml 112 | yml_add_service "$MEILISEARCH_YML" 113 | # Apply stack changes. 114 | fin stop cli 115 | fin up 116 | } 117 | 118 | # Disable container and settings 119 | meiliesearch_disable () 120 | { 121 | echo " Running checks..." 122 | # Make sure cli container is running 123 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 124 | echo " ERROR: Start the project with fin start first" && exit 1 125 | fi 126 | 127 | # Make sure meiliesearch is installed 128 | if ! in_config "image: getmeili/meilisearch"; then 129 | echo " meiliesearch support is not enabled at the moment." && exit 130 | fi 131 | 132 | echo " Preparing to remove meiliesearch service..." 133 | yml_install_tools 134 | # Remove meiliesearch service from docksal.yml 135 | yml_remove_service "meiliesearch" 136 | # Apply stack changes 137 | COMPOSE_FILE="" fin stop cli 138 | fin up 139 | } 140 | 141 | #------------------------------------------ Runtime ----------------------------------------------- 142 | 143 | cd "$PROJECT_ROOT" 144 | 145 | case "$1" in 146 | enable) 147 | meiliesearch_enable 148 | ;; 149 | disable) 150 | meiliesearch_disable 151 | ;; 152 | *) 153 | echo "Usage: fin meiliesearch " 154 | exit 1 155 | ;; 156 | esac 157 | -------------------------------------------------------------------------------- /meilisearch/meilisearch.filelist: -------------------------------------------------------------------------------- 1 | # Hooks 2 | meilisearch.pre-install 3 | meilisearch.post-install 4 | meilisearch.pre-uninstall 5 | 6 | # Container config 7 | conf/meilisearch.yml 8 | 9 | -------------------------------------------------------------------------------- /meilisearch/meilisearch.post-install: -------------------------------------------------------------------------------- 1 | !/usr/bin/env bash 2 | 3 | # Console colors 4 | red='\033[0;91m' 5 | red_bg='\033[101m' 6 | yellow_bg='\033[43;90m' 7 | green='\033[0;32m' 8 | green_bg='\033[42m' 9 | yellow='\033[0;33m' 10 | yellow_bold='\033[1;33m' 11 | NC='\033[0m' 12 | 13 | 14 | echo-red () { echo -e "${red}$1${NC}"; } 15 | echo-green () { echo -e "${green}$1${NC}"; } 16 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 17 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 18 | fin meilisearch enable 19 | 20 | echo-green "meilisearch UI:${yellow} http://meilisearch.$VIRTUAL_HOST${NC}" 21 | -------------------------------------------------------------------------------- /meilisearch/meilisearch.pre-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Check Docksal running 4 | if [[ "$DOCKER_RUNNING" != "true" ]]; then 5 | echo "[PRE-INSTALL] ERROR: Docksal and project should be running" 6 | exit 1 7 | fi 8 | 9 | # Check Docksal running 10 | if [[ "$ADDON_GLOBAL" == "true" ]]; then 11 | echo -e "[PRE-INSTALL] ERROR: Meilisearch addon should not be installed globally" 12 | exit 1 13 | fi 14 | 15 | 16 | # Check project running 17 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 18 | echo "[PRE-INSTALL] ERROR: Start the project with fin start first" 19 | exit 1 20 | fi 21 | 22 | # Get fin config 23 | fin_config=$(fin config) 24 | if [[ $? != 0 ]]; then 25 | echo "[PRE-INSTALL] ERROR: 'fin config' command was not successful. Check your fin config" 26 | exit 1 27 | fi 28 | 29 | # Check there is no adminer already 30 | if (echo "$fin_config" | grep "image: getmeili/meilisearch"); then 31 | echo "[PRE-INSTALL] ERROR: Adminer seems to be already enabled for this project" 32 | exit 1 33 | fi 34 | 35 | # Check there is no adminer already 36 | if (echo "$fin_config" | grep " meilisearch:"); then 37 | echo "[PRE-INSTALL] ERROR: Container named 'meilisearch' already exists. Remove it to continue." 38 | exit 1 39 | fi 40 | 41 | # All good 42 | exit 0 43 | -------------------------------------------------------------------------------- /meilisearch/meilisearch.pre-uninstall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin meilisearch disable 4 | -------------------------------------------------------------------------------- /mkcert/README.md: -------------------------------------------------------------------------------- 1 | # mkcert 2 | 3 | [mkcert](https://github.com/FiloSottile/mkcert) addon for Docksal. 4 | 5 | A mkcert generated cert will be trusted locally by: 6 | 7 | - Firefox (Linux & Mac) 8 | - Chrome & Chromium 9 | - curl & wget 10 | 11 | The cert is automatically generated for `VIRTUAL_HOST` and `*.VIRTUAL_HOST`. 12 | 13 | ## Installation 14 | 15 | ```bash 16 | fin addon install --global mkcert 17 | ``` 18 | 19 | The `mkcert` binary is installed in `$HOME/.docksal/bin/mkcert` **except** when `mkcert` is already installed globally. 20 | 21 | ## Use 22 | 23 | In a project directory, run: 24 | 25 | ```bash 26 | fin mkcert create 27 | fin project restart 28 | ``` 29 | 30 | Open https://[project].docksal to validate. 31 | -------------------------------------------------------------------------------- /mkcert/mkcert: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERSION="1.0" 4 | 5 | ## mkcert addon 6 | ## 7 | ## This is an mkcert addon. 8 | ## See: https://github.com/FiloSottile/mkcert for details 9 | ## 10 | ## It creates trusted certificates for $VIRTUAL_HOST and *.$VIRTUAL_HOST 11 | ## 12 | ## fin mkcert 13 | ## 14 | ## Usage: 15 | ## create (cr) Create a certificate for this project 16 | ## version Display addon version 17 | 18 | CONFIG_CERTS=${CONFIG_CERTS:-$HOME/.docksal/certs} 19 | 20 | if [[ "$TERM" != "dumb" ]]; then 21 | # Console colors 22 | red='\033[0;91m' 23 | red_bg='\033[101m' 24 | yellow_bg='\033[43m' 25 | lightmagenta_bg='\033[0;105m' 26 | green='\033[0;32m' 27 | green_bg='\033[42m' 28 | yellow='\033[0;33m' 29 | yellow_bold='\033[1;33m' 30 | blue='\033[0;34m' 31 | lime='\033[0;92m' 32 | acqua='\033[0;96m' 33 | magenta='\033[0;35m' 34 | lightmagenta='\033[0;95m' 35 | NC='\033[0m' 36 | fi 37 | 38 | echo-red () { echo -e "${red}$1${NC}"; } 39 | echo-green () { echo -e "${green}$1${NC}"; } 40 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 41 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 42 | 43 | echo-warning () 44 | { 45 | echo -e "${yellow_bg} WARNING: ${NC} ${yellow}$1${NC}"; 46 | shift 47 | for arg in "$@"; do 48 | echo -e " $arg" 49 | done 50 | } 51 | 52 | echo-error () 53 | { 54 | echo -e "${red_bg} ERROR: ${NC} ${red}$1${NC}" 55 | shift 56 | for arg in "$@"; do 57 | echo -e " $arg" 58 | done 59 | } 60 | 61 | echo-alert () 62 | { 63 | echo -e "${lightmagenta_bg} ALERT: ${NC} ${lightmagenta}$1${NC}" 64 | shift 65 | for arg in "$@"; do 66 | echo -e " $arg" 67 | done 68 | } 69 | 70 | # print string in $1 for $2 times 71 | echo-repeat () 72 | { 73 | seq -f $1 -s '' $2; echo 74 | } 75 | 76 | # prints message to stderr 77 | echo-stderr () 78 | { 79 | (>&2 echo "$@") 80 | } 81 | 82 | # Get path to .docksal folder using upfind 83 | get_project_path () 84 | { 85 | if [[ "$DOCKSAL_PATH" == "" ]]; then 86 | DOCKSAL_PATH=$(upfind ".docksal") 87 | fi 88 | # If we reached $HOME, then we did not find the project root. 89 | if [[ "$DOCKSAL_PATH" != "$HOME" ]]; then 90 | echo "$DOCKSAL_PATH" 91 | fi 92 | } 93 | 94 | # Check that .docksal is present 95 | check_project_root () 96 | { 97 | if [[ "$(get_project_path)" == "" ]] ; then 98 | echo-error "Cannot detect project root." \ 99 | "Please make sure you have ${yellow}.docksal${NC} directory in the root of your project." \ 100 | "To setup a basic Docksal stack in the current directory run ${yellow}fin config generate${NC}" 101 | exit 1 102 | fi 103 | } 104 | 105 | create_project_certificate () 106 | { 107 | check_project_root 108 | mkcert -key-file ${CONFIG_CERTS}/${VIRTUAL_HOST}.key -cert-file ${CONFIG_CERTS}/${VIRTUAL_HOST}.crt *.${VIRTUAL_HOST} ${VIRTUAL_HOST} 109 | if [[ $? == 0 ]]; then 110 | echo-green "Run ${yellow}fin project restart${NC} to load the new cert." 111 | fi 112 | } 113 | 114 | case "$1" in 115 | create|cr) 116 | create_project_certificate 117 | ;; 118 | version|-v) 119 | echo "$VERSION" 120 | ;; 121 | *) 122 | fin help mkcert 123 | ;; 124 | esac 125 | -------------------------------------------------------------------------------- /mkcert/mkcert.filelist: -------------------------------------------------------------------------------- 1 | # Hooks 2 | mkcert.pre-install 3 | 4 | -------------------------------------------------------------------------------- /mkcert/mkcert.pre-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Check Global flag 4 | if [[ "$ADDON_GLOBAL" != "true" ]]; then 5 | echo -e "[PRE-INSTALL] ERROR: Mkcert addon should installed globally, use 'fin addon install mkcert -g'" 6 | exit 1 7 | fi 8 | 9 | CONFIG_DIR="$HOME/.docksal" 10 | CONFIG_CERTS=${CONFIG_CERTS:-$HOME/.docksal/certs} 11 | MKCERT_BIN="$CONFIG_DIR/bin/mkcert" 12 | MKCERT_ADDON="$CONFIG_DIR/addons/mkcert" 13 | 14 | REQUIREMENTS_MKCERT=1.4.1 15 | URL_MKCERT_MAC="https://github.com/FiloSottile/mkcert/releases/download/v${REQUIREMENTS_MKCERT}/mkcert-v${REQUIREMENTS_MKCERT}-darwin-amd64" 16 | URL_MKCERT_NIX="https://github.com/FiloSottile/mkcert/releases/download/v${REQUIREMENTS_MKCERT}/mkcert-v${REQUIREMENTS_MKCERT}-linux-amd64" 17 | URL_MKCERT_WIN="https://github.com/FiloSottile/mkcert/releases/download/v${REQUIREMENTS_MKCERT}/mkcert-v${REQUIREMENTS_MKCERT}-windows-amd64.exe" 18 | 19 | if [[ "$TERM" != "dumb" ]]; then 20 | # Console colors 21 | red='\033[0;91m' 22 | red_bg='\033[101m' 23 | yellow_bg='\033[43m' 24 | lightmagenta_bg='\033[0;105m' 25 | green='\033[0;32m' 26 | green_bg='\033[42m' 27 | yellow='\033[0;33m' 28 | yellow_bold='\033[1;33m' 29 | blue='\033[0;34m' 30 | lime='\033[0;92m' 31 | acqua='\033[0;96m' 32 | magenta='\033[0;35m' 33 | lightmagenta='\033[0;95m' 34 | NC='\033[0m' 35 | fi 36 | 37 | echo-red () { echo -e "${red}$1${NC}"; } 38 | echo-green () { echo -e "${green}$1${NC}"; } 39 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 40 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 41 | 42 | echo-warning () 43 | { 44 | echo -e "${yellow_bg} WARNING: ${NC} ${yellow}$1${NC}"; 45 | shift 46 | for arg in "$@"; do 47 | echo -e " $arg" 48 | done 49 | } 50 | 51 | echo-error () 52 | { 53 | echo -e "${red_bg} ERROR: ${NC} ${red}$1${NC}" 54 | shift 55 | for arg in "$@"; do 56 | echo -e " $arg" 57 | done 58 | } 59 | 60 | echo-alert () 61 | { 62 | echo -e "${lightmagenta_bg} ALERT: ${NC} ${lightmagenta}$1${NC}" 63 | shift 64 | for arg in "$@"; do 65 | echo -e " $arg" 66 | done 67 | } 68 | 69 | # print string in $1 for $2 times 70 | echo-repeat () 71 | { 72 | seq -f $1 -s '' $2; echo 73 | } 74 | 75 | # prints message to stderr 76 | echo-stderr () 77 | { 78 | (>&2 echo "$@") 79 | } 80 | 81 | # Get path to .docksal folder using upfind 82 | get_project_path () 83 | { 84 | if [[ "$DOCKSAL_PATH" == "" ]]; then 85 | DOCKSAL_PATH=$(upfind ".docksal") 86 | fi 87 | # If we reached $HOME, then we did not find the project root. 88 | if [[ "$DOCKSAL_PATH" != "$HOME" ]]; then 89 | echo "$DOCKSAL_PATH" 90 | fi 91 | } 92 | 93 | is_linux () 94 | { 95 | [[ "$OS_TYPE" == "Linux" ]] 96 | } 97 | 98 | # TODO: drop this function in May 2020 to complete Babun deprecation 99 | is_windows () 100 | { 101 | [[ "$OS_TYPE" == "Cygwin" ]] 102 | } 103 | 104 | is_wsl () 105 | { 106 | [[ "$OS_TYPE" == "WSL" ]] 107 | } 108 | 109 | is_mac () 110 | { 111 | [[ "$OS_TYPE" == "Darwin" ]] 112 | } 113 | 114 | if [[ "$(mkcert --version 2>&1)" != "v${REQUIREMENTS_MKCERT}" ]]; then 115 | is_linux && URL_MKCERT=$URL_MKCERT_NIX 116 | is_wsl && URL_MKCERT=$URL_MKCERT_NIX 117 | is_windows && URL_MKCERT=$URL_MKCERT_WIN 118 | is_mac && URL_MKCERT=$URL_MKCERT_MAC 119 | 120 | echo-green "[PRE-INSTALL] INFO: Installing mkcert..." 121 | curl -fL# "$URL_MKCERT" -o "$MKCERT_BIN" && \ 122 | chmod +x "$MKCERT_BIN" && \ 123 | 124 | if (mkcert --version &>/dev/null); then 125 | echo-green "[PRE-INSTALL] INFO: mkcert version $(mkcert --version) installed" 126 | else 127 | echo-red "[PRE-INSTALL] ERROR: mkcert installation/upgrade failed." 128 | exit 1 129 | fi 130 | 131 | echo-green "[PRE-INSTALL] INFO: Initializing mkcert" 132 | mkcert -install 133 | 134 | mkdir -p "${CONFIG_CERTS}" 135 | else 136 | echo-green "[PRE-INSTALL] INFO: mkcert binary allready installed; found $(which mkcert)" 137 | fi 138 | -------------------------------------------------------------------------------- /phpcs/README.md: -------------------------------------------------------------------------------- 1 | # PHP Code Sniffer 2 | 3 | Easily run PHPCS and PHPCBF commands to detect violations of a defined coding standard. Coding standards are included within the Docksal `cli` container for both [Drupal](https://www.drupal.org/docs/8/modules/code-review-module/installing-coder-sniffer) and [WordPress](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards). 4 | 5 | ```bash 6 | fin addon install phpcs 7 | ``` 8 | 9 | ## Usage once installed 10 | 11 | Once installed the following commands can be ran to help with code quality. 12 | 13 | ### PHPCS 14 | 15 | The main `phpcs` script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard. 16 | 17 | ```bash 18 | # Default Command 19 | fin phpcs cs "modules/test_module" 20 | ``` 21 | 22 | ```bash 23 | # Run With Other Options 24 | fin phpcs cs --standards="ExtraStandards,Drupal,DrupalPractice" modules/test_module 25 | ``` 26 | 27 | ### PHPCBF 28 | 29 | The second `phpcbf` script automatically corrects coding standard violations. 30 | 31 | 32 | ```bash 33 | # Default Command 34 | fin phpcs cbf "modules/test_module" 35 | ``` 36 | 37 | ```bash 38 | # Run With Other Options 39 | fin phpcs cbf --standards="ExtraStandards,Drupal,DrupalPractice" modules/test_module 40 | ``` 41 | 42 | ### Default Standards Used 43 | 44 | For Drupal: Drupal,DrupalPractice 45 | 46 | For WordPress: WordPress 47 | 48 | To customize these the `--standards` option could be used. 49 | 50 | Additionally the `PHPCS_STANDARDS` variable may set within `.docksal/docksal.env`. 51 | 52 | ### Default Extensions Used 53 | 54 | For Drupal: php,module,inc,install,test,profile,theme,css,info,txt,md 55 | 56 | For WordPress: php 57 | 58 | To customize these the `--extensions` option could be used. 59 | 60 | Additionally the `PHPCS_EXTENSIONS` variable may set within `.docksal/docksal.env`. 61 | -------------------------------------------------------------------------------- /phpcs/phpcs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Run PHP Code Sniffer Commands 4 | ## 5 | ## This command will allow for running Code Sniffer commands 6 | ## to help make sure is to coding standards. 7 | ## 8 | ## Running PHPCS 9 | ## fin phpcs cs "[directory name]" 10 | ## 11 | ## Running PHPCBF 12 | ## fin phpcs cbf "[directory name]" 13 | ## 14 | ## Usage: 15 | ## cs Run PHPCS 16 | ## cbf Run PHPCBF 17 | 18 | STANDARDS="" 19 | 20 | if [[ -n "${PHPCS_STANDARDS}" ]]; then 21 | STANDARDS="${PHPCS_STANDARDS}" 22 | fi 23 | 24 | if [[ -n "${PHPCS_EXTENSIONS}" ]]; then 25 | EXTENSIONS="${PHPCS_EXTENSIONS}" 26 | fi 27 | 28 | if [[ -f "${PROJECT_ROOT}/${DOCROOT}/sites/default/settings.php" ]] || [[ -f "${PROJECT_ROOT}/${DOCROOT}/sites/default/default.settings.php" ]]; then 29 | STANDARDS="${STANDARDS:-"Drupal,DrupalPractice"}" 30 | EXTENSIONS="${EXTENSIONS:-"php,module,inc,install,test,profile,theme,css,info,txt,md"}"; 31 | elif [[ -f "${PROJECT_ROOT}/${DOCROOT}/wp-config.php" ]]; then 32 | STANDARDS="${STANDARDS:-"WordPress"}" 33 | EXTENSIONS="${EXTENSIONS:-"php"}" 34 | fi 35 | 36 | COMMAND="" 37 | 38 | case "$1" in 39 | cs) 40 | shift 41 | COMMAND="phpcs" 42 | ;; 43 | cbf) 44 | shift 45 | COMMAND="phpcbf" 46 | ;; 47 | *) 48 | fin help phpcs 49 | exit 50 | ;; 51 | esac 52 | 53 | # If standard flag is used remove our default. 54 | STANDARD_OPT="--standard=\"${STANDARDS}\"" 55 | if [[ "$@" =~ "--standard=" ]]; then 56 | STANDARD_OPT="" 57 | fi 58 | 59 | # If extension flag is used remove our default. 60 | EXTENSION_OPT="--extensions=\"${EXTENSIONS}\"" 61 | if [[ "$@" =~ "--extensions=" ]]; then 62 | EXTENSION_OPT="" 63 | fi 64 | 65 | # run the command in the container. 66 | fin exec "$COMMAND $STANDARD_OPT $EXTENSION_OPT $@" 67 | -------------------------------------------------------------------------------- /phpunit/README.md: -------------------------------------------------------------------------------- 1 | # PHPUnit 2 | 3 | Easily run PHPUnit tests for your Drupal 8 project. 4 | 5 | ```bash 6 | fin addon install phpunit 7 | ``` 8 | 9 | ## Usage once installed 10 | 11 | Run `fin phpunit` to run the tests. Any additional arguments and options will be appended to the command. For example, to run tests within the `modules/custom` directory, run `fin phpunit modules/custom`. 12 | 13 | If no `phpunit.xml` file exists, either a project specific one can be copied from `.docksal/drupal/core/phpunit.xml` or core's `phpunit.xml.dist` will be duplicated and renamed. 14 | -------------------------------------------------------------------------------- /phpunit/phpunit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #: exec_target = cli 4 | 5 | ## Creates a phpunit.xml file and runs PHPUnit tests in Drupal 8 6 | ## 7 | ## Usage: fin phpunit 8 | ## 9 | ## This first ensures that a `core/phpunit.xml` file exists, either by copying a 10 | ## stub from `.docksal/drupal/core/phpunit.xml` if that exists, or copying and 11 | ## renaming `core/phpunit.xml.dist`. 12 | ## 13 | ## If `core/phpunit.xml` exists, the phpunit command with then be run, appending 14 | ## any optional arguments such as the directory path (run `fin phpunit -h`) to 15 | ## see a full list of options. 16 | 17 | DOCROOT_PATH="${PROJECT_ROOT}/${DOCROOT}" 18 | DRUPAL_CORE_PATH="${DOCROOT_PATH}/core" 19 | 20 | run_tests() { 21 | ${PROJECT_ROOT}/vendor/bin/phpunit -c ${DRUPAL_CORE_PATH} "$@" 22 | } 23 | 24 | if [ ! -e ${DRUPAL_CORE_PATH}/phpunit.xml ]; then 25 | if [ -e "${PROJECT_ROOT}/.docksal/drupal/core/phpunit.xml" ]; then 26 | echo "Copying ${PROJECT_ROOT}/.docksal/drupal/core/phpunit.xml to ${DRUPAL_CORE_PATH}/phpunit.xml" 27 | cp "${PROJECT_ROOT}/.docksal/drupal/core/phpunit.xml" ${DRUPAL_CORE_PATH}/phpunit.xml 28 | run_tests "$@" 29 | else 30 | echo "Copying phpunit.xml.dist to phpunit.xml." 31 | echo "Please edit it's values as needed and re-run 'fin phpunit'." 32 | cp ${DRUPAL_CORE_PATH}/phpunit.xml.dist ${DRUPAL_CORE_PATH}/phpunit.xml 33 | exit 1; 34 | fi 35 | else 36 | run_tests "$@" 37 | fi 38 | -------------------------------------------------------------------------------- /pma/README.md: -------------------------------------------------------------------------------- 1 | # PHPMyAdmin - Docksal addon 2 | 3 | Easily install PHPMyAdmin for your Docksal project. Make it easy to access the database and examine directly rather then through the CLI. 4 | 5 | ```bash 6 | fin addon install pma 7 | ``` 8 | 9 | ## URL 10 | 11 | After the installation PhpMyAdmin will be available at `http://pma-.docksal` 12 | 13 | ## Command line reference 14 | 15 | - `fin pma disable` to disable 16 | - `fin pma enable` to re-enable 17 | 18 | ## Regressions 19 | Previously the url for PHPMyAdmin could be found at `http://pma..docksal`. This change was made to make it easier to use a LetsEncrypt wildcard certificate, as it is only valid for one level of subdomains. 20 | -------------------------------------------------------------------------------- /pma/conf/pma.yml: -------------------------------------------------------------------------------- 1 | # PHPMyAdmin 2 | pma: 3 | hostname: pma 4 | image: phpmyadmin/phpmyadmin 5 | environment: 6 | - PMA_HOST=db 7 | - PMA_USER=root 8 | - PMA_PASSWORD=${MYSQL_ROOT_PASSWORD:-root} 9 | labels: 10 | - io.docksal.virtual-host=pma-${VIRTUAL_HOST} 11 | -------------------------------------------------------------------------------- /pma/pma: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Enable/disable pma for current project 4 | ## 5 | ## Sub-commands: 6 | ## enable Enable pma 7 | ## disable Disable pma 8 | 9 | red='\033[0;31m' 10 | green='\033[0;32m' 11 | green_bg='\033[42m' 12 | yellow='\033[1;33m' 13 | NC='\033[0m' 14 | 15 | echo-red () { echo -e "${red}$1${NC}"; } 16 | echo-green () { echo -e "${green}$1${NC}"; } 17 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 18 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 19 | die () { echo -e "$1"; exit 1; } 20 | 21 | DOCKSAL_YML=".docksal/docksal.yml" 22 | DOCKSAL_YML_NEW=".docksal/docksal.yml.new" 23 | DOCKSAL_ENV=".docksal/docksal.env" 24 | DOCKSAL_STACKS="$HOME/.docksal/stacks" 25 | PMA_YML="$ADDON_ROOT/conf/pma.yml" 26 | 27 | #----------------------------------- YML & config functions ------------------------------------------ 28 | 29 | # Check whether given string is in config 30 | # $1 - string to find 31 | in_config () 32 | { 33 | fin config 2>/dev/null | grep "$1" >/dev/null 34 | } 35 | 36 | # Check that docksal.yml is valid 37 | yml_is_valid () 38 | { 39 | [[ -f "$DOCKSAL_YML" ]] && $(cat "$DOCKSAL_YML" 2>/dev/null | grep "services" >/dev/null) 40 | } 41 | 42 | # Prepares stack to editing docksal.yml config 43 | yml_prepare () 44 | { 45 | # Get yml version to use for a new file from existing stacks 46 | YML_VERSION=$(head "$DOCKSAL_STACKS/volumes-bind.yml" | grep "version") 47 | YML_DEFAULT_BODY="${YML_VERSION}\nservices:" 48 | NEW_STACK='DOCKSAL_STACK="default"' 49 | 50 | # Source docksal.env 51 | source "$DOCKSAL_ENV" >/dev/null 2>&1 52 | 53 | # If DOCKSAL_STACK is not set, then... 54 | if [[ -z "$DOCKSAL_STACK" ]]; then 55 | echo " Configuring to use DOCKSAL_STACK=\"default\"..." 56 | # ...set stack to default so we could use docksal.yml 57 | echo -e "$NEW_STACK" >> "$DOCKSAL_ENV" 58 | fi 59 | 60 | # Create docksal.yml if needed 61 | yml_is_valid || echo -e "$YML_DEFAULT_BODY" > "$DOCKSAL_YML" 62 | } 63 | 64 | # Install tool required to edit yml from command line 65 | yml_install_tools () 66 | { 67 | fin exec "which yaml >/dev/null 2>&1 || npm install --silent -g yaml-cli >/dev/null" 68 | } 69 | 70 | # Add a service to docksal.yml from another yml 71 | # $1 - filename of yml get service from 72 | yml_add_service () 73 | { 74 | [[ -z "$1" ]] && echo "File not found: $1" && return 1 75 | # TODO: use https://www.npmjs.com/package/merge-yaml 76 | cat "$1" >> "$DOCKSAL_YML" 77 | } 78 | 79 | # Removes a service from docksal.yml 80 | # $1 - service name 81 | yml_remove_service () 82 | { 83 | [[ -z "$1" ]] && echo "Provide a service name to remove" && return 1 84 | local service="$1" 85 | read -r -d '' CODE_TO_EXEC <<-EOF 86 | yaml set $DOCKSAL_YML services.$service | grep -v '$service:' | tee $DOCKSAL_YML_NEW >/dev/null; 87 | [[ -z "\$(yaml get $DOCKSAL_YML_NEW services)" ]] && rm '$DOCKSAL_YML' || mv $DOCKSAL_YML_NEW $DOCKSAL_YML 88 | EOF 89 | # Remove service. If no services left after that, then remove docksal.yml 90 | fin exec "$CODE_TO_EXEC" 91 | } 92 | 93 | #-------------------------------------- PMA functions --------------------------------------------- 94 | 95 | # Set/remove proper setting into php.ini 96 | # $1 - enable/disable 97 | # Enable container and settings 98 | pma_enable () 99 | { 100 | # Check that pma is not already enabled 101 | if (in_config "image: phpmyadmin\/phpmyadmin"); then 102 | echo " PHPMyAdmin support is already enabled." && exit 103 | fi 104 | 105 | echo " Enabling pma..." 106 | yml_prepare 107 | # Add pma service to docksal.yml 108 | yml_add_service "$PMA_YML" 109 | # Apply stack changes. 110 | fin stop cli 111 | fin up 112 | } 113 | 114 | # Disable container and settings 115 | pma_disable () 116 | { 117 | echo " Running checks..." 118 | # Make sure cli container is running 119 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 120 | echo " ERROR: Start the project with fin start first" && exit 1 121 | fi 122 | 123 | # Make sure pma is installed 124 | if ! in_config "image: phpmyadmin\/phpmyadmin"; then 125 | echo " PHPMyAdmin support is not enabled at the moment." && exit 126 | fi 127 | 128 | echo " Preparing to remove pma service..." 129 | yml_install_tools 130 | # Remove pma service from docksal.yml 131 | yml_remove_service "pma" 132 | # Apply stack changes 133 | COMPOSE_FILE="" fin stop cli 134 | fin up 135 | } 136 | 137 | #------------------------------------------ Runtime ----------------------------------------------- 138 | 139 | cd "$PROJECT_ROOT" 140 | 141 | case "$1" in 142 | enable) 143 | pma_enable 144 | ;; 145 | disable) 146 | pma_disable 147 | ;; 148 | *) 149 | echo "Usage: fin pma " 150 | exit 1 151 | ;; 152 | esac 153 | -------------------------------------------------------------------------------- /pma/pma.filelist: -------------------------------------------------------------------------------- 1 | # Hooks 2 | pma.pre-install 3 | pma.post-install 4 | pma.pre-uninstall 5 | 6 | # Container config 7 | conf/pma.yml 8 | -------------------------------------------------------------------------------- /pma/pma.post-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin pma enable 4 | 5 | echo -e "${green}PHPMyAdmin UI:${NC} http://pma-$VIRTUAL_HOST" 6 | -------------------------------------------------------------------------------- /pma/pma.pre-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Check Docksal running 4 | if [[ "$DOCKER_RUNNING" != "true" ]]; then 5 | echo "[PRE-INSTALL] ERROR: Docksal and project should be running" 6 | exit 1 7 | fi 8 | 9 | # Check Docksal running 10 | if [[ "$ADDON_GLOBAL" == "true" ]]; then 11 | echo -e "[PRE-INSTALL] ERROR: PHPMyAdmin addon should not be installed globally" 12 | exit 1 13 | fi 14 | 15 | 16 | # Check project running 17 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 18 | echo "[PRE-INSTALL] ERROR: Start the project with fin start first" 19 | exit 1 20 | fi 21 | 22 | # Get fin config 23 | fin_config=$(fin config) 24 | if [[ $? != 0 ]]; then 25 | echo "[PRE-INSTALL] ERROR: 'fin config' command was not successful. Check your fin config" 26 | exit 1 27 | fi 28 | 29 | # Check there is no pma already 30 | if (echo "$fin_config" | grep "image: phpmyadmin\/phpmyadmin"); then 31 | echo "[PRE-INSTALL] ERROR: PHPMyAdmin seems to be already enabled for this project" 32 | exit 1 33 | fi 34 | 35 | # Check there is no pma already 36 | if (echo "$fin_config" | grep " pma:"); then 37 | echo "[PRE-INSTALL] ERROR: Container named 'pma' already exists. Remove it to continue." 38 | exit 1 39 | fi 40 | 41 | 42 | # All good 43 | exit 0 44 | -------------------------------------------------------------------------------- /pma/pma.pre-uninstall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin pma disable 4 | -------------------------------------------------------------------------------- /pull/README.md: -------------------------------------------------------------------------------- 1 | # Remote Provider Pull 2 | 3 | The `pull` addon was recently a core command but has moved to an addon command. 4 | 5 | `fin pull` command allows you to easily bring your assets: db, files, and code from your hosting environment 6 | down to your local environment without manually running through the steps. 7 | 8 | ## Installation 9 | 10 | ```bash 11 | fin addon install --global pull 12 | ``` 13 | 14 | ## Requirements 15 | 16 | ### Acquia 17 | 18 | To interact with Acquia through the Acquia CLI, the `SECRET_ACQUIA_CLI_SECRET` and 19 | `SECRET_ACQUIA_CLI_KEY` are required. Additionally, access to the Acquia Cloud API 20 | is required. If access is not allowed, fallback to using the [Drush](https://docs.docksal.io/fin/fin-pull/#drupal-drush) method. 21 | 22 | More information on working with [Acquia CLI in Docksal](https://docs.docksal.io/tools/acquia-drush). 23 | 24 | ### Pantheon 25 | 26 | Interacting with Pantheon requires that the `SECRET_TERMINUS_TOKEN` 27 | is set. More information on [generating tokens](https://pantheon.io/docs/machine-tokens/) 28 | can be found in Pantheon's documentation. 29 | 30 | More information on working with [Pantheon in Docksal](https://docs.docksal.io/tools/terminus). 31 | 32 | ### Platform.sh 33 | 34 | Interacting with Platform.sh requires that the `SECRET_PLATFORMSH_CLI_TOKEN` 35 | is set. For more information on [creating CLI tokens](https://docs.platform.sh/gettingstarted/cli/api-tokens.html) 36 | for use with the Platform.sh CLI tool, consult with Platform's documentation. 37 | 38 | More information on working with [Platform.sh in Docksal](https://docs.docksal.io/tools/platformsh). 39 | 40 | ### Drupal / Drush 41 | 42 | A [Drush site alias](https://docs.docksal.io/tools/drush/#site-aliases) must be set up within the project and recognized when running the `fin drush sa` command to use 43 | the Drush provider integration. An example of a site alias file for [Drush 8](https://github.com/drush-ops/drush/blob/8.x/examples/example.aliases.drushrc.php), 44 | [Drush 9](https://github.com/drush-ops/drush/blob/9.x/examples/example.site.yml) and [Drush 10](https://github.com/drush-ops/drush/blob/master/examples/example.site.yml) can be 45 | found within the Drush project. 46 | 47 | An example of what `remote.site.yml` would look like: 48 | 49 | ```yaml 50 | dev: 51 | host: 1.1.1.1 52 | paths: 53 | dump-dir: /home/remote-user/backup/ 54 | root: /var/www/drupal8/docroot 55 | uri: example.com 56 | user: remote-user 57 | 58 | ``` 59 | 60 | The following is an example of `example.aliases.drushrc.php`: 61 | 62 | ```php 63 | 'server.domain.com', 67 | 'remote-user' => 'www-admin', 68 | 'root' => '/other/path/to/drupal', 69 | 'uri' => 'http://example.com', 70 | ); 71 | ``` 72 | 73 | ### WordPress / WP-CLI 74 | 75 | To use the WP-CLI provider integration, an alias must be set up within the project. For instructions 76 | on setting up a `wp-cli.yml` file or a config file, consult the [WordPress WP-CLI Config Documentation](https://make.wordpress.org/cli/handbook/config/#config-files). 77 | 78 | Example of what `wp-cli.yml` would look like: 79 | 80 | ```yaml 81 | @remote: 82 | ssh: ssh-user@1.1.1.1/var/www/wordpress/docroot 83 | url: http://example.com 84 | ``` 85 | 86 | More information on working with [WP-CLI in Docksal](https://docs.docksal.io/tools/wp-cli). 87 | 88 | ## Initializing Project 89 | 90 | If you are not using an initializing process for a specific provider and are 91 | starting from an already existing project, you can take advantage of 92 | the `fin pull` command by setting the `HOSTING_PLATFORM` and 93 | `HOSTING_SITE` variables within the project's `.docksal/docksal.env` 94 | file. 95 | 96 | ```bash 97 | fin config set HOSTING_PLATFORM=[provider] 98 | 99 | fin config set HOSTING_SITE="[remote name]" 100 | 101 | # WordPress is the only provider that doesn't need to use this. 102 | fin config set HOSTING_ENV="[remote env]" 103 | ``` 104 | 105 | If you are starting from scratch, the following command can be used 106 | to pull code and start the project locally: 107 | 108 | ```bash 109 | fin pull init \ 110 | --hosting-platform= \ 111 | --hosting-site= \ 112 | --hosting-env= \ 113 | 114 | ``` 115 | 116 | ### Acquia / Pantheon / Platform.sh 117 | 118 | Additionally, the `--hosting-env` option can be used to specify exactly 119 | which environment on Acquia Cloud that should be used. If it isn't used, 120 | the `dev` environment is used by default. 121 | 122 | ### Drush / WP-CLI 123 | 124 | Drupal and WordPress Providers are supported but require a GIT URL that 125 | can be cloned. 126 | 127 | ```bash 128 | fin pull init \ 129 | --hosting-platform=drush \ 130 | --hosting-site="example" \ 131 | my_new_site \ 132 | https://github.com/docksal/drupal8.git 133 | ``` 134 | 135 | ## Pulling Code 136 | 137 | Pulling code utilizes the project's existing git remotes and allows for 138 | the project to pull in the latest code from the remote. 139 | 140 | To pull code use the argument `code`. This will default to pulling `origin` 141 | and then pulling the current branch. If a different branch or remote is required, 142 | those can be specified using the flags `--sync-git-remote` and `--sync-git-branch`. 143 | 144 | Example 145 | 146 | ``` 147 | # Default Pull From Origin and current branch. 148 | fin pull code 149 | 150 | # Pull from the production remote. 151 | fin pull code --sync-git-remote=production 152 | 153 | # Pull the dev branch. 154 | fin pull code --sync-git-branch=dev 155 | 156 | # Pull from the github remote and the rc branch. 157 | fin pull code --sync-git-remote=github --sync-git-branch=rc 158 | ``` 159 | 160 | ``` 161 | --sync-git-remote The GIT Remote to pull from. (Defaults to origin) 162 | --sync-git-branch The GIT Branch to pull from. (Defaults to current branch) 163 | ``` 164 | 165 | ## Pulling Database 166 | 167 | To pull a database from the remote, run the `pull db` command. When 168 | pulling the database, it stays cached within your `cli` container for a 169 | period of one (1) hour. If at any point this needs to be updated, use 170 | the `--force` option as this will bypass the database and reimport. 171 | 172 | ```bash 173 | fin pull db 174 | ``` 175 | 176 | When pulling there are some additional options that can be used for 177 | importing the data. 178 | 179 | ``` 180 | --db-user= Specify the DB User (Defaults to root) 181 | --db-pass= Specify the DB Password (Defaults to root) 182 | --db-name= Specify the DB Name to import into. (Defaults to default) 183 | --force Force a new database file to be pulled 184 | --remote-db= Specify the remote DB name to pull. (Used with Acquia) 185 | --progress Show import progress 186 | ``` 187 | 188 | __NOTICE__ 189 | Acquia has the ability to host a Drupal multi-site which allow 190 | multiple databases within the Acquia cloud that can be accessed. A 191 | database can be pulled down using the `--remote-db` option where the 192 | remote db is the database within the site's dashboard. 193 | 194 | ## Pulling Files 195 | 196 | Pulling down the files from an environment can sometimes be a lengthy process, especially 197 | if you only want new files or updated files. Using the `rsync` command can help you with 198 | that process, but trying to remember the `rsync` command and options you need for 199 | the files to pull specifically can be challenging. 200 | 201 | ```bash 202 | fin pull files 203 | ``` 204 | 205 | Additional options can be used to help rsync the files locally. 206 | 207 | ``` 208 | --rsync-options= Rsync Options to append. 209 | --files-dir= Directory to sync files with. 210 | Default Drupal: {DOCROOT}/sites/default/files/ 211 | Wordpress Default: {DOCROOT}/wp-content/uploads/ 212 | 213 | ``` 214 | 215 | __NOTICE__ 216 | Due to limitations with WP-CLI, file syncing is not supported for `wordpress` 217 | at this time. Please check back later as we are working on this feature. 218 | 219 | ## Pulling All 220 | 221 | When no options are provided, `fin pull` will run through all items 222 | (code, db, and files) and pull from the provided hosting environment. 223 | All of the arguments will be passed through to the appropriate assets. 224 | 225 | ```bash 226 | fin pull 227 | ``` 228 | 229 | ## Help 230 | 231 | For more information on the `pull` command, including arguments and options, 232 | use the `help` command to get more details. 233 | 234 | ```bash 235 | fin help pull 236 | ``` 237 | 238 | 239 | ``` 240 | Docksal Provider Interaction commands. 241 | 242 | Usage: pull 243 | 244 | Possible Options for Asssets: 245 | init Pull a project repo down 246 | db Export a database from the provider 247 | files Rsync files from remote to local 248 | code Execute a pull on code 249 | (blank) All (Default) 250 | 251 | Options: 252 | --hosting-platform= Platform to interact with. 253 | Options: acquia, pantheon, platform.sh, drush, wp 254 | --hosting-site= Site ID on Provider 255 | --hosting-env= Site Env on Provider 256 | 257 | Extra Options for Code 258 | --sync-git-remote The GIT Remote to pull from. (Defaults to origin) 259 | --sync-git-branch The GIT Branch to pull from. (Defaults to current branch) 260 | 261 | Extra Options for DB 262 | --db-user= Specify the DB User (Defaults to root) 263 | --db-pass= Specify the DB Password (Defaults to root) 264 | --db-name= Specify the DB Name to import into. (Defaults to default) 265 | --force Generate and pull a new db dump, rather than using locally cached in /tmp 266 | --remote-db= Specify the remote DB name to pull. (Used with Acquia) 267 | --progress Show import progress 268 | 269 | Extra Options for Files 270 | --rsync-options= Rsync Options to append. 271 | --files-dir= Directory to sync files with. 272 | Default Drupal: {DOCROOT}/sites/default/files/ 273 | Wordpress Default: {DOCROOT}/wp-content/uploads/ 274 | 275 | Examples: 276 | fin pull init Start a project by pulling the repo from the provider. 277 | --hosting-platform=acquia Provide the Platform Name. 278 | --hosting-site=testsiteid Provide the Site ID. 279 | test_project_directory Specify the directory to clone the project in. 280 | fin pull Pull all items from provider 281 | fin pull db Pull only the db from the provider 282 | fin pull db --remote-db=dbname Pull the db name dbname from the provider. (Acquia Cloud Only) 283 | ``` 284 | -------------------------------------------------------------------------------- /pull/pull: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Find the fin command 4 | fin=`which fin` 5 | 6 | # Source the file to use functions 7 | [[ -f ${fin} ]] && source $fin 8 | 9 | ## Docksal Provider Interaction commands. 10 | ## 11 | ## Usage: pull 12 | ## 13 | ## Possible Options for Asssets: 14 | ## init Pull a project repo down 15 | ## db Export a database from the provider 16 | ## files Rsync files from remote to local 17 | ## code Execute a pull on code 18 | ## (blank) All (Default) 19 | ## 20 | ## Options: 21 | ## --hosting-platform= Platform to interact with. 22 | ## Options: acquia, pantheon, platform.sh, drush, wp 23 | ## --hosting-site= Site ID on Provider 24 | ## --hosting-env= Site Env on Provider 25 | ## 26 | ## Extra Options for Code 27 | ## --sync-git-remote The GIT Remote to pull from. (Defaults to origin) 28 | ## --sync-git-branch The GIT Branch to pull from. (Defaults to current branch) 29 | ## 30 | ## Extra Options for DB 31 | ## --db-user= Specify the DB User (Defaults to root) 32 | ## --db-pass= Specify the DB Password (Defaults to root) 33 | ## --db-name= Specify the DB Name to import into. (Defaults to default) 34 | ## --force Generate and pull a new db dump, rather than using locally cached in /tmp 35 | ## --remote-db= Specify the remote DB name to pull. (Used with Acquia) 36 | ## --progress Show import progress 37 | ## 38 | ## Extra Options for Files 39 | ## --rsync-options= Rsync Options to append. 40 | ## --files-dir= Directory to sync files with. 41 | ## Default Drupal: {DOCROOT}/sites/default/files/ 42 | ## Wordpress Default: {DOCROOT}/wp-content/uploads/ 43 | ## 44 | ## Examples: 45 | ## fin pull init Start a project by pulling the repo from the provider. 46 | ## --hosting-platform=acquia Provide the Platform Name. 47 | ## --hosting-site=testsiteid Provide the Site ID. 48 | ## test_project_directory Specify the directory to clone the project in. 49 | ## fin pull Pull all items from provider 50 | ## fin pull db Pull only the db from the provider 51 | ## fin pull db --remote-db=dbname Pull the db name dbname from the provider. (Acquia Cloud Only) 52 | 53 | # Pull main command for interacting with Hosting Providers. 54 | # $1 - action to run (init, db, files, code) 55 | # $2 - 56 | # - project directory (when ran with init) 57 | # - db name (when ran in with Acquia DB pull) 58 | # $3 - 59 | # - git url (when ran in with Drush / WP init) 60 | # $4 - 61 | # - git branch (when ran in with Drush / WP init) 62 | # $hostingplatform - the hosting platform name. 63 | # $hostingsite - the site id on the hosting platform. 64 | # $hostingenv - the env id on the hosting platform for the site. 65 | provider_pull () 66 | { 67 | # Set Columns to 200 so text wouldn't 68 | # get cut off when testing in CI. 69 | COLUMNS=200 70 | 71 | eval $(parse_params "$@") 72 | 73 | local hostingplatform=${HOSTING_PLATFORM:-${hostingplatform}} 74 | local hostingsite=${HOSTING_SITE:-${hostingsite}} 75 | local hostingenv=${HOSTING_ENV:-${hostingenv}} 76 | 77 | if [[ "${hostingplatform}" == "" || "${hostingsite}" == "" ]]; then 78 | echo-error "Hosting Provider not set up. Following variables must be set: hostingplatform and hostingsite" 79 | exit 1 80 | fi 81 | 82 | hostingplatform=$(echo ${hostingplatform} | tr '[:upper:]' '[:lower:]') 83 | 84 | # Check to see if a support platform is supported. 85 | if [[ " acquia pantheon platformsh drush wp " != *" ${hostingplatform} "* ]]; then 86 | echo-error "Only the following platforms are supported: Acquia (acquia), Pantheon (pantheon), Platform.sh (platformsh), Drupal (drush), and WordPress (wp)." 87 | exit 1 88 | fi 89 | 90 | # Run some checks before continuing. 91 | provider_pull_find_function ${hostingplatform} 'precheck' 92 | 93 | echo-green "Starting provider pull for ${hostingplatform}" 94 | 95 | # Query the provider for the given repo url. Only Pantheon, Platform.sh, and Acquia support this. 96 | # All others will need to do a git clone. 97 | if [[ "${ARGV[0]}" == "init" ]]; then 98 | provider_pull_init 99 | return 100 | fi 101 | 102 | # Execute a Pull On Code. 103 | if [[ "${ARGV[0]}" == "code" ]] || [[ "${ARGV[0]}" == "" ]]; then 104 | provider_pull_code 105 | fi 106 | 107 | # Execute a Pull on DB. 108 | if [[ "${ARGV[0]}" == "db" ]] || [[ "${ARGV[0]}" == "" ]]; then 109 | provider_pull_db 110 | fi 111 | 112 | # Execute a pull on Files. 113 | if [[ "${ARGV[0]}" == "files" ]] || [[ "${ARGV[0]}" == "" ]]; then 114 | provider_pull_files 115 | fi 116 | 117 | echo-green "Pull Completed" 118 | } 119 | 120 | # Provider Pull Init Subcommand 121 | # Used specifically for pulling the repo from a provider. 122 | # $1 - directory to clone the repo into 123 | # $2 - git repo url (optional) 124 | # $3 - git branch url (optional) 125 | provider_pull_init () 126 | { 127 | echo-green "Starting Pull Init Process." 128 | local project_directory=${ARGV[1]:-${hostingsite}} 129 | 130 | # Check to see if project_directory already exists. 131 | if [[ -d ${project_directory} ]]; then 132 | echo-error "Project Directory ${project_directory} already exists." 133 | exit 1 134 | fi 135 | 136 | provider_pull_find_function ${hostingplatform} 'init' 1 "Init function not currently supported for ${hostingplatform}." 137 | echo-green "Pulling code complete." 138 | 139 | # Change into the project directory. 140 | cd "${project_directory}" 141 | 142 | # Check to see if .docksal directory exists. 143 | if [[ ! -d .docksal ]]; then 144 | if [[ "$y" != "y" && "$yes" != "yes" ]]; then 145 | _confirm "Project is not a docksal project. Would you like to generate config?" 146 | fi 147 | config_generate 148 | fi 149 | 150 | # Set the Current Hosting Platform and Hosting Site for project. 151 | config_set "HOSTING_PLATFORM=${hostingplatform}" > /dev/null 152 | config_set "HOSTING_SITE=${hostingsite}" > /dev/null 153 | config_set "HOSTING_ENV=${hostingenv}" > /dev/null 154 | addon_file_path="$(addon_get_path init)" 155 | if [[ ! -z "$addon_file_path" ]] && [[ -x "$addon_file_path" ]]; then 156 | if _confirm "Init command found for project run?" --no-exit; then 157 | addon_execute "$addon_file_path" 158 | fi 159 | fi 160 | } 161 | 162 | # Generic Precheck function to check if ${hostingenv} variable is set. 163 | provider_pull_precheck () 164 | { 165 | # After Init Process Let's Check to Make sure hostingenv has been set. 166 | if [[ "${hostingenv}" == "" ]]; then 167 | echo-error "hostingenv variable is required to continue." 168 | exit 1 169 | fi 170 | } 171 | 172 | # Provider Pull Code Subcommand 173 | # Used specifically for pulling the repo from a provider. 174 | provider_pull_code () 175 | { 176 | echo-green "Pulling code" 177 | provider_pull_find_function ${hostingplatform} 'code' 1 178 | if_failed_error "Error pulling code from ${hostingplatform}." 179 | echo-green "Code Pull Successful" 180 | } 181 | 182 | # Provider Pull DB Subcommand 183 | # Used specifically for pulling the db from a provider. 184 | # $1 - database name to connect to 185 | provider_pull_db () 186 | { 187 | if [[ "$y" != "y" && "$yes" != "yes" ]]; then 188 | _confirm "Existing database will be truncated, Continue?" 189 | fi 190 | 191 | echo-green "Pulling DB" 192 | 193 | # Get database environment variables. 194 | DB_USER=${MYSQL_USER:-root} 195 | DB_PASS=${MYSQL_PASSWORD:-root} 196 | DB_NAME=${MYSQL_DATABASE:-default} 197 | 198 | # Variables to set for local use. 199 | local __db_user="${dbuser:-${DB_USER}}" 200 | local __db_password="${dbpass:-${DB_PASS}}" 201 | local __db_database="${dbname:-${DB_NAME}}" 202 | 203 | # Set the db file that will be stored within the cli container 204 | local db_file="/tmp/${__db_database}.${hostingenv}.${hostingsite}.sql.gz" 205 | # Check to see if the file exists in the cli container 206 | local file_exists=$(_exec "ls -1 /tmp/** 2> /dev/null | grep \"${db_file}\"\$ | wc -l | tr -d '[:space:]'") 207 | # Get the time of that file within the cli container. 208 | local file_time=$(_exec "find ${db_file} -mmin +360 2> /dev/null | tr -d '[:space:]'") 209 | # Get the time from 24 hours ago. 210 | local yesterday=$(_exec date --date='yesterday' "+%Y-%m-%d %H:%M:%S"); 211 | 212 | # Use cli's pv for progress if requested. 213 | local progress_pipe='cat' 214 | if ( [[ "$progress" == "progress" ]] ); then 215 | progress_pipe='pv' 216 | fi 217 | 218 | # Check to see if file doesn't exist, or if file exists and is older, or using force flag 219 | if ( [[ "${file_exists}" == "0" ]] && [[ "${file_time}" == "" ]] ) || ( [[ "${file_exists}" > "0" ]] && [[ "${file_time}" != "" ]] ) || [[ "${force}" == "force" ]]; then 220 | # Check to see if File Is Older than 1 hour 221 | if ( [[ "${file_exists}" > "0" ]] && [[ "${file_time}" != "" ]] ) || [[ "${force}" == "force" ]]; then 222 | echo -e "${acqua}Cached DB file needs updating${NC}" 223 | echo -e "${acqua}Removing old database file${NC}" 224 | _exec rm -f "${db_file}" 225 | fi 226 | 227 | echo -e "${acqua}Pulling new database file...${NC}" 228 | provider_pull_find_function ${hostingplatform} 'db' 1 229 | else 230 | echo-green "Cached DB file still valid found and using to import" 231 | fi 232 | 233 | # ToDo: Do we need to account for Multi-Site and other DB Names? 234 | 235 | # Import the Database. 236 | # Truncate the existing db. 237 | echo -e "${acqua}Truncating Existing Database${NC}" 238 | mysql_db_truncate "${dbname}" > /dev/null 239 | # Execute ZCAT on the db file and import into mysql database. 240 | echo -e "${acqua}Importing DB file...${NC}" 241 | _exec "${progress_pipe} ${db_file} | zcat | mysql -u ${__db_user} -p${__db_password} -h db ${__db_database}" 242 | if_failed_error "Error importing DB" 243 | echo-green "DB Pull Successful" 244 | } 245 | 246 | # Provider Pull Files Subcommand 247 | # Used specifically for pulling the db from a provider. 248 | provider_pull_files () 249 | { 250 | if [[ "$y" != "y" && "$yes" != "yes" ]]; then 251 | _confirm "The following will delete all files within the files directory, Continue?" 252 | fi 253 | echo -e "${acqua}Pulling Files...${NC}" 254 | 255 | # Default directory for Drupal Files. 256 | local drupal_files="sites/default/files/" 257 | # Default directory for WordPress Files. 258 | local wordpress_files="wp-content/uploads/" 259 | 260 | # Default to Drupal Specifically. 261 | local default_dir=${drupal_files} 262 | # If find a wp-config.php file in the docroot set to wordpress_files 263 | if [[ -f ${PROJECT_ROOT}/${DOCROOT}/wp-config.php ]]; then 264 | default_dir=${wordpress_files} 265 | fi 266 | 267 | # Allow for this to be modified with the --filesdir option. 268 | filesdir=${filesdir:-$default_dir} 269 | # Exclude specific items by default. Allow other rsync options to be included using --rsync-options flag. 270 | local rsyncoptions="${rsyncoptions} --exclude='styles' --exclude='css' --exclude='js'" 271 | provider_pull_find_function ${hostingplatform} 'files' 1 272 | echo-green "File Pull Complete" 273 | } 274 | 275 | # GENERIC PROVIDER FUNCTIONS 276 | 277 | # Generic function for searching if function exists and executing. 278 | # Searches for a function that is in the format of provider_pull_${PROVIDER}_${ACTION} 279 | # $1 - the provider machine name to check 280 | # $2 - the action to perform for the provider (Examples db, files, code) 281 | # $3 - any value to indicate this function is required to exist 282 | # $4 - the message to display if this function cannot be found 283 | provider_pull_find_function () 284 | { 285 | # Providers name to attach to function. 286 | local provider=$1 287 | # Action for provider. 288 | local action=$2 289 | # Is this function required. Any value is acceptable. 290 | local required=$3 291 | # If required what is the error message if not found. 292 | local required_message=${4:-"Pulling ${action} is currently not supported for ${provider}."} 293 | 294 | # Check for help function for specific command 295 | local pull_function="provider_pull_${provider}_${action}" 296 | type "${pull_function}" >/dev/null 2>&1 297 | [[ $? -eq 0 ]] && ${pull_function} || ( [[ -n $required ]] && echo "${required_message}" ) 298 | } 299 | 300 | # Runs a git pull on the project repo. 301 | provider_pull_generic_git_pull () 302 | { 303 | local git_remote=${syncgitremote:-origin} 304 | # Trim \r from output (necessary on Windows) 305 | local current_branch=$(_exec "git rev-parse --abbrev-ref HEAD" | tr -d '\r') 306 | local git_branch=${syncgitbranch:-$current_branch} 307 | echo -e "${acqua}Pulling Code From ${git_remote} - ${git_branch}${NC}" 308 | _exec -T "git pull -q ${git_remote} ${git_branch} 2>/dev/null" 309 | if_failed_error "Error Pulling Code from ${git_remote} - ${git_branch}" 310 | } 311 | 312 | # Runs a generic drush rsync command. 313 | provider_pull_generic_drush_rsync () 314 | { 315 | cd ${PROJECT_ROOT}/${DOCROOT} 316 | echo -e "${acqua}Downloading Files from ${hostingsite} on the ${hostingenv} environment${NC}" 317 | local drush_version=$(_exec "drush version --format=string | cut -d'.' -f1" | sed "s/[[:space:]]//") 318 | local separator="" 319 | if [[ "$drush_version" == "9" ]]; then 320 | separator="--" 321 | fi 322 | local rsync_filesdir 323 | rsync_filesdir="/var/www/${DOCROOT}/${filesdir}" 324 | _exec drush -q -y rsync \ 325 | @${hostingsite}.${hostingenv}:%files \ 326 | ${rsync_filesdir} \ 327 | ${separator} \ 328 | --delete \ 329 | ${rsyncoptions} 2>/dev/null 330 | if_failed_error "Error Downloading Files from ${hostingsite} on the ${hostingenv} environment" 331 | } 332 | 333 | # Generic Git Clone for Init Function 334 | # $1 - git repo to clone 335 | # $2 - repo branch to checkout 336 | provider_pull_generic_init () 337 | { 338 | local repo_url="$1" 339 | if [[ -z "${repo_url}" ]]; then 340 | echo-error "Repository URL required for Drush Project to init." 341 | exit 1 342 | fi 343 | local repo_checkout=${2:-"master"} 344 | echo -e "${acqua}Cloning Site Locally: ${hostingsite} - ${hostingenv} in ${project_directory}${NC}" 345 | run_cli "git clone -q --depth=1 --branch='${repo_checkout}' ${repo_url} ${project_directory} 2>/dev/null" 346 | if_failed_error "Error Cloning Repo" 347 | } 348 | 349 | # ACQUIA PROVIDER FUNCTIONS 350 | 351 | # Check to see if acquia keys have been set. 352 | provider_pull_acquia_precheck () 353 | { 354 | if [[ -z "${SECRET_ACAPI_EMAIL}" ]] || [[ -z "${SECRET_ACAPI_KEY}" ]]; then 355 | echo-error "SECRET_ACAPI_EMAIL and SECRET_ACAPI_KEY must be set in order to work with Acquia." 356 | exit 1; 357 | fi 358 | 359 | if [[ "${ARGV[0]}" == "init" ]]; then 360 | return; 361 | fi 362 | 363 | provider_pull_precheck 364 | } 365 | 366 | # Init process to pull code from acquia. 367 | provider_pull_acquia_init () 368 | { 369 | local acquia_alias_update="drush8 -q acquia-update; [[ -d "~/.drush/site-aliases" ]] && mv ~/.drush/*.aliases.* ~/.drush/site-aliases/" 370 | 371 | # Set hostingenv to dev if none are set. 372 | hostingenv=${hostingenv:-dev} 373 | # Get the repo url for the specific environment.provider_pull_platformsh_files 374 | local repo_url 375 | repo_url=$(run_cli -T "${acquia_alias_update}; drush8 @${hostingsite}.${hostingenv} ac-site-info | grep 'vcs_url' | awk '{print \$3}' | tr -d '[:space:]'") 376 | if_failed_error "Error accessing Acquia Cloud API to get Project Git Repo" 377 | # Get the branch for the specific environment. 378 | local repo_checkout 379 | repo_checkout=$(run_cli -T "${acquia_alias_update}; drush8 @${hostingsite}.${hostingenv} ac-environment-info | grep 'vcs_path' | awk '{print \$3}' | sed 's/tags\///g' | tr -d '[:space:]'") 380 | if_failed_error "Error accessing Acquia Cloud API to get ${hostingenv} info." 381 | 382 | echo -e "${acqua}Cloning Acquia Site Locally: ${hostingsite} - ${hostingenv} in ${project_directory}${NC}" 383 | # Run a git clone to get the specific repo. 384 | run_cli "git clone -q --depth=1 --branch='${repo_checkout}' ${repo_url} ${project_directory}" 2>/dev/null 385 | if_failed_error "Error cloning Acquia Project." 386 | } 387 | 388 | # Pull process to pull files from Acquia. 389 | provider_pull_acquia_files () 390 | { 391 | local acquia_alias_update="drush8 -q acquia-update; [[ -d "~/.drush/site-aliases" ]] && mv ~/.drush/*.aliases.* ~/.drush/site-aliases/" 392 | 393 | # Update Acquia Drush Aliases in container. 394 | _exec "${acquia_alias_update}" 395 | 396 | # Execute a generic rsync on files from remote. 397 | provider_pull_generic_drush_rsync 398 | } 399 | 400 | # Pull process to pull db from Acquia. 401 | provider_pull_acquia_db () 402 | { 403 | local acquia_alias_update="drush8 -q acquia-update; [[ -d "~/.drush/site-aliases" ]] && mv ~/.drush/*.aliases.* ~/.drush/site-aliases/" 404 | 405 | # Update Acquia Drush Aliases in container. 406 | _exec "${acquia_alias_update}" 407 | 408 | # TODO: Allow for all databases to be downloaded. drush ac-database-list will list all databases for a site. 409 | # Following will grab all databases for a site. 410 | # local acquia_dbs=$(_exec drush @${hostingsite}.${hostingenv} ac-database-list | awk '{print $3}') 411 | 412 | # Default Acquia DB Name to project name. 413 | local acquia_db_name="${remotedb:-${hostingsite}}" 414 | if [[ -z "${acquia_db_name}" ]]; then 415 | echo-error "Database name is required." 416 | exit 1 417 | fi 418 | 419 | local query 420 | query=$(_exec drush8 @${hostingsite}.${hostingenv} ac-database-instance-backup-list ${acquia_db_name}) 421 | if_failed_error "Error retrieving list of backups from Acquia for ${hostingsite} - ${hostingenv} for database ${acquia_db_name}" 422 | 423 | # Returns timestamp of last backup. 424 | local last_date 425 | last_date=$(printf "${query}" | grep started | tail -n 1 | awk '{ print $3 }' | tr -d '[:space:]') 426 | if [[ "${last_date}" != "" ]]; then 427 | # Convert Date To Y-m-d H:m:s format 428 | last_date=$(_exec date --date=@${last_date} "+%Y-%m-%d %H:%M:%S") 429 | fi 430 | 431 | # If Last backup was more than 24 hours ago. Create one. 432 | if [[ "${last_date}" < "${yesterday}" ]] || [[ "$force" == "force" ]]; then 433 | # Create backup on Acquia through Cloud API. 434 | echo -e "${acqua}Creating new backup on Acquia for ${hostingsite} - ${hostingenv} for database ${acquia_db_name}${NC}" 435 | _exec drush8 -q @${hostingsite}.${hostingenv} ac-database-instance-backup ${acquia_db_name} 436 | if_failed_error "Error creating backup on Acquia for ${acquia_db_name}." 437 | echo -e "${acqua}Backup queued on Acquia for ${hostingsite} - ${hostingenv} for database ${acquia_db_name} waiting 10 seconds to finish${NC}" 438 | # Sleep for 10 seconds wait for backup to finish. 439 | sleep 10 440 | # Requery to get a new list of backups. 441 | query=$(_exec drush8 @${hostingsite}.${hostingenv} ac-database-instance-backup-list ${acquia_db_name}) 442 | if_failed_error "Error retrieving list of backups from Acquia on site ${hostingsite} on environment ${hostingenv} for database ${acquia_db_name}" 443 | else 444 | echo -e "${acqua}Using latest backup from Acquia for ${hostingsite} - ${hostingenv} for database ${acquia_db_name}${NC}" 445 | fi 446 | 447 | # Returns id of last backup. 448 | local last_id=$(printf "${query}" | grep "^ id" | tail -n 1 | awk '{ print $3 }' | tr -d '[:space:]') 449 | # Use Drush to download the latest file using the Acquia Cloud API. 450 | echo -e "${acqua}Downloading backup from Acquia for ${hostingsite} - ${hostingenv} for database ${acquia_db_name}${NC}" 451 | _exec "drush8 -q @${hostingsite}.${hostingenv} ac-database-instance-backup-download ${acquia_db_name} ${last_id} | ${progress_pipe} > ${db_file}" 452 | if_failed_error "Error Downloading backup from Acquia for ${hostingsite} - ${hostingenv} for database ${acquia_db_name}" 453 | } 454 | 455 | # Pull process to pull files from Acquia. 456 | provider_pull_acquia_code () 457 | { 458 | # Execute a generic git pull on code. 459 | provider_pull_generic_git_pull 460 | } 461 | 462 | # PANTHEON PROVIDER FUNCTIONS 463 | 464 | # Check to see if tokens are set correctly. 465 | provider_pull_pantheon_precheck () 466 | { 467 | if [[ -z "${SECRET_TERMINUS_TOKEN}" ]]; then 468 | echo-error "SECRET_TERMINUS_TOKEN must be set in order to work with Pantheon." 469 | exit 1; 470 | fi 471 | 472 | if [[ "${ARGV[0]}" == "init" ]]; then 473 | return; 474 | fi 475 | 476 | provider_pull_precheck 477 | } 478 | 479 | # Init process to pull code from Pantheon 480 | provider_pull_pantheon_init () 481 | { 482 | # If hostingenv isn't set default to dev. 483 | hostingenv=${hostingenv:-dev} 484 | # Set the BRANCH to be what the hostingenv is. 485 | local repo_checkout=${hostingenv} 486 | # The URL for the repo to clone. 487 | local repo_url 488 | repo_url=$(run_cli -T "terminus connection:info ${hostingsite}.dev --field=\"Git Command\" | awk '{print \$3}'") 489 | if_failed_error "Error retrieving Git URL from Pantheon" 490 | 491 | if [[ "${hostingenv}" == 'dev' ]]; then 492 | # If hostingenv is set to dev set the repo_checkout to be master. 493 | repo_checkout='master' 494 | elif [[ "${hostingenv}" == 'test' ]] || [[ "${hostingenv}" == "live" ]]; then 495 | # If hostingenv is test or live get the latest tag for the repo. 496 | repo_checkout=$(run_cli -T "git ls-remote --exit-code -t ${repo_url} | grep 'refs/tags/pantheon_${hostingenv}_' | awk '{print $2}' | cut -d'/' -f3 | sort -k1.15n | grep '[0-9]$' | tail -1 | tr -d '[:space:]'") 497 | if_failed_error "Error getting latest tag for ${hostingenv} on Pantheon repo" 498 | fi 499 | 500 | echo -e "${acqua}Cloning Pantheon Site Locally: ${hostingsite} - ${hostingenv} in ${project_directory}${NC}" 501 | # Run git clone and checkout the provided branch. 502 | run_cli "git clone -q --depth=1 --branch='${repo_checkout}' ${repo_url} ${project_directory}" 503 | if_failed_error "Error cloning Pantheon project ${hostingsite} - ${hostingenv} in ${project_directory}" 504 | } 505 | 506 | # Pull process to pull files from Pantheon. 507 | # Need to run a custom rsync command as every environment is different. 508 | provider_pull_pantheon_files () 509 | { 510 | # Get the SFTP Hostname from Site's Info. 511 | local host_url 512 | host_url=$(_exec -T "terminus connection:info ${hostingsite}.${hostingenv} --field=\"SFTP Command\" 2>/dev/null | awk '{print \$4}'") 513 | if_failed_error "Could not communicate with Pantheon. Check connection and SECRET_TERMINUS_TOKEN is set to an active token." 514 | echo -e "${acqua}Downloading Files from ${hostingsite} on the ${hostingenv} through Pantheon${NC}" 515 | # Execute a rsync using Pantheon recommended Options. 516 | _exec "rsync \ 517 | -rlz \ 518 | --copy-unsafe-links \ 519 | --size-only \ 520 | --ipv4 \ 521 | --progress \ 522 | -e 'ssh -p 2222' \ 523 | ${host_url}:files/ \ 524 | /var/www/${DOCROOT}/${filesdir} \ 525 | --delete \ 526 | ${rsyncoptions}" 527 | if_failed_error "Could not rsync files from Pantheon. Confirm that SSH Key has been added to Pantheon account and added to Docksal SSH-Agent." 528 | } 529 | 530 | # Pull process to pull db from Pantheon. 531 | # Pull from Pantheon backup system so that can pull the live db and not impact the site performance. 532 | provider_pull_pantheon_db () 533 | { 534 | # Get Time of Last Backup In Pantheon. 535 | local last_backup 536 | last_backup=$(_exec -T "terminus backup:list ${hostingsite}.${hostingenv} --element=db --format=list --field=date | head -n 1") 537 | if_failed_error "Error retrieving list of backups from Pantheon for ${hostingsite} on the ${hostingenv} environment" 538 | if [[ "last_backup" == "" ]] || [[ "${last_backup}" < "${yesterday}" ]] || [[ "$force" == "force" ]]; then 539 | # If last backup does not exist or is older than 24 hours create new one. 540 | echo -e "${acqua}Creating new backup on Pantheon for ${hostingsite} on the ${hostingenv} environment${NC}" 541 | _exec terminus backup:create ${hostingsite}.${hostingenv} --element=db 542 | if_failed_error "Error creating backup on Pantheon for ${hostingsite} on the ${hostingenv} environment" 543 | fi 544 | # Download backup with Terminus to given location. 545 | echo -e "${acqua}Downloading database backup from Pantheon for ${hostingsite} on the ${hostingenv} environment${NC}" 546 | _exec terminus backup:get ${hostingsite}.${hostingenv} --element="db" --to="${db_file}" 547 | if_failed_error "Error Downloading backup from Pantheon for ${hostingsite} on the ${hostingenv} environment" 548 | } 549 | 550 | # Pull process to pull files from Pantheon. 551 | provider_pull_pantheon_code () 552 | { 553 | # Execute a generic git pull on code. 554 | provider_pull_generic_git_pull 555 | } 556 | 557 | # PLATFORM.SH PROVIDER FUNCTIONS 558 | 559 | # Check to see if tokens are set correctly. 560 | provider_pull_platformsh_precheck () 561 | { 562 | if [[ -z "${SECRET_PLATFORMSH_CLI_TOKEN}" ]]; then 563 | echo-error "SECRET_PLATFORMSH_CLI_TOKEN must be set in order to work with Platform.sh." 564 | exit 1 565 | fi 566 | 567 | if [[ "${ARGV[0]}" == "init" ]]; then 568 | return; 569 | fi 570 | 571 | provider_pull_precheck 572 | } 573 | 574 | # Init process to pull code from Platform.sh 575 | provider_pull_platformsh_init () 576 | { 577 | # If hostingenv isn't set use master as default. 578 | hostingenv=${hostingenv:-master} 579 | echo -e "${acqua}Cloning Platform.sh Site Locally: ${hostingsite} - ${hostingenv} in ${project_directory}${NC}" 580 | run_cli "platform project:get -q --environment=${hostingenv} ${hostingsite} ${project_directory}" 581 | if_failed_error "Could not communicate with Platform.sh. Check connection and SECRET_PLATFORMSH_CLI_TOKEN is set to an active token." 582 | } 583 | 584 | # Pull process to pull files from Platform.sh 585 | provider_pull_platformsh_files () 586 | { 587 | local host_url 588 | host_url=$(_exec -T "platform ssh --pipe --project=${hostingsite} --environment=${hostingenv} 2>/dev/null"); 589 | if_failed_error "Could not communicate with Platform.sh. Check connection and SECRET_PLATFORMSH_CLI_TOKEN is set to an active token." 590 | echo -e "${acqua}Downloading Files from ${hostingsite} on the ${hostingenv} through Platform.sh${NC}" 591 | _exec rsync \ 592 | -rlz \ 593 | --copy-unsafe-links \ 594 | --size-only \ 595 | --ipv4 \ 596 | --progress \ 597 | ${host_url}:/app/${DOCROOT}/${filesdir} \ 598 | /var/www/${DOCROOT}/${filesdir} \ 599 | --delete \ 600 | ${rsyncoptions} 601 | if_failed_error "Could not rsync files from Platform.sh. Confirm that SSH Key has been added to Platform.sh account and added to Docksal SSH-Agent." 602 | } 603 | 604 | # Pull process to pull db from Platform.sh 605 | provider_pull_platformsh_db () 606 | { 607 | echo -e "${acqua}Downloading database backup from Platform.sh for ${hostingsite} on the ${hostingenv} environment${NC}" 608 | _exec "platform -q db:dump -p ${hostingsite} -e ${hostingenv} --gzip --stdout | ${progress_pipe} > ${db_file}" 609 | if_failed_error "Error Downloading backup from Platform.sh for ${hostingsite} on the ${hostingenv} environment" 610 | } 611 | 612 | # Pull process to pull code from Platform.sh. 613 | provider_pull_platformsh_code () 614 | { 615 | syncgitremote=${syncgitremote:-"platform"} 616 | # Execute a generic git pull on code. 617 | provider_pull_generic_git_pull 618 | } 619 | 620 | # DRUSH PROVIDER FUNCTIONS 621 | 622 | # Execute a generic git clone on the provided. 623 | provider_pull_drush_init () 624 | { 625 | provider_pull_generic_init "${ARGV[2]}" "${ARGV[3]}" 626 | if_failed_error "Could not communicate with Drush site repo. Check connection and try again." 627 | } 628 | 629 | # Use Generic Precheck function to makes sure env is set. 630 | provider_pull_drush_precheck () 631 | { 632 | if [[ "${ARGV[0]}" == "init" ]]; then 633 | return; 634 | fi 635 | 636 | provider_pull_precheck 637 | } 638 | 639 | # Execute a generic rsync on files from remote. 640 | provider_pull_drush_files () 641 | { 642 | provider_pull_generic_drush_rsync 643 | } 644 | 645 | # Pull database from the drush provider using the alias. Exclude cache, session, and watchdog data. 646 | provider_pull_drush_db () 647 | { 648 | cd ${PROJECT_ROOT}/${DOCROOT} 649 | # Execute drush sql-dump on remote host and exclude cache, session, watchdog tables. 650 | echo -e "${acqua}Creating database export for @${hostingsite}.${hostingenv}${NC}" 651 | # Drush appends a .gz when using the --gzip option. Remove .gz extension. 652 | local db_save=$(echo $db_file | sed 's/\.gz//') 653 | _exec drush -q -y @${hostingsite}.${hostingenv} sql-dump --structure-tables-list="cache,cache_*,sessions,watchdog" --gzip --result-file="${db_save}.export" 2>/dev/null 654 | if_failed_error "Error accessing Drush Site @${hostingsite}.${hostingenv} to create database export" 655 | # Rsync database file locally 656 | echo -e "${acqua}Downloading database export for @${hostingsite}.${hostingenv}${NC}" 657 | _exec drush -q -y rsync @${hostingsite}.${hostingenv}:${db_save}.export.gz ${db_file} 2>/dev/null 658 | if_failed_error "Error accessing Drush Site @${hostingsite}.${hostingenv} to download database export" 659 | } 660 | 661 | # Pull process to pull files from Drush. 662 | provider_pull_drush_code () 663 | { 664 | provider_pull_generic_git_pull 665 | } 666 | 667 | # WORDPRESS PROVIDER FUNCTIONS 668 | 669 | # Execute a generic git clone on the provided. 670 | provider_pull_wp_init () 671 | { 672 | provider_pull_generic_init "${ARGV[2]}" "${ARGV[3]}" 673 | if_failed_error "Could not communicate with WP site repo. Check connection and try again." 674 | } 675 | 676 | # Pull db from provider using the wp db export function. 677 | provider_pull_wp_db () 678 | { 679 | cd ${PROJECT_ROOT}/${DOCROOT} 680 | echo -e "${acqua}Downloading database export for @${hostingsite}${NC}" 681 | _exec "wp @${hostingsite} db export --add-drop-table - | gzip > ${db_file}" 682 | if_failed_error "Error accessing WordPress Site @${hostingsite} to create database export" 683 | } 684 | 685 | # Pull process to pull code from WP-CLI. 686 | provider_pull_wp_code () 687 | { 688 | # Execute a generic git pull on code. 689 | provider_pull_generic_git_pull 690 | } 691 | 692 | # Pull process to pull files from WP-CLI 693 | provider_pull_wp_files () 694 | { 695 | # Show Error as currently not supported. 696 | echo-warning "File Pull for WordPress is currently not supported." 697 | } 698 | 699 | # Only load the project config if $1 isn't init. 700 | if [[ "$1" != "init" ]]; then 701 | load_configuration 702 | fi 703 | 704 | provider_pull "$@" -------------------------------------------------------------------------------- /rabbitmq/README.md: -------------------------------------------------------------------------------- 1 | # RabbitMQ 2 | 3 | Easily install RabbitMQ service to the project 4 | 5 | ```bash 6 | fin addon install rabbitmq 7 | ``` 8 | 9 | ## Usage once installed 10 | 11 | - `fin rabbitmq disable` to disable 12 | - `fin rabbitmq enable` to re-enable 13 | 14 | ## Host and Port 15 | 16 | From within your project, the rabbitmq service will be available at `rabbitmq:5672` 17 | 18 | ## URL 19 | 20 | After the installation RabbitMQ Management UI will be available at `http://rabbitmq-.docksal` with the default username and password of `guest / guest`. 21 | -------------------------------------------------------------------------------- /rabbitmq/conf/rabbitmq.yml: -------------------------------------------------------------------------------- 1 | # rabbitMQ 2 | rabbitmq: 3 | hostname: rabbitmq 4 | image: rabbitmq:3-management 5 | labels: 6 | - io.docksal.virtual-host=rabbitmq-${VIRTUAL_HOST} 7 | - io.docksal.virtual-port=15672 8 | dns: 9 | - ${DOCKSAL_DNS1} 10 | - ${DOCKSAL_DNS2} 11 | -------------------------------------------------------------------------------- /rabbitmq/rabbitmq: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERSION="1.0" 4 | 5 | ## Enable/disable rabbitmq for current project 6 | ## 7 | ## Sub-commands: 8 | ## enable Enable rabbitmq 9 | ## disable Disable rabbitmq 10 | 11 | red='\033[0;31m' 12 | green='\033[0;32m' 13 | green_bg='\033[42m' 14 | yellow='\033[1;33m' 15 | NC='\033[0m' 16 | 17 | echo-red () { echo -e "${red}$1${NC}"; } 18 | echo-green () { echo -e "${green}$1${NC}"; } 19 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 20 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 21 | die () { echo -e "$1"; exit 1; } 22 | 23 | DOCKSAL_YML=".docksal/docksal.yml" 24 | DOCKSAL_YML_NEW=".docksal/docksal.yml.new" 25 | DOCKSAL_ENV=".docksal/docksal.env" 26 | DOCKSAL_STACKS="$HOME/.docksal/stacks" 27 | RABBITMQ_YML="$ADDON_ROOT/conf/rabbitmq.yml" 28 | 29 | 30 | ## Example addon 31 | ## 32 | ## This is an example addon. It's purpose is to show sample folder structure 33 | ## and concepts of creating addons. 34 | ## 35 | ## fin example 36 | ## 37 | ## Usage: 38 | ## hello Say Hello! 39 | ## version Display addon version 40 | 41 | #----------------------------------- YML & config functions ------------------------------------------ 42 | 43 | # Check whether given string is in config 44 | # $1 - string to find 45 | in_config () 46 | { 47 | fin config 2>/dev/null | grep "$1" >/dev/null 48 | } 49 | 50 | # Check that docksal.yml is valid 51 | yml_is_valid () 52 | { 53 | [[ -f "$DOCKSAL_YML" ]] && $(cat "$DOCKSAL_YML" 2>/dev/null | grep "services" >/dev/null) 54 | } 55 | 56 | # Prepares stack to editing docksal.yml config 57 | yml_prepare () 58 | { 59 | # Get yml version to use for a new file from existing stacks 60 | YML_VERSION=$(head "$DOCKSAL_STACKS/volumes-bind.yml" | grep "version") 61 | YML_DEFAULT_BODY="${YML_VERSION}\nservices:" 62 | NEW_STACK='DOCKSAL_STACK="default"' 63 | 64 | # Source docksal.env 65 | source "$DOCKSAL_ENV" >/dev/null 2>&1 66 | 67 | # If DOCKSAL_STACK is not set, then... 68 | if [[ -z "$DOCKSAL_STACK" ]]; then 69 | echo " Configuring to use DOCKSAL_STACK=\"default\"..." 70 | # ...set stack to default so we could use docksal.yml 71 | echo -e "$NEW_STACK" >> "$DOCKSAL_ENV" 72 | fi 73 | 74 | # Create docksal.yml if needed 75 | yml_is_valid || echo -e "$YML_DEFAULT_BODY" > "$DOCKSAL_YML" 76 | } 77 | 78 | # Install tool required to edit yml from command line 79 | yml_install_tools () 80 | { 81 | fin exec "which yaml >/dev/null 2>&1 || npm install --silent -g yaml-cli >/dev/null" 82 | } 83 | 84 | # Add a service to docksal.yml from another yml 85 | # $1 - filename of yml get service from 86 | yml_add_service () 87 | { 88 | [[ -z "$1" ]] && echo "File not found: $1" && return 1 89 | # TODO: use https://www.npmjs.com/package/merge-yaml 90 | cat "$1" >> "$DOCKSAL_YML" 91 | } 92 | 93 | # Removes a service from docksal.yml 94 | # $1 - service name 95 | yml_remove_service () 96 | { 97 | [[ -z "$1" ]] && echo "Provide a service name to remove" && return 1 98 | local service="$1" 99 | read -r -d '' CODE_TO_EXEC <<-EOF 100 | yaml set $DOCKSAL_YML services.$service | grep -v '$service:' | tee $DOCKSAL_YML_NEW >/dev/null; 101 | [[ -z "\$(yaml get $DOCKSAL_YML_NEW services)" ]] && rm '$DOCKSAL_YML' || mv $DOCKSAL_YML_NEW $DOCKSAL_YML 102 | EOF 103 | # Remove service. If no services left after that, then remove docksal.yml 104 | fin exec "$CODE_TO_EXEC" 105 | } 106 | 107 | #-------------------------------------- rabbitmq functions --------------------------------------------- 108 | 109 | # Set/remove proper setting into php.ini 110 | # $1 - enable/disable 111 | # Enable container and settings 112 | rabbitmq_enable () 113 | { 114 | # Check that rabbitmq is not already enabled 115 | if (in_config "image: rabbitmq\/rabbitmq"); then 116 | echo " rabbitmq support is already enabled." && exit 117 | fi 118 | 119 | echo " Enabling rabbitmq..." 120 | yml_prepare 121 | # Add rabbitmq service to docksal.yml 122 | yml_add_service "$RABBITMQ_YML" 123 | # Apply stack changes. 124 | fin stop cli 125 | fin up 126 | } 127 | 128 | # Disable container and settings 129 | rabbitmq_disable () 130 | { 131 | echo " Running checks..." 132 | # Make sure cli container is running 133 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 134 | echo " ERROR: Start the project with fin start first" && exit 1 135 | fi 136 | 137 | # Make sure rabbitmq is installed 138 | if ! in_config "image: rabbitmq\/rabbitmq"; then 139 | echo " rabbitmq support is not enabled at the moment." && exit 140 | fi 141 | 142 | echo " Preparing to remove rabbitmq service..." 143 | yml_install_tools 144 | # Remove rabbitmq service from docksal.yml 145 | yml_remove_service "rabbitmq" 146 | # Apply stack changes 147 | COMPOSE_FILE="" fin stop cli 148 | fin up 149 | } 150 | 151 | #------------------------------------------ Runtime ----------------------------------------------- 152 | 153 | cd "$PROJECT_ROOT" 154 | 155 | case "$1" in 156 | enable) 157 | rabbitmq_enable 158 | ;; 159 | disable) 160 | rabbitmq_disable 161 | ;; 162 | *) 163 | echo "Usage: fin rabbitmq " 164 | exit 1 165 | ;; 166 | esac 167 | -------------------------------------------------------------------------------- /rabbitmq/rabbitmq.filelist: -------------------------------------------------------------------------------- 1 | # Hooks 2 | rabbitmq.pre-install 3 | rabbitmq.post-install 4 | rabbitmq.pre-uninstall 5 | 6 | # Container config 7 | conf/rabbitmq.yml 8 | -------------------------------------------------------------------------------- /rabbitmq/rabbitmq.post-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin rabbitmq enable 4 | 5 | echo -e "${green}RabbitMQ Management:${NC} http://rabbitmq-$VIRTUAL_HOST" 6 | -------------------------------------------------------------------------------- /rabbitmq/rabbitmq.pre-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Check Docksal running 4 | if [[ "$DOCKER_RUNNING" != "true" ]]; then 5 | echo "[PRE-INSTALL] ERROR: Docksal and project should be running" 6 | exit 1 7 | fi 8 | 9 | # Check Docksal running 10 | if [[ "$ADDON_GLOBAL" == "true" ]]; then 11 | echo -e "[PRE-INSTALL] ERROR: RabbitMQ addon should not be installed globally" 12 | exit 1 13 | fi 14 | 15 | 16 | # Check project running 17 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 18 | echo "[PRE-INSTALL] ERROR: Start the project with fin start first" 19 | exit 1 20 | fi 21 | 22 | # Get fin config 23 | fin_config=$(fin config) 24 | if [[ $? != 0 ]]; then 25 | echo "[PRE-INSTALL] ERROR: 'fin config' command was not successful. Check your fin config" 26 | exit 1 27 | fi 28 | 29 | # Check there is no rabbitmq already 30 | if (echo "$fin_config" | grep "image: rabbitmq:3-management"); then 31 | echo "[PRE-INSTALL] ERROR: RabbitMQ seems to be already enabled for this project" 32 | exit 1 33 | fi 34 | 35 | # Check there is no pma already 36 | if (echo "$fin_config" | grep " rabbitmq:"); then 37 | echo "[PRE-INSTALL] ERROR: Container named 'pma' already exists. Remove it to continue." 38 | exit 1 39 | fi 40 | 41 | 42 | # All good 43 | exit 0 44 | -------------------------------------------------------------------------------- /rabbitmq/rabbitmq.pre-uninstall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin rabbitmq disable 4 | -------------------------------------------------------------------------------- /redis/README.md: -------------------------------------------------------------------------------- 1 | # Redis 2 | 3 | Easily install Redis to the project 4 | 5 | ```bash 6 | fin addon install redis 7 | ``` 8 | 9 | ## Usage once installed 10 | 11 | - `fin redis disable` to disable 12 | - `fin redis enable` to re-enable 13 | 14 | ## More documentation 15 | 16 | - Download redis from https://www.drupal.org/project/redis 17 | - No need to enable the module 18 | - Edit /sites/default/settings.local.php and add the following lines. 19 | - $conf['redis_client_interface'] = 'PhpRedis'; // Can be "Predis". 20 | - $conf['redis_client_host'] = 'redis'; // Your Redis instance hostname. 21 | - $conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc'; 22 | - $conf['path_inc'] = 'sites/all/modules/contrib/redis/redis.path.inc'; 23 | - $conf['cache_backends'][] = 'sites/all/modules/contrib/redis/redis.autoload.inc'; 24 | - $conf['cache_default_class'] = 'Redis_Cache'; 25 | -------------------------------------------------------------------------------- /redis/conf/redis.yml: -------------------------------------------------------------------------------- 1 | redis: 2 | hostname: redis 3 | image: redis:3.2.11 4 | -------------------------------------------------------------------------------- /redis/redis: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Enable/disable redis for current project 4 | ## 5 | ## Sub-commands: 6 | ## enable Enable redis 7 | ## disable Disable redis 8 | 9 | red='\033[0;31m' 10 | green='\033[0;32m' 11 | green_bg='\033[42m' 12 | yellow='\033[1;33m' 13 | NC='\033[0m' 14 | 15 | echo-red () { echo -e "${red}$1${NC}"; } 16 | echo-green () { echo -e "${green}$1${NC}"; } 17 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 18 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 19 | die () { echo -e "$1"; exit 1; } 20 | 21 | DOCKSAL_YML=".docksal/docksal.yml" 22 | DOCKSAL_YML_NEW=".docksal/docksal.yml.new" 23 | DOCKSAL_ENV=".docksal/docksal.env" 24 | DOCKSAL_STACKS="$HOME/.docksal/stacks" 25 | PHP_INI=".docksal/etc/php/php.ini" 26 | REDIS_YML="$ADDON_ROOT/conf/redis.yml" 27 | 28 | #----------------------------------- YML & config functions ------------------------------------------ 29 | 30 | # Check whether given string is in config 31 | # $1 - string to find 32 | in_config () 33 | { 34 | fin config 2>/dev/null | grep "$1" >/dev/null 35 | } 36 | 37 | # Check that docksal.yml is valid 38 | yml_is_valid () 39 | { 40 | [[ -f "$DOCKSAL_YML" ]] && $(cat "$DOCKSAL_YML" 2>/dev/null | grep "services" >/dev/null) 41 | } 42 | 43 | # Prepares stack to editing docksal.yml config 44 | yml_prepare () 45 | { 46 | # Get yml version to use for a new file from existing stacks 47 | YML_VERSION=$(head "$DOCKSAL_STACKS/volumes-bind.yml" | grep "version") 48 | YML_DEFAULT_BODY="${YML_VERSION}\nservices:" 49 | NEW_STACK='DOCKSAL_STACK="default"' 50 | 51 | # Source docksal.env 52 | source "$DOCKSAL_ENV" >/dev/null 2>&1 53 | 54 | # If DOCKSAL_STACK is not set, then... 55 | if [[ -z "$DOCKSAL_STACK" ]]; then 56 | echo " Configuring to use DOCKSAL_STACK=\"default\"..." 57 | # ...set stack to default so we could use docksal.yml 58 | echo -e "$NEW_STACK" >> "$DOCKSAL_ENV" 59 | fi 60 | 61 | # Create docksal.yml if needed 62 | yml_is_valid || echo -e "$YML_DEFAULT_BODY" >> "$DOCKSAL_YML" 63 | } 64 | 65 | # Install tool required to edit yml from command line 66 | yml_install_tools () 67 | { 68 | fin exec "which yaml >/dev/null 2>&1 || npm install --silent -g yaml-cli >/dev/null" 69 | } 70 | 71 | # Add a service to docksal.yml from another yml 72 | # $1 - filename of yml get service from 73 | yml_add_service () 74 | { 75 | [[ -z "$1" ]] && echo "File not found: $1" && return 1 76 | # TODO: use https://www.npmjs.com/package/merge-yaml 77 | cat "$1" >> "$DOCKSAL_YML" 78 | } 79 | 80 | # Removes a service from docksal.yml 81 | # $1 - service name 82 | yml_remove_service () 83 | { 84 | [[ -z "$1" ]] && echo "Provide a service name to remove" && return 1 85 | local service="$1" 86 | read -r -d '' CODE_TO_EXEC <<-EOF 87 | yaml set $DOCKSAL_YML services.$service | grep -v '$service:' | tee $DOCKSAL_YML_NEW >/dev/null; 88 | [[ -z "\$(yaml get $DOCKSAL_YML_NEW services)" ]] && rm '$DOCKSAL_YML' || mv $DOCKSAL_YML_NEW $DOCKSAL_YML 89 | EOF 90 | # Remove service. If no services left after that, then remove docksal.yml 91 | fin exec "$CODE_TO_EXEC" 92 | } 93 | 94 | #-------------------------------------- Redis functions --------------------------------------------- 95 | 96 | # Enable container and settings 97 | redis_enable () 98 | { 99 | # Check that redis is not already enabled 100 | if (in_config "image: docksal\/redis"); then 101 | echo " Redis is already enabled." && exit 102 | fi 103 | 104 | echo " Enabling redis ..." 105 | yml_prepare 106 | # Add redis service to docksal.yml 107 | yml_add_service "$REDIS_YML" 108 | # Apply stack changes. 109 | fin up 110 | echo "Download the redis module and add the following lines to /sites/default/settings.local.php" 111 | echo " $conf['redis_client_interface'] = 'PhpRedis'; // Can be "Predis"." 112 | echo " $conf['redis_client_host'] = 'redis'; // Your Redis instance hostname." 113 | echo " $conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc';" 114 | echo " $conf['path_inc'] = 'sites/all/modules/contrib/redis/redis.path.inc';" 115 | echo " $conf['cache_backends'][] = 'sites/all/modules/contrib/redis/redis.autoload.inc';" 116 | echo " $conf['cache_default_class'] = 'Redis_Cache';" 117 | } 118 | 119 | # Disable container and settings 120 | redis_disable () 121 | { 122 | echo " Running checks..." 123 | # Make sure cli container is running 124 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 125 | echo " ERROR: Start the project with fin start first" && exit 1 126 | fi 127 | 128 | # Make sure redis is installed 129 | if ! in_config "image: docksal\/redis"; then 130 | echo " Redis is not enabled at the moment." && exit 131 | fi 132 | 133 | echo " Preparing to remove redis service..." 134 | yml_install_tools 135 | # Remove redis service from docksal.yml 136 | yml_remove_service "redis" 137 | # Apply stack changes 138 | fin up 139 | } 140 | 141 | #------------------------------------------ Runtime ----------------------------------------------- 142 | 143 | cd "$PROJECT_ROOT" 144 | 145 | case "$1" in 146 | enable) 147 | redis_enable 148 | ;; 149 | disable) 150 | redis_disable 151 | ;; 152 | *) 153 | echo "Usage: fin redis " 154 | exit 1 155 | ;; 156 | esac 157 | -------------------------------------------------------------------------------- /redis/redis.filelist: -------------------------------------------------------------------------------- 1 | # Hooks 2 | redis.pre-install 3 | redis.post-install 4 | redis.pre-uninstall 5 | 6 | # Container config 7 | conf/redis.yml 8 | -------------------------------------------------------------------------------- /redis/redis.post-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin redis enable 4 | -------------------------------------------------------------------------------- /redis/redis.pre-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Check Docksal running 4 | if [[ "$DOCKER_RUNNING" != "true" ]]; then 5 | echo "[PRE-INSTALL] ERROR: Docksal and project should be running" 6 | exit 1 7 | fi 8 | 9 | # Check Docksal running 10 | if [[ "$ADDON_GLOBAL" == "true" ]]; then 11 | echo -e "[PRE-INSTALL] ERROR: Redis addon should not be installed globally" 12 | exit 1 13 | fi 14 | 15 | 16 | # Check project running 17 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 18 | echo "[PRE-INSTALL] ERROR: Start the project with fin start first" 19 | exit 1 20 | fi 21 | 22 | # Get fin config 23 | fin_config=$(fin config) 24 | if [[ $? != 0 ]]; then 25 | echo "[PRE-INSTALL] ERROR: 'fin config' command was not successful. Check your fin config" 26 | exit 1 27 | fi 28 | 29 | # Check there is no redis already 30 | if (echo "$fin_config" | grep "image: docksal\/redis"); then 31 | echo "[PRE-INSTALL] ERROR: Redis seems to be already enabled for this project" 32 | exit 1 33 | fi 34 | 35 | # Check there is no redis already 36 | if (echo "$fin_config" | grep " redis:"); then 37 | echo "[PRE-INSTALL] ERROR: Container named 'redis' already exists. Remove it to continue." 38 | exit 1 39 | fi 40 | 41 | 42 | # All good 43 | exit 0 44 | -------------------------------------------------------------------------------- /redis/redis.pre-uninstall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin redis disable 4 | -------------------------------------------------------------------------------- /sequelace/README.md: -------------------------------------------------------------------------------- 1 | # SequelAce Connection 2 | 3 | Launches [SequelAce](https://github.com/Sequel-Ace/Sequel-Ace) with the connection information for your project. -------------------------------------------------------------------------------- /sequelace/sequelace: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Opens SequelAce 4 | ## 5 | ## Usage: fin sequelace 6 | 7 | # Abort if anything fails 8 | set -e 9 | 10 | container_port=$(docker ps --all --filter 'label=com.docker.compose.service=db' --filter "label=com.docker.compose.project=${COMPOSE_PROJECT_NAME_SAFE}" --format '{{.Ports}}' | sed 's/.*0.0.0.0://g'|sed 's/->.*//g') 11 | HOST=${VIRTUAL_HOST} 12 | DB=${MYSQL_DATABASE:-default} 13 | USER=${MYSQL_USER:-user} 14 | PASS=${MYSQL_PASSWORD:-user} 15 | NAME=${COMPOSE_PROJECT_NAME} 16 | 17 | PORT=${PORT:-$container_port} 18 | 19 | FILENAME=/tmp/docksal-sequelace-${RANDOM}.spf 20 | cat <> $FILENAME 21 | 22 | 23 | 24 | 25 | ContentFilters 26 | 27 | auto_connect 28 | 29 | data 30 | 31 | connection 32 | 33 | database 34 | ${DB} 35 | host 36 | ${HOST} 37 | name 38 | ${NAME} 39 | user 40 | ${USER} 41 | password 42 | ${PASS} 43 | port 44 | ${PORT} 45 | rdbms_type 46 | mysql 47 | 48 | session 49 | 50 | 51 | encrypted 52 | 53 | format 54 | connection 55 | queryFavorites 56 | 57 | queryHistory 58 | 59 | rdbms_type 60 | mysql 61 | version 62 | 1 63 | 64 | 65 | EOT 66 | 67 | open $FILENAME -------------------------------------------------------------------------------- /sequelpro/README.md: -------------------------------------------------------------------------------- 1 | # SequelPro Connection 2 | 3 | Launches [SequelPro](https://www.sequelpro.com) with the connection information for your project. 4 | -------------------------------------------------------------------------------- /sequelpro/sequelpro: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Opens SequelPro 4 | ## 5 | ## Usage: fin sequelpro 6 | 7 | # Abort if anything fails 8 | set -e 9 | 10 | container_port=$(docker ps --all --filter 'label=com.docker.compose.service=db' --filter "label=com.docker.compose.project=${COMPOSE_PROJECT_NAME_SAFE}" --format '{{.Ports}}' | sed 's/.*0.0.0.0://g'|sed 's/->.*//g') 11 | HOST=${VIRTUAL_HOST} 12 | DB=${MYSQL_DATABASE:-default} 13 | USER=${MYSQL_USER:-user} 14 | PASS=${MYSQL_PASSWORD:-user} 15 | NAME=${COMPOSE_PROJECT_NAME} 16 | 17 | PORT=${PORT:-$container_port} 18 | 19 | FILENAME=/tmp/docksal-sequelpro-${RANDOM}.spf 20 | cat <> $FILENAME 21 | 22 | 23 | 24 | 25 | ContentFilters 26 | 27 | auto_connect 28 | 29 | data 30 | 31 | connection 32 | 33 | database 34 | ${DB} 35 | host 36 | ${HOST} 37 | name 38 | ${NAME} 39 | user 40 | ${USER} 41 | password 42 | ${PASS} 43 | port 44 | ${PORT} 45 | rdbms_type 46 | mysql 47 | 48 | session 49 | 50 | 51 | encrypted 52 | 53 | format 54 | connection 55 | queryFavorites 56 | 57 | queryHistory 58 | 59 | rdbms_type 60 | mysql 61 | version 62 | 1 63 | 64 | 65 | EOT 66 | 67 | open $FILENAME 68 | -------------------------------------------------------------------------------- /simpletest/README.md: -------------------------------------------------------------------------------- 1 | # SimpleTest 2 | 3 | Easily run SimpleTest tests for your Drupal 7 or 8 project. 4 | 5 | ```bash 6 | fin addon install simpletest 7 | ``` 8 | 9 | ## Usage once installed 10 | 11 | Run `fin simpletest` to run the tests. Any additional arguments and options will be appended to the command. For example, to run tests within the `modules/custom` directory, run `fin simpletest --directory modules/custom`. 12 | -------------------------------------------------------------------------------- /simpletest/simpletest: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #: exec_target = cli 4 | 5 | ## Run automated tests with SimpleTest 6 | ## 7 | ## Usage: fin simpletest [arguments] 8 | 9 | set -e 10 | set -o pipefail 11 | 12 | DRUPAL8_PATH="$PROJECT_ROOT/$DOCROOT/core/scripts/run-tests.sh" 13 | DRUPAL7_PATH="$PROJECT_ROOT/$DOCROOT/scripts/run-tests.sh" 14 | 15 | if [[ -f "$DRUPAL8_PATH" ]]; then 16 | SCRIPT_FILE="$DRUPAL8_PATH" 17 | elif [[ -f "$DRUPAL7_PATH" ]]; then 18 | SCRIPT_FILE="$DRUPAL7_PATH" 19 | else 20 | echo "ERROR: could not find run-tests.sh" 21 | exit 1 22 | fi 23 | 24 | SIMPLETEST_STATUS=`drush pm-info simpletest | grep Status | cut -d : -f 2` 25 | if [[ "$SIMPLETEST_STATUS" != *"enabled"* ]]; then 26 | drush pm-enable -y simpletest 27 | fi 28 | 29 | # Execute the script. 30 | php "$SCRIPT_FILE" --color "$@" 31 | -------------------------------------------------------------------------------- /sitediff/README.md: -------------------------------------------------------------------------------- 1 | # Sitediff 2 | 3 | Easily install [Sitediff](https://sitediff.io/) for your Docksal project 4 | 5 | ```bash 6 | fin addon install sitediff 7 | ``` 8 | 9 | ## Usage once installed 10 | 11 | - `fin sitediff disable` to disable 12 | - `fin sitediff enable` to re-enable 13 | - `fin sitediff ` to run Sitediff commands in your project 14 | 15 | # More information 16 | 17 | You can learn more about using Sitediff in the [Github repo](https://github.com/evolvingweb/sitediff#sitediff-cli) -------------------------------------------------------------------------------- /sitediff/conf/sitediff.yml: -------------------------------------------------------------------------------- 1 | # Sitediff 2 | sitediff: 3 | hostname: sitediff 4 | image: evolvingweb/sitediff 5 | ports: 6 | - 13080 7 | volumes: 8 | - ${PROJECT_ROOT}/sitediff:/app/sitediff:cached 9 | command: tail -f /dev/null 10 | labels: 11 | - io.docksal.virtual-host=sitediff.${VIRTUAL_HOST},sitediff.${VIRTUAL_HOST}.* 12 | - io.docksal.virtual-port=13080 13 | - io.docksal.cert-name=${VIRTUAL_HOST_CERT_NAME:-none} 14 | -------------------------------------------------------------------------------- /sitediff/sitediff: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Enable/disable sitediff for current project 4 | ## 5 | ## Sub-commands: 6 | ## enable Enable sitediff 7 | ## disable Disable sitediff 8 | 9 | red='\033[0;31m' 10 | green='\033[0;32m' 11 | green_bg='\033[42m' 12 | yellow='\033[1;33m' 13 | NC='\033[0m' 14 | 15 | echo-red () { echo -e "${red}$1${NC}"; } 16 | echo-green () { echo -e "${green}$1${NC}"; } 17 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 18 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 19 | die () { echo -e "$1"; exit 1; } 20 | 21 | DOCKSAL_YML=".docksal/docksal.yml" 22 | DOCKSAL_YML_NEW=".docksal/docksal.yml.new" 23 | DOCKSAL_ENV=".docksal/docksal.env" 24 | DOCKSAL_STACKS="$HOME/.docksal/stacks" 25 | SITEDIFF_YML="$ADDON_ROOT/conf/sitediff.yml" 26 | 27 | #----------------------------------- YML & config functions ------------------------------------------ 28 | 29 | # Check whether given string is in config 30 | # $1 - string to find 31 | in_config () 32 | { 33 | fin config 2>/dev/null | grep "$1" >/dev/null 34 | } 35 | 36 | # Check that docksal.yml is valid 37 | yml_is_valid () 38 | { 39 | [[ -f "$DOCKSAL_YML" ]] && $(cat "$DOCKSAL_YML" 2>/dev/null | grep "services" >/dev/null) 40 | } 41 | 42 | # Prepares stack to editing docksal.yml config 43 | yml_prepare () 44 | { 45 | # Get yml version to use for a new file from existing stacks 46 | YML_VERSION=$(head "$DOCKSAL_STACKS/volumes-bind.yml" | grep "version") 47 | YML_DEFAULT_BODY="${YML_VERSION}\nservices:" 48 | NEW_STACK='DOCKSAL_STACK="default"' 49 | 50 | # Source docksal.env 51 | source "$DOCKSAL_ENV" >/dev/null 2>&1 52 | 53 | # If DOCKSAL_STACK is not set, then... 54 | if [[ -z "$DOCKSAL_STACK" ]]; then 55 | echo " Configuring to use DOCKSAL_STACK=\"default\"..." 56 | # ...set stack to default so we could use docksal.yml 57 | echo -e "$NEW_STACK" >> "$DOCKSAL_ENV" 58 | fi 59 | 60 | # Create docksal.yml if needed 61 | yml_is_valid || echo -e "$YML_DEFAULT_BODY" > "$DOCKSAL_YML" 62 | } 63 | 64 | # Install tool required to edit yml from command line 65 | yml_install_tools () 66 | { 67 | fin exec "which yaml >/dev/null 2>&1 || npm install --silent -g yaml-cli >/dev/null" 68 | } 69 | 70 | # Add a service to docksal.yml from another yml 71 | # $1 - filename of yml get service from 72 | yml_add_service () 73 | { 74 | [[ -z "$1" ]] && echo "File not found: $1" && return 1 75 | # TODO: use https://www.npmjs.com/package/merge-yaml 76 | cat "$1" >> "$DOCKSAL_YML" 77 | } 78 | 79 | # Removes a service from docksal.yml 80 | # $1 - service name 81 | yml_remove_service () 82 | { 83 | [[ -z "$1" ]] && echo "Provide a service name to remove" && return 1 84 | local service="$1" 85 | read -r -d '' CODE_TO_EXEC <<-EOF 86 | yaml set $DOCKSAL_YML services.$service | grep -v '$service:' | tee $DOCKSAL_YML_NEW >/dev/null; 87 | [[ -z "\$(yaml get $DOCKSAL_YML_NEW services)" ]] && rm '$DOCKSAL_YML' || mv $DOCKSAL_YML_NEW $DOCKSAL_YML 88 | EOF 89 | # Remove service. If no services left after that, then remove docksal.yml 90 | fin exec "$CODE_TO_EXEC" 91 | } 92 | 93 | #-------------------------------------- SITEDIFF functions --------------------------------------------- 94 | 95 | # $1 - enable/disable 96 | # Enable container and settings 97 | sitediff_enable () 98 | { 99 | # Check that sitediff is not already enabled 100 | if (in_config "image: evolvingweb\/sitediff"); then 101 | echo " Sitediff support is already enabled." && exit 102 | fi 103 | 104 | echo " Enabling sitediff..." 105 | yml_prepare 106 | # Add sitediff service to docksal.yml 107 | yml_add_service "$SITEDIFF_YML" 108 | fin up 109 | } 110 | 111 | # Disable container and settings 112 | sitediff_disable () 113 | { 114 | echo " Running checks..." 115 | # Make sure cli container is running 116 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 117 | echo " ERROR: Start the project with fin start first" && exit 1 118 | fi 119 | 120 | # Make sure sitediff is installed 121 | if ! in_config "image: evolvingweb\/sitediff"; then 122 | echo " Sitediff support is not enabled at the moment." && exit 123 | fi 124 | 125 | echo " Preparing to remove sitediff service..." 126 | yml_install_tools 127 | # Remove sitediff service from docksal.yml 128 | yml_remove_service "sitediff" 129 | fin up 130 | } 131 | 132 | #------------------------------------------ Runtime ----------------------------------------------- 133 | 134 | cd "$PROJECT_ROOT" 135 | 136 | case "$1" in 137 | enable) 138 | sitediff_enable 139 | ;; 140 | disable) 141 | sitediff_disable 142 | ;; 143 | *) 144 | if (in_config "image: evolvingweb\/sitediff"); then 145 | fin exec --in=sitediff /usr/local/bundle/bin/sitediff "$@" --directory=/app/sitediff 146 | else 147 | echo "Sitediff needs to be installed prior to using it" 148 | echo "Run 'fin sitediff enable' to install it" 149 | exit 1 150 | fi; 151 | ;; 152 | 153 | esac 154 | -------------------------------------------------------------------------------- /sitediff/sitediff.post-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin sitediff enable 4 | 5 | echo -e "${green}Sitediff UI:${NC} http://sitediff.$VIRTUAL_HOST" 6 | -------------------------------------------------------------------------------- /sitediff/sitediff.pre-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Check Docksal running 4 | if [[ "$DOCKER_RUNNING" != "true" ]]; then 5 | echo "[PRE-INSTALL] ERROR: Docksal and project should be running" 6 | exit 1 7 | fi 8 | 9 | # Check Docksal running 10 | if [[ "$ADDON_GLOBAL" == "true" ]]; then 11 | echo -e "[PRE-INSTALL] ERROR: Sitediff addon should not be installed globally" 12 | exit 1 13 | fi 14 | 15 | 16 | # Check project running 17 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 18 | echo "[PRE-INSTALL] ERROR: Start the project with fin start first" 19 | exit 1 20 | fi 21 | 22 | # Get fin config 23 | fin_config=$(fin config) 24 | if [[ $? != 0 ]]; then 25 | echo "[PRE-INSTALL] ERROR: 'fin config' command was not successful. Check your fin config" 26 | exit 1 27 | fi 28 | 29 | # Check there is no sitediff already 30 | if (echo "$fin_config" | grep "image: evolvingweb\/sitediff"); then 31 | echo "[PRE-INSTALL] ERROR: Sitediff seems to be already enabled for this project" 32 | exit 1 33 | fi 34 | 35 | # Check there is no sitediff already 36 | if (echo "$fin_config" | grep " sitediff:"); then 37 | echo "[PRE-INSTALL] ERROR: Container named 'sitediff' already exists. Remove it to continue." 38 | exit 1 39 | fi 40 | 41 | 42 | # All good 43 | exit 0 44 | -------------------------------------------------------------------------------- /sitediff/sitediff.pre-uninstall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin sitediff disable 4 | -------------------------------------------------------------------------------- /socketi/README.md: -------------------------------------------------------------------------------- 1 | # Socketi Docksal addon 2 | 3 | Soketi is your simple, fast, and resilient open-source WebSockets server 4 | 5 | 6 | ## Known issues 7 | 8 | Does not work with SSL currently 9 | -------------------------------------------------------------------------------- /socketi/conf/socketi.yml: -------------------------------------------------------------------------------- 1 | #socketi settings 2 | soketi: 3 | hostname: socketi 4 | image: quay.io/soketi/soketi:latest-16-debian 5 | labels: 6 | - io.docksal.virtual-host=socketi.${VIRTUAL_HOST} 7 | ports: 8 | - "${SOKETI_PORT:-6001}:6001" 9 | - "${SOKETI_METRICS_SERVER_PORT:-9601}:9601" 10 | environment: 11 | SOKETI_DEBUG: "1" 12 | SOKETI_METRICS_SERVER_PORT: "9601" 13 | dns: 14 | - ${DOCKSAL_DNS1} 15 | - ${DOCKSAL_DNS2} 16 | -------------------------------------------------------------------------------- /socketi/socketi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERSION="1.0" 4 | 5 | ## Socketi addon 6 | ## 7 | ## Adds the node socket running connection (pusher compatable) 8 | ## to your stack: https://docs.soketi.app/ 9 | ## 10 | ## fin example 11 | ## 12 | ## Usage: 13 | ## enable enable socketi 14 | ## disable disable socketi 15 | 16 | 17 | 18 | # Console colors 19 | red='\033[0;91m' 20 | red_bg='\033[101m' 21 | yellow_bg='\033[43;90m' 22 | green='\033[0;32m' 23 | green_bg='\033[42m' 24 | yellow='\033[0;33m' 25 | yellow_bold='\033[1;33m' 26 | NC='\033[0m' 27 | 28 | echo-red () { echo -e "${red}$1${NC}"; } 29 | echo-green () { echo -e "${green}$1${NC}"; } 30 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 31 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 32 | die () { echo -e "$1"; exit 1; } 33 | 34 | DOCKSAL_YML=".docksal/docksal.yml" 35 | DOCKSAL_YML_NEW=".docksal/docksal.yml.new" 36 | DOCKSAL_ENV=".docksal/docksal.env" 37 | DOCKSAL_STACKS="$HOME/.docksal/stacks" 38 | SOCKETI_YML="$ADDON_ROOT/conf/socketi.yml" 39 | 40 | #----------------------------------- YML & config functions ------------------------------------------ 41 | 42 | # Check whether given string is in config 43 | # $1 - string to find 44 | in_config () 45 | { 46 | fin config 2>/dev/null | grep "$1" >/dev/null 47 | } 48 | 49 | # Check that docksal.yml is valid 50 | yml_is_valid () 51 | { 52 | [[ -f "$DOCKSAL_YML" ]] && $(cat "$DOCKSAL_YML" 2>/dev/null | grep "services" >/dev/null) 53 | } 54 | 55 | # Prepares stack to editing docksal.yml config 56 | yml_prepare () 57 | { 58 | # Get yml version to use for a new file from existing stacks 59 | YML_VERSION=$(head "$DOCKSAL_STACKS/volumes-bind.yml" | grep "version") 60 | YML_DEFAULT_BODY="${YML_VERSION}\nservices:" 61 | NEW_STACK='DOCKSAL_STACK="default"' 62 | 63 | # Source docksal.env 64 | source "$DOCKSAL_ENV" >/dev/null 2>&1 65 | 66 | # If DOCKSAL_STACK is not set, then... 67 | if [[ -z "$DOCKSAL_STACK" ]]; then 68 | echo " Configuring to use DOCKSAL_STACK=\"default\"..." 69 | # ...set stack to default so we could use docksal.yml 70 | echo -e "$NEW_STACK" >> "$DOCKSAL_ENV" 71 | fi 72 | 73 | # Create docksal.yml if needed 74 | yml_is_valid || echo -e "$YML_DEFAULT_BODY" >> "$DOCKSAL_YML" 75 | } 76 | 77 | # Install tool required to edit yml from command line 78 | yml_install_tools () 79 | { 80 | fin exec "which yaml >/dev/null 2>&1 || npm install --silent -g yaml-cli >/dev/null" 81 | } 82 | 83 | # Add a service to docksal.yml from another yml 84 | # $1 - filename of yml get service from 85 | yml_add_service () 86 | { 87 | [[ -z "$1" ]] && echo "File not found: $1" && return 1 88 | # TODO: use https://www.npmjs.com/package/merge-yaml 89 | cat "$1" >> "$DOCKSAL_YML" 90 | } 91 | 92 | # Removes a service from docksal.yml 93 | # $1 - service name 94 | yml_remove_service () 95 | { 96 | [[ -z "$1" ]] && echo "Provide a service name to remove" && return 1 97 | local service="$1" 98 | read -r -d '' CODE_TO_EXEC <<-EOF 99 | yaml set $DOCKSAL_YML services.$service | grep -v '$service:' | tee $DOCKSAL_YML_NEW >/dev/null; 100 | [[ -z "\$(yaml get $DOCKSAL_YML_NEW services)" ]] && rm '$DOCKSAL_YML' || mv $DOCKSAL_YML_NEW $DOCKSAL_YML 101 | EOF 102 | # Remove service. If no services left after that, then remove docksal.yml 103 | fin exec "$CODE_TO_EXEC" 104 | } 105 | 106 | #-------------------------------------- socketi functions --------------------------------------------- 107 | 108 | # Set/remove proper setting into php.ini 109 | # $1 - enable/disable 110 | # Enable container and settings 111 | socketi_enable () 112 | { 113 | # Check that socketi is not already enabled 114 | if (in_config "image: quay.io/soketi/soketi:latest-16-debian"); then 115 | echo " socketi support is already enabled." && exit 116 | fi 117 | 118 | echo " Enabling socketi..." 119 | yml_prepare 120 | # Add socketi service to docksal.yml 121 | yml_add_service "$SOCKETI_YML" 122 | # Apply stack changes. 123 | fin stop cli 124 | fin up 125 | } 126 | 127 | # Disable container and settings 128 | socketi_disable () 129 | { 130 | echo " Running checks..." 131 | # Make sure cli container is running 132 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 133 | echo " ERROR: Start the project with fin start first" && exit 1 134 | fi 135 | 136 | # Make sure socketi is installed 137 | if ! in_config "image: quay.io/soketi/soketi:latest-16-debian"; then 138 | echo " socketi support is not enabled at the moment." && exit 139 | fi 140 | 141 | echo " Preparing to remove socketi service..." 142 | yml_install_tools 143 | # Remove socketi service from docksal.yml 144 | yml_remove_service "socketi" 145 | # Apply stack changes 146 | COMPOSE_FILE="" fin stop cli 147 | fin up 148 | } 149 | 150 | #------------------------------------------ Runtime ----------------------------------------------- 151 | 152 | cd "$PROJECT_ROOT" 153 | 154 | case "$1" in 155 | enable) 156 | socketi_enable 157 | ;; 158 | disable) 159 | socketi_disable 160 | ;; 161 | *) 162 | echo "Usage: fin socketi " 163 | exit 1 164 | ;; 165 | esac 166 | -------------------------------------------------------------------------------- /socketi/socketi.filelist: -------------------------------------------------------------------------------- 1 | # Hooks 2 | socketi.pre-install 3 | socketi.post-install 4 | socketi.pre-uninstall 5 | 6 | # Container config 7 | conf/socketi.yml 8 | 9 | -------------------------------------------------------------------------------- /socketi/socketi.post-install: -------------------------------------------------------------------------------- 1 | !/usr/bin/env bash 2 | 3 | # Console colors 4 | red='\033[0;91m' 5 | red_bg='\033[101m' 6 | yellow_bg='\033[43;90m' 7 | green='\033[0;32m' 8 | green_bg='\033[42m' 9 | yellow='\033[0;33m' 10 | yellow_bold='\033[1;33m' 11 | NC='\033[0m' 12 | 13 | 14 | echo-red () { echo -e "${red}$1${NC}"; } 15 | echo-green () { echo -e "${green}$1${NC}"; } 16 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 17 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 18 | fin socketi enable 19 | 20 | echo-green "Socketi uri:${yellow} http://socketi.$VIRTUAL_HOST${NC}" 21 | -------------------------------------------------------------------------------- /socketi/socketi.pre-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Check Docksal running 4 | if [[ "$DOCKER_RUNNING" != "true" ]]; then 5 | echo "[PRE-INSTALL] ERROR: Docksal and project should be running" 6 | exit 1 7 | fi 8 | 9 | # Check Docksal running 10 | if [[ "$ADDON_GLOBAL" == "true" ]]; then 11 | echo -e "[PRE-INSTALL] ERROR: Socketi addon should not be installed globally" 12 | exit 1 13 | fi 14 | 15 | 16 | # Check project running 17 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 18 | echo "[PRE-INSTALL] ERROR: Start the project with fin start first" 19 | exit 1 20 | fi 21 | 22 | # Get fin config 23 | fin_config=$(fin config) 24 | if [[ $? != 0 ]]; then 25 | echo "[PRE-INSTALL] ERROR: 'fin config' command was not successful. Check your fin config" 26 | exit 1 27 | fi 28 | 29 | # Check there is no socketi already 30 | if (echo "$fin_config" | grep "image: quay.io/soketi/soketi:latest-16-debian"); then 31 | echo "[PRE-INSTALL] ERROR: Socketi seems to be already enabled for this project" 32 | exit 1 33 | fi 34 | 35 | # Check there is no socketi already 36 | if (echo "$fin_config" | grep " soketi:"); then 37 | echo "[PRE-INSTALL] ERROR: Container named 'soketi' already exists. Remove it to continue." 38 | exit 1 39 | fi 40 | 41 | # All good 42 | exit 0 43 | -------------------------------------------------------------------------------- /socketi/socketi.pre-uninstall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin socketi disable 4 | -------------------------------------------------------------------------------- /solr/README.md: -------------------------------------------------------------------------------- 1 | # Solr 2 | 3 | Easily install Apache Solr search service to the project 4 | 5 | ```bash 6 | fin addon install solr 7 | ``` 8 | 9 | ## Usage once installed 10 | 11 | - `fin solr disable` to disable 12 | - `fin solr enable` to re-enable 13 | 14 | ## More documentation 15 | 16 | http://docs.docksal.io/en/master/tools/apache-solr 17 | -------------------------------------------------------------------------------- /solr/conf/solr.yml: -------------------------------------------------------------------------------- 1 | solr: 2 | extends: 3 | file: ${HOME}/.docksal/stacks/services.yml 4 | service: solr 5 | -------------------------------------------------------------------------------- /solr/solr: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Enable/disable solr for current project 4 | ## 5 | ## Sub-commands: 6 | ## enable Enable solr 7 | ## disable Disable solr 8 | 9 | red='\033[0;31m' 10 | green='\033[0;32m' 11 | green_bg='\033[42m' 12 | yellow='\033[1;33m' 13 | NC='\033[0m' 14 | 15 | echo-red () { echo -e "${red}$1${NC}"; } 16 | echo-green () { echo -e "${green}$1${NC}"; } 17 | echo-green-bg () { echo -e "${green_bg}$1${NC}"; } 18 | echo-yellow () { echo -e "${yellow}$1${NC}"; } 19 | die () { echo -e "$1"; exit 1; } 20 | 21 | DOCKSAL_YML=".docksal/docksal.yml" 22 | DOCKSAL_YML_NEW=".docksal/docksal.yml.new" 23 | DOCKSAL_ENV=".docksal/docksal.env" 24 | DOCKSAL_STACKS="$HOME/.docksal/stacks" 25 | PHP_INI=".docksal/etc/php/php.ini" 26 | SOLR_YML="$ADDON_ROOT/conf/solr.yml" 27 | 28 | #----------------------------------- YML & config functions ------------------------------------------ 29 | 30 | # Check whether given string is in config 31 | # $1 - string to find 32 | in_config () 33 | { 34 | fin config 2>/dev/null | grep "$1" >/dev/null 35 | } 36 | 37 | # Check that docksal.yml is valid 38 | yml_is_valid () 39 | { 40 | [[ -f "$DOCKSAL_YML" ]] && $(cat "$DOCKSAL_YML" 2>/dev/null | grep "services" >/dev/null) 41 | } 42 | 43 | # Prepares stack to editing docksal.yml config 44 | yml_prepare () 45 | { 46 | # Get yml version to use for a new file from existing stacks 47 | YML_VERSION=$(head "$DOCKSAL_STACKS/volumes-bind.yml" | grep "version") 48 | YML_DEFAULT_BODY="${YML_VERSION}\nservices:" 49 | NEW_STACK='DOCKSAL_STACK="default"' 50 | 51 | # Source docksal.env 52 | source "$DOCKSAL_ENV" >/dev/null 2>&1 53 | 54 | # If DOCKSAL_STACK is not set, then... 55 | if [[ -z "$DOCKSAL_STACK" ]]; then 56 | echo " Configuring to use DOCKSAL_STACK=\"default\"..." 57 | # ...set stack to default so we could use docksal.yml 58 | echo -e "$NEW_STACK" >> "$DOCKSAL_ENV" 59 | fi 60 | 61 | # Create docksal.yml if needed 62 | yml_is_valid || echo -e "$YML_DEFAULT_BODY" >> "$DOCKSAL_YML" 63 | } 64 | 65 | # Install tool required to edit yml from command line 66 | yml_install_tools () 67 | { 68 | fin exec "which yaml >/dev/null 2>&1 || npm install --silent -g yaml-cli >/dev/null" 69 | } 70 | 71 | # Add a service to docksal.yml from another yml 72 | # $1 - filename of yml get service from 73 | yml_add_service () 74 | { 75 | [[ -z "$1" ]] && echo "File not found: $1" && return 1 76 | # TODO: use https://www.npmjs.com/package/merge-yaml 77 | cat "$1" >> "$DOCKSAL_YML" 78 | } 79 | 80 | # Removes a service from docksal.yml 81 | # $1 - service name 82 | yml_remove_service () 83 | { 84 | [[ -z "$1" ]] && echo "Provide a service name to remove" && return 1 85 | local service="$1" 86 | read -r -d '' CODE_TO_EXEC <<-EOF 87 | yaml set $DOCKSAL_YML services.$service | grep -v '$service:' | tee $DOCKSAL_YML_NEW >/dev/null; 88 | [[ -z "\$(yaml get $DOCKSAL_YML_NEW services)" ]] && rm '$DOCKSAL_YML' || mv $DOCKSAL_YML_NEW $DOCKSAL_YML 89 | EOF 90 | # Remove service. If no services left after that, then remove docksal.yml 91 | fin exec "$CODE_TO_EXEC" 92 | } 93 | 94 | #-------------------------------------- Solr functions --------------------------------------------- 95 | 96 | # Enable container and settings 97 | solr_enable () 98 | { 99 | # Check that mailhog is not already enabled 100 | if (in_config "image: docksal\/solr"); then 101 | echo " Solr is already enabled." && exit 102 | fi 103 | 104 | echo " Enabling solr..." 105 | yml_prepare 106 | # Add mailhog service to docksal.yml 107 | yml_add_service "$SOLR_YML" 108 | # Apply stack changes. 109 | fin up 110 | echo "See documentation for more details: http://docs.docksal.io/en/master/tools/apache-solr" 111 | } 112 | 113 | # Disable container and settings 114 | solr_disable () 115 | { 116 | echo " Running checks..." 117 | # Make sure cli container is running 118 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 119 | echo " ERROR: Start the project with fin start first" && exit 1 120 | fi 121 | 122 | # Make sure mailhog is installed 123 | if ! in_config "image: docksal\/solr"; then 124 | echo " Solr is not enabled at the moment." && exit 125 | fi 126 | 127 | echo " Preparing to remove solr service..." 128 | yml_install_tools 129 | # Remove mailhog service from docksal.yml 130 | yml_remove_service "solr" 131 | # Apply stack changes 132 | fin up 133 | } 134 | 135 | #------------------------------------------ Runtime ----------------------------------------------- 136 | 137 | cd "$PROJECT_ROOT" 138 | 139 | case "$1" in 140 | enable) 141 | solr_enable 142 | ;; 143 | disable) 144 | solr_disable 145 | ;; 146 | *) 147 | echo "Usage: fin solr " 148 | exit 1 149 | ;; 150 | esac 151 | -------------------------------------------------------------------------------- /solr/solr.filelist: -------------------------------------------------------------------------------- 1 | # Hooks 2 | solr.pre-install 3 | solr.post-install 4 | solr.pre-uninstall 5 | 6 | # Container config 7 | conf/solr.yml 8 | -------------------------------------------------------------------------------- /solr/solr.post-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin solr enable 4 | -------------------------------------------------------------------------------- /solr/solr.pre-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Check Docksal running 4 | if [[ "$DOCKER_RUNNING" != "true" ]]; then 5 | echo "[PRE-INSTALL] ERROR: Docksal and project should be running" 6 | exit 1 7 | fi 8 | 9 | # Check Docksal running 10 | if [[ "$ADDON_GLOBAL" == "true" ]]; then 11 | echo -e "[PRE-INSTALL] ERROR: Solr addon should not be installed globally" 12 | exit 1 13 | fi 14 | 15 | 16 | # Check project running 17 | if ! (fin ps | grep "_cli_" | grep "Up" >/dev/null); then 18 | echo "[PRE-INSTALL] ERROR: Start the project with fin start first" 19 | exit 1 20 | fi 21 | 22 | # Get fin config 23 | fin_config=$(fin config) 24 | if [[ $? != 0 ]]; then 25 | echo "[PRE-INSTALL] ERROR: 'fin config' command was not successful. Check your fin config" 26 | exit 1 27 | fi 28 | 29 | # Check there is no mailhog already 30 | if (echo "$fin_config" | grep "image: docksal\/solr"); then 31 | echo "[PRE-INSTALL] ERROR: Solr seems to be already enabled for this project" 32 | exit 1 33 | fi 34 | 35 | # Check there is no mailhog already 36 | if (echo "$fin_config" | grep " solr:"); then 37 | echo "[PRE-INSTALL] ERROR: Container named 'solr' already exists. Remove it to continue." 38 | exit 1 39 | fi 40 | 41 | 42 | # All good 43 | exit 0 -------------------------------------------------------------------------------- /solr/solr.pre-uninstall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | fin solr disable 4 | -------------------------------------------------------------------------------- /tableplus/README.md: -------------------------------------------------------------------------------- 1 | # TablePlus Connection 2 | 3 | Launches [TablePlus](https://www.tableplus.com) with the connection information for your project. 4 | -------------------------------------------------------------------------------- /tableplus/tableplus: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## Opens TablePlus 4 | ## 5 | ## Usage: fin tableplus [mysql|mariadb|postgre] 6 | 7 | # Abort if anything fails 8 | set -e 9 | 10 | container_port=$(docker ps --all --filter 'label=com.docker.compose.service=db' --filter "label=com.docker.compose.project=${COMPOSE_PROJECT_NAME_SAFE}" --format '{{.Ports}}' | sed 's/.*0.0.0.0://g'|sed 's/->.*//g') 11 | HOST=${VIRTUAL_HOST} 12 | DB=${MYSQL_DATABASE:-default} 13 | USER=${MYSQL_USER:-user} 14 | PASS=${MYSQL_PASSWORD:-user} 15 | NAME=${COMPOSE_PROJECT_NAME} 16 | 17 | PORT=${PORT:-$container_port} 18 | 19 | 20 | 21 | case "$1" in 22 | mysql) 23 | open "mysql://${USER}:${PASS}@${HOST}:${PORT}/${DB}?statusColor=007F3D&enviroment=local&name=${NAME}" 24 | ;; 25 | mariadb) 26 | open "mariadb://${USER}:${PASS}@${HOST}:${PORT}/${DB}?statusColor=007F3D&enviroment=local&name=${NAME}" 27 | ;; 28 | postgre) 29 | open "postgresql://${USER}:${PASS}@${HOST}:${PORT}/${DB}?statusColor=007F3D&enviroment=local&name=${NAME}" 30 | ;; 31 | *) 32 | echo "Usage: fin tableplus [mysql|mariadb|postgre]" 33 | exit 1 34 | ;; 35 | esac 36 | -------------------------------------------------------------------------------- /uli/README.md: -------------------------------------------------------------------------------- 1 | # Drupal one-time login url 2 | 3 | * Generate one time login url and: 4 | * on Mac copy it to clipboard with `pbcopy` 5 | * on Linux copy it to both the selection buffer and clipboard with `xclip` 6 | 7 | ## Usage 8 | 9 | ``` 10 | fin uli [-s] [-i] [@drushsitealias] [ drush uli options ] 11 | ``` 12 | 13 | * `-s` outputs the login url with https instead of default of http 14 | * Setting `DOCKSAL_ADDON_ULI_USE_HTTPS=1` in the global `docksal.env` or in a project's `docksal-local.env` will force the use of https in the link output unless overridden by the `-i` option. 15 | * `-i` outputs the login url with the default http 16 | * Drush site alias - useful for Drupal multi-site installations 17 | * Drush uli options are passed in. See [Drush user:login documentation](https://drushcommands.com/drush-9x/user/user:login/) for possible options. 18 | 19 | Note: the `-s` and `-i` options and Drush site alias must be one of the first two given on the command line. Both are optional. 20 | -------------------------------------------------------------------------------- /uli/uli: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | die () 4 | { 5 | echo "$1" 6 | exit 1 7 | } 8 | 9 | ## Generate one time user login link. Add -s to use https in url or -i for insecure. 10 | ## Usage fin uli @drushalias -s -i 11 | ## The drush alias and -s -i flags are optional. 12 | ## Set environmental variable DOCKSAL_ADDON_ULI_USE_HTTPS=1 in either the global docksal.env 13 | ## or the project docksal-local.env file to always use https in the link. Use -i to override. 14 | 15 | cd "$PROJECT_ROOT/$DOCROOT" || die "Could not change dir to $PROJECT_ROOT/$DOCROOT" 16 | 17 | # Check the environmental variable DOCKSAL_ADDON_ULI_USE_HTTPS to see if it is set to true. 18 | # This will be overridden by command line options given in the next section. 19 | https=${DOCKSAL_ADDON_ULI_USE_HTTPS:-0} # Default is to not use https 20 | 21 | # Check the first two options / arguments given on the the command line for 22 | # what looks like a Drush site alias or the -s option to use https in the url. 23 | count=2 24 | while [ $count -ne 0 ]; do 25 | if [[ $1 == @* ]]; then 26 | drushalias=$1 27 | shift 1 28 | elif [[ $1 == "-s" ]]; then 29 | https=1 30 | shift 1 31 | elif [[ $1 == "-i" ]]; then 32 | https=0 33 | shift 1 34 | fi 35 | count=$[$count-1] 36 | done 37 | 38 | if [ $https -eq 0 ]; then 39 | uli=$(fin drush $drushalias uli "$@" 2>&1 | sed "s/default/$VIRTUAL_HOST/") 40 | elif [ $https -eq 1 ]; then 41 | uli=$(fin drush $drushalias uli "$@" 2>&1 | sed "s/default/$VIRTUAL_HOST/" | sed "s/http\:/https:/") 42 | else 43 | exit 2 44 | fi 45 | echo "$uli" 46 | [[ "$uli" == *"Error"* ]] && exit 1 47 | 48 | # Mac OSX copy uli to clipboard with pbcopy 49 | ( which pbcopy >/dev/null 2>&1 ) && 50 | echo "$uli" | pbcopy && 51 | echo "[+] Copied to clipboard" 52 | 53 | # Linux copy uli to both the selection buffer and clipboard with xclip. 54 | ( which xclip >/dev/null 2>&1 ) && 55 | echo "$uli" | xclip -i -sel c -f |xclip -i -sel p && 56 | echo "[+] Copied to clipboard and selection buffer" 57 | -------------------------------------------------------------------------------- /wkhtmltopdf/wkhtmltopdf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #: exec_target = cli 4 | 5 | ## Install wkhtmltopdf inside project's cli container. 6 | ## Installs the base compiled version along with fonts and Xvfb for X Server rendering. 7 | ## 8 | ## Usage: fin wkhtmltopdf install | version 9 | 10 | _install () 11 | { 12 | # Steps below follow the Dockerfile RUN format used in Docksal images. 13 | # This makes it simpler to copy and paste them into a custom Dockerfile. 14 | set -xe; \ 15 | sudo apt-get update --allow-releaseinfo-change; \ 16 | sudo apt-get -y --no-install-recommends install \ 17 | libxrender1 \ 18 | libfontconfig1 \ 19 | libx11-dev \ 20 | libjpeg62 \ 21 | libxtst6 \ 22 | fontconfig \ 23 | ttf-mscorefonts-installer \ 24 | xauth \ 25 | xfonts-75dpi \ 26 | xvfb \ 27 | ; \ 28 | # wkhtmltopdf binary (wkhtmltopdfx) 29 | curl -fL# "https://github.com/SilvertipSoftware/wkhtmltopdf-amd64/blob/master/bin/wkhtmltopdf-amd64?raw=true" -o /tmp/wkhtmltopdfx; \ 30 | sudo install /tmp/wkhtmltopdfx /usr/local/bin/wkhtmltopdfx; \ 31 | # wkhtmltopdf wrapper script (wkhtmltopdf) 32 | echo 'xvfb-run -a -s "-screen 0 1024x768x16" wkhtmltopdfx "$@"' | tee /tmp/wkhtmltopdf; \ 33 | sudo install /tmp/wkhtmltopdf /usr/local/bin/wkhtmltopdf; \ 34 | wkhtmltopdf -V 35 | } 36 | 37 | case "$1" in 38 | install) 39 | _install 40 | ;; 41 | version|-v) 42 | wkhtmltopdf -V 43 | ;; 44 | *) 45 | echo "Install wkhtmltopdf to your current cli" 46 | echo " " 47 | echo "Usage: fin wkhtmltopdf install | version " 48 | ;; 49 | esac 50 | -------------------------------------------------------------------------------- /xdebug/xdebug: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ## Turn Xdebug on or off 3 | ## 4 | ## Usage: fin xdebug [on|off] 5 | 6 | set -e 7 | 8 | case $1 in 9 | 10 | on) 11 | fin config set --env=local XDEBUG_ENABLED=1 12 | fin up 13 | ;; 14 | off) 15 | fin config set --env=local XDEBUG_ENABLED=0 16 | fin up 17 | ;; 18 | *) 19 | echo "Usage: fin xdebug " 20 | esac 21 | 22 | echo "Set xdebug to $1" 23 | --------------------------------------------------------------------------------