diff --git a/CHANGELOG.md b/CHANGELOG.md index 621d3f9..e121b7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,25 @@ CliTools Changelog ================== +next - UPCOMING +------------------ + + +2.3.0 - 2016-01-26 +------------------ +- Updated compile documentation +- Improved compile scripts +- Added rsync.opts documentation +- Added rsync.opts section in `clisync.yml` for additional rsync options +- No terminal title if stdout redirect is detected +- Added `docker:cleanup` for cleanup of orphaned images and volumes +- Renamed `sync:server` to `sync` +- Renamed `sync:backup` to `share:backup` +- Renamed `sync:restore` to `share:restore` +- Renamed `sync:deploy` to `deploy` +- Added `COMPOSER=custom.json ct php:composer` support +- Support for new PHP and TYPO3 Docker Boilerplate (with APPLICATION_USER detection, configurable) + 2.2.0 - 2015-08-19 ------------------ - Introduced `docker:up --switch` (`docker:up` without --switch parameter no longer shutdown previous one) diff --git a/Documentation/ALIASES.md b/Documentation/ALIASES.md index e36344f..d124744 100644 --- a/Documentation/ALIASES.md +++ b/Documentation/ALIASES.md @@ -22,6 +22,7 @@ alias dcroot='ct docker:root' # Execute predefined cli in docker container alias dccrun='ct docker:cli' +alias dcrun='ct docker:cli' # Run command alias dcexec='ct docker:exec' diff --git a/Documentation/COMMANDS.md b/Documentation/COMMANDS.md index 42f3922..6c8ca79 100644 --- a/Documentation/COMMANDS.md +++ b/Documentation/COMMANDS.md @@ -77,7 +77,7 @@ All log commands are using a grep-filter (specified as optional argument) | | __ct mysql:restore typo3 dump.sql.xz__ -> xz'ed (lzma'ed) sql dump | | | __ct mysql:restore typo3 dump.sql --filter=typo3__ -> No TYPO3 cache tables in dump | | ct mysql:restore | Create (and drops if already exists) a database and restore from a dump | -| | Dump file can be plaintext, gziped, bzip2 or lzma compressed | +| | Dump file can be plaintext, gzip, bzip2 or lzma compressed | | | and will automatically detected | | | __ct mysql:restore typo3 dump.sql.bz2__ | | ct mysql:convert | Convert character set and collation of a database | diff --git a/Documentation/Examples/clisync.yml b/Documentation/Examples/clisync.yml index 59af1c1..e371ffd 100644 --- a/Documentation/Examples/clisync.yml +++ b/Documentation/Examples/clisync.yml @@ -53,6 +53,9 @@ GLOBAL: # set target as sub directroy (will be appended to working directory) workdir: "" + # Additional options ("-rlptD --delete-after --progress --human-readable" is already set) + opts: "" + # exclude list/patterns for files and directories exclude: # Temp files @@ -61,9 +64,7 @@ GLOBAL: # VCS - ".git*" - - ".gitignore" - - ".gitmodules" - - ".svn" + - ".svn*" # Build files - "composer.json" diff --git a/Documentation/INSTALL.md b/Documentation/INSTALL.md index 7de019e..8c25b69 100644 --- a/Documentation/INSTALL.md +++ b/Documentation/INSTALL.md @@ -1,4 +1,4 @@ -q[<-- Back to main section](../README.md) +[<-- Back to main section](../README.md) # Installation @@ -17,8 +17,13 @@ q[<-- Back to main section](../README.md) - sudo - moreutils (ifdata) - coreutils (grep, sort, uniq, awk, cat, df, ip, cut, lsb_release, wall) + - rsync (to prevent bugs with umlauts while you have to use rsync with version >= 3.0 (GNU version)) + - gnu-sed - docker and docker-compose (if you want to use docker) - mysql (if you want to use mysql) + +When you're want to using clitools under OSX, you could use homebrew, an excellent package manager +to easily install the above mentioned requirements. ## Install clitools @@ -36,37 +41,9 @@ wget -O"$HOME/.clitools.ini" https://github.com/webdevops/clitools/blob/develop/ ## Aliases -Now you can use following aliases (some aliases requires clitools 1.8.0!): +Now you can use some useful aliases (some aliases requires clitools 1.8.0!): -```bash -# Shortcut for auto-tree-searching make -alias make='ct make' - -# Shortcut for auto-tree-searching make -alias composer='ct php:composer' - -# Shortcut for docker-compose (autosearch docker-compose.yml in up-dir, you don't have to be in directory with docker-compose.yml) -alias dcc='ct docker:compose' - -# Startup docker-container (and shutdown previous one, v1.9.0 and up) -alias dccup='ct docker:up' -alias dccstop='ct docker:compose stop' - -# Enter main docker container (as CLI_USER if available - if not specified then root is used) -alias dcshell='ct docker:shell' -alias dcsh='ct docker:shell' - -# Enter main docker container (as root) -alias dcroot='ct docker:root' - -# Execute predefined cli in docker container -alias dccrun='ct docker:cli' -alias dcrun='ct docker:cli' - -# Execute mysql client in docker container -alias dcsql='ct docker:mysql' -alias dcmysql='ct docker:mysql' -``` +[Example aliases for clitools](ALIASES.md) ## Configuration @@ -135,9 +112,12 @@ cd clitools make all ``` +### Details about the Makefile If you take a look into the `Makefile`, you will see which tasks have been executed. The steps are: 1. Execute composer command 2. Start main build script 3. Copy the previously built phar file to `/usr/local/bin`, so that you can execute clitools just by typing ct. + +*Note*: If you're compiling clitools in OSX the easiest thing is to install requirements with homebrew: `brew install coreutils g-sed homebrew/php/box` diff --git a/Documentation/USAGE-DOCKER.md b/Documentation/USAGE-DOCKER.md index 41dfa2f..0c4ef7e 100644 --- a/Documentation/USAGE-DOCKER.md +++ b/Documentation/USAGE-DOCKER.md @@ -4,7 +4,7 @@ ## Docker creation -You can easly create new docker instances (from my or a custom docker boilerplate) also with code intalization +You can easily create new docker instances (from my or a custom docker boilerplate) also with code initialization and Makefile running. ```bash @@ -14,6 +14,9 @@ ct docker:create foobar # Create and start new docker boilerplate into foobar directory ct docker:create foobar --up +# Create new typo3 docker boilerplate +ct docker:create foobar --docker=typo3 + # Create new custom docker boilerplate ct docker:create foobar --docker=git... @@ -29,8 +32,8 @@ ct docker:create foobar --code=git... --make=build --up ## Docker startup -The `docker:up` command will search the `docker-compose.yml` in the current parent directroy tree and -execute `docker-compose` from this directroy - you don't have to change the current directroy. +The `docker:up` command will search the `docker-compose.yml` in the current parent directory tree and +execute `docker-compose` from this directory - you don't have to change the current directory. Also the previous docker instance will be shut down to avoid port conflicts. @@ -42,7 +45,7 @@ ct docker:up ## Custom docker commands As `docker:up` the `docker:compose` will search the `docker-compose.yml` and will execute your command -from this directroy. +from this directory. ```bash # Stop docker instance @@ -83,7 +86,7 @@ ct docker:exec ps You can define a common CLI script entrypoint with the environment variable CLI_SCRIPT in your docker containers. The environment variable will be read by `ct docker:cli` and will be executed - you don't have to jump -into your containers, you can start your CLI_SCRIPTs from the outide. +into your containers, you can start your CLI_SCRIPTs from the outside. ```bash # Execute predefined cli command with argument "help" in "main" container @@ -105,3 +108,21 @@ ct docker:sniff http --full # Show mysql querys by using network sniffer ct docker:sniff mysql ``` + +## Docker cleanup +Docker currently doesn't cleanup orphaned images or volumes so you have to cleanup your system regularly to get free disk space + +```bash +ct docker:cleanup +``` + +It's a shortcut for: + +```bash +# Docker image cleanup: +docker images | grep "" | awk "{print \$3}" | xargs --no-run-if-empty docker rmi -f + +# Docker volume cleanup +docker pull martin/docker-cleanup-volumes +docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes +``` diff --git a/Documentation/USAGE-MYSQL.md b/Documentation/USAGE-MYSQL.md index 269e482..6ae723f 100644 --- a/Documentation/USAGE-MYSQL.md +++ b/Documentation/USAGE-MYSQL.md @@ -17,7 +17,7 @@ ct mysql:list # Debugging -The `ct mysql:querylog` and `ct mysql:slowlog` provides a convinent way to access the general query log +The `ct mysql:querylog` and `ct mysql:slowlog` provides a convenient way to access the general query log and the slow log. In the query log you can see all queries send and executed by the MySQL database. @@ -67,7 +67,7 @@ Also the compression is automatically detected by file mime type. ct mysql:restore typo3 dump.sql ``` -# Datbase charset conversion +# Database charset conversion ```bash # Convert database to UTF8 diff --git a/Documentation/USAGE-PHP.md b/Documentation/USAGE-PHP.md index 911ec67..3997df2 100644 --- a/Documentation/USAGE-PHP.md +++ b/Documentation/USAGE-PHP.md @@ -4,7 +4,7 @@ ## Composer (auto searching in path tree) -Because you always need to jump into `composer.json` directroy `ct php:composer` will do this for you +Because you always need to jump into `composer.json` directory `ct php:composer` will do this for you ```bash # Run composer install task diff --git a/Documentation/USAGE-SYNC.md b/Documentation/USAGE-SYNC.md index 11bed8d..9d2c304 100644 --- a/Documentation/USAGE-SYNC.md +++ b/Documentation/USAGE-SYNC.md @@ -11,7 +11,7 @@ First you need to create a `clisync.yml` in your project directory, the CliTools of this file by using following command: ```bash -ct sync:init +ct sync-init ``` If you need special SSH settings (ports, compression, identify...) please use your `~/.ssh/config` file @@ -30,38 +30,38 @@ Now you can sync your `production` server to your local installation: ```bash # Full sync (files and database, with interactive context selection) -ct sync:server +ct sync # Only MySQL (from production context, without interactive context selection) -ct sync:server production --mysql +ct sync production --mysql # Only Files (from production context, without interactive context selection) -ct sync:server production --rsync +ct sync production --rsync ``` -## Project sharing (ct sync:backup and ct sync:restore) +## Project sharing (ct share:backup and ct share:restore) The sharing can be used to share files (assets) and databases between developers. Please use a common development/storage server with ssh access for each developer for this feature. ```bash # Make backup of current state and transfer to share server -ct sync:backup +ct share:backup # ... only MySQL -ct sync:backup --mysql +ct share:backup --mysql # ... only files -ct sync:backup --rsync +ct share:backup --rsync # Restore to state from the share server -ct sync:restore +ct share:restore # ... only MySQL -ct sync:restore --mysql +ct share:restore --mysql # ... only files -ct sync:restore --rsync +ct share:restore --rsync ``` @@ -69,20 +69,39 @@ ct sync:restore --rsync With `sync:deploy` you can push your files to your production servers. Please keep in mind that this feature is just an wrapped rsync and should only be -the simplest solution for deployment. For more advanced or centralized deployemnt try +the simplest solution for deployment. For more advanced or centralized deployment try solutions build on Jenkis, Ansible and others. ```bash # Push your project to your servers (with interactive context selection) -ct sync:deploy +ct deploy # Push your project to your staging server (without interactive context selection) -ct sync:deploy staging +ct deploy staging ``` +## Rsync additional options (rsync.opts) + +The rsync options `-rlptD --delete-after --progress --human-readable` are automatically added when using the sync +features of clitools. In addition, it is possible to set more options by adding them via `rsync.opts` (available since +version 2.3 of clitools). In the following example the option `--iconv=UTF8-MAC,UTF8` is added to enable rsync filename +charset conversion between local and remote file system. You need this especially when using rsync between hosts where a +charset conversion on filenames is necessary (see `man rsync` for further details; e.g.: you probably need this when +you sync between mac and linux utf-8 filesystem). + +``` +... +# Enable filename charset conversion where local is UTF8-MAC (Mac OSX) and remote is UTF8 (e.g. Linux) +rsync.opts: "--iconv=UTF8-MAC,UTF8" +... +``` + +If you run into problems with `--iconv` make shure you have a compatible version of rsync >= 3.0 (as already mentioned +in the [install section](INSTALL.md) of this documentation). + ## Advanced ssh options -If you need some advaned ssh options (eg. other ports) use your `~/.ssh/config` configuration file: +If you need some advanced ssh options (eg. other ports) use your `~/.ssh/config` configuration file: Host project-server Hostname project-server.example.com diff --git a/Makefile b/Makefile index 80ab517..114af40 100644 --- a/Makefile +++ b/Makefile @@ -9,5 +9,8 @@ install: autoload: sh -c "cd src ; composer dump-autoload --optimize --no-dev" +update: + sh -c "cd src ; composer update" + sloccount: sloccount src/app/ src/command.php diff --git a/README.md b/README.md index eb93636..20d0f91 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # CliTools for Docker, PHP und MySQL development -[![latest v2.2.0](https://img.shields.io/badge/latest-v2.2.0-green.svg?style=flat)](https://github.com/webdevops/clitools/releases/tag/2.2.0) +[![latest v2.3.0](https://img.shields.io/badge/latest-v2.3.0-green.svg?style=flat)](https://github.com/webdevops/clitools/releases/tag/2.3.0) [![License GPL3](https://img.shields.io/badge/license-GPL3-blue.svg?style=flat)](/LICENSE) [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/webdevops/clitools.svg)](http://isitmaintained.com/project/webdevops/clitools "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/webdevops/clitools.svg)](http://isitmaintained.com/project/webdevops/clitools "Percentage of issues still open") -[![SensioLabsInsight](https://insight.sensiolabs.com/projects/9f12f125-3623-4b9d-b01b-07090f91e416/big.png)](https://insight.sensiolabs.com/projects/9f12f125-3623-4b9d-b01b-07090f91e416) +[![SensioLabsInsight](https://insight.sensiolabs.com/projects/57b021a7-35a7-486f-80c8-e3fc6dee426c/big.png)](https://insight.sensiolabs.com/projects/57b021a7-35a7-486f-80c8-e3fc6dee426c) ## Introduction @@ -32,6 +32,7 @@ Thanks for support, ideas and issues ... - [Florian Tatzel](https://twitter.com/PanadeEdu) - [Philipp Kitzberger](https://github.com/Kitzberger) - [Josef Glatz](https://github.com/jousch) +- [Alexander Grein](https://github.com/rabe69) - my (old) colleagues at [Lightwerk GmbH](http://www.lightwerk.de/) - my colleagues at [cron IT GmbH](http://www.cron.eu/) diff --git a/compile.sh b/compile.sh index d1a67b2..722719f 100755 --- a/compile.sh +++ b/compile.sh @@ -5,7 +5,18 @@ set -o errtrace # trace ERR through 'time command' and other functions set -o nounset ## set -u : exit the script if you try to use an uninitialised variable set -o errexit ## set -e : exit the script if any statement returns a non-true return value -SCRIPT_DIR=$(dirname $(readlink -f "$0")) +READLINK='readlink' + +[[ `uname` == 'Darwin' ]] && { + which greadlink > /dev/null && { + READLINK='greadlink' + } || { + echo 'ERROR: GNU utils required for Mac. You may use homebrew to install them: brew install coreutils gnu-sed' + exit 1 + } +} + +SCRIPT_DIR=$(dirname $($READLINK -f "$0")) OLD_PWD=`pwd` @@ -19,6 +30,14 @@ composer dump-autoload --optimize --no-dev ## create phar cd "$SCRIPT_DIR/" -box.phar build -c box.json + +if hash box.phar 2>/dev/null; then + box.phar build -c box.json +elif hash box 2>/dev/null; then + box build -c box.json +else + echo 'ERROR: box.phar (box-project/box2) not found' + exit 1 +fi cd "$OLD_PWD" diff --git a/src/app/CliTools/Console/Application.php b/src/app/CliTools/Console/Application.php index 03acfc2..6ba0f25 100644 --- a/src/app/CliTools/Console/Application.php +++ b/src/app/CliTools/Console/Application.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -214,6 +215,11 @@ protected function configureIO(InputInterface $input, OutputInterface $output) $style->setPadding(' [EE] '); $output->getFormatter() ->setStyle('p-error', $style); + + $style = new OutputFormatterStyle('yellow'); + $style->setPadding(' [!!!] '); + $output->getFormatter() + ->setStyle('warning', $style); } /** @@ -262,7 +268,7 @@ protected function initializeErrorHandler() protected function initializeChecks() { if (!function_exists('pcntl_signal')) { - echo ' [ERROR] PHP-Module pcnt not loaded'; + echo ' [ERROR] PHP-Module pcntl not loaded'; exit(1); } } diff --git a/src/app/CliTools/Console/Command/AbstractCommand.php b/src/app/CliTools/Console/Command/AbstractCommand.php index 18d6989..b93b57c 100644 --- a/src/app/CliTools/Console/Command/AbstractCommand.php +++ b/src/app/CliTools/Console/Command/AbstractCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -260,6 +261,11 @@ public function getApplication() */ public function setTerminalTitle($title) { + // no title if stdout redirect + if(!posix_isatty(STDOUT)) { + return; + } + $args = func_get_args(); $titleList = array(); diff --git a/src/app/CliTools/Console/Command/AbstractTraceCommand.php b/src/app/CliTools/Console/Command/AbstractTraceCommand.php index 6d4d025..dde604c 100644 --- a/src/app/CliTools/Console/Command/AbstractTraceCommand.php +++ b/src/app/CliTools/Console/Command/AbstractTraceCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Apache/RestartCommand.php b/src/app/CliTools/Console/Command/Apache/RestartCommand.php index 6509319..6b3bde4 100644 --- a/src/app/CliTools/Console/Command/Apache/RestartCommand.php +++ b/src/app/CliTools/Console/Command/Apache/RestartCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Apache/TraceCommand.php b/src/app/CliTools/Console/Command/Apache/TraceCommand.php index d9659e7..57f1291 100644 --- a/src/app/CliTools/Console/Command/Apache/TraceCommand.php +++ b/src/app/CliTools/Console/Command/Apache/TraceCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Common/FixRightsCommand.php b/src/app/CliTools/Console/Command/Common/FixRightsCommand.php index 26645f3..624e876 100644 --- a/src/app/CliTools/Console/Command/Common/FixRightsCommand.php +++ b/src/app/CliTools/Console/Command/Common/FixRightsCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Common/MakeCommand.php b/src/app/CliTools/Console/Command/Common/MakeCommand.php index ad855d2..9d15f9f 100644 --- a/src/app/CliTools/Console/Command/Common/MakeCommand.php +++ b/src/app/CliTools/Console/Command/Common/MakeCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Common/SelfUpdateCommand.php b/src/app/CliTools/Console/Command/Common/SelfUpdateCommand.php index e8e3545..6e276ee 100644 --- a/src/app/CliTools/Console/Command/Common/SelfUpdateCommand.php +++ b/src/app/CliTools/Console/Command/Common/SelfUpdateCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Docker/AbstractCommand.php b/src/app/CliTools/Console/Command/Docker/AbstractCommand.php index 13c6db5..cf881a0 100644 --- a/src/app/CliTools/Console/Command/Docker/AbstractCommand.php +++ b/src/app/CliTools/Console/Command/Docker/AbstractCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -54,7 +55,29 @@ protected function getDockerPath() } /** - * Execute docker command + * Find and get docker environment variable + * + * @param string $containerName Container name + * @param array $envNameList Environment variable (list) + * + * @return string|bool|null + */ + protected function findAndGetDockerEnv($containerName, array $envNameList) + { + $ret = null; + + foreach ($envNameList as $envName) { + if ($tmp = $this->getDockerEnv($containerName, $envName) ) { + $ret = $tmp; + break; + } + } + + return $ret; + } + + /** + * Get docker environment variable * * @param string $containerName Container name * @param string $envName Environment variable diff --git a/src/app/CliTools/Console/Command/Docker/CleanupCommand.php b/src/app/CliTools/Console/Command/Docker/CleanupCommand.php new file mode 100644 index 0000000..5dab9f4 --- /dev/null +++ b/src/app/CliTools/Console/Command/Docker/CleanupCommand.php @@ -0,0 +1,90 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +use CliTools\Shell\CommandBuilder\CommandBuilder; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class CleanupCommand extends AbstractCommand +{ + + /** + * Configure command + */ + protected function configure() + { + $this->setName('docker:cleanup') + ->setDescription('Cleanup docker environment'); + } + + /** + * Execute command + * + * @param InputInterface $input Input instance + * @param OutputInterface $output Output instance + * + * @return int|null|void + */ + public function execute(InputInterface $input, OutputInterface $output) + { + $this->cleanDockerImages(); + $this->cleanDockerVolumes(); + $output->writeln('Cleanup finished'); + } + + /** + * Clean docker images + */ + protected function cleanDockerImages() + { + $this->output->writeln('

Cleanup orphaned docker images

'); + try { + $command = new CommandBuilder('docker', 'rmi $(docker images -qf "dangling=true")'); + $command->executeInteractive(); + + } catch (\Exception $e) { + $this->output->writeln('Some images could not be removed (this is normal)'); + } + + $this->output->writeln(''); + } + + /** + * Clean docker volumes + */ + protected function cleanDockerVolumes() + { + $this->output->writeln('

Cleanup orphaned docker volumes

'); + $this->output->writeln('Updating docker image "martin/docker-cleanup-volumes"'); + + $command = new CommandBuilder('docker', 'pull martin/docker-cleanup-volumes'); + $command->executeInteractive(); + + $this->output->writeln('Run docker image "martin/docker-cleanup-volumes"'); + $command = new CommandBuilder('docker', 'run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes'); + $command->executeInteractive(); + + $this->output->writeln(''); + } + +} diff --git a/src/app/CliTools/Console/Command/Docker/CliCommand.php b/src/app/CliTools/Console/Command/Docker/CliCommand.php index 14cc03b..18dab88 100644 --- a/src/app/CliTools/Console/Command/Docker/CliCommand.php +++ b/src/app/CliTools/Console/Command/Docker/CliCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -21,6 +22,7 @@ */ use CliTools\Shell\CommandBuilder\RemoteCommandBuilder; +use CliTools\Utility\PhpUtility; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -34,7 +36,7 @@ protected function configure() { $this->setName('docker:cli') ->setDescription( - 'Run cli command in docker container (defined by CLI_SCRIPT and CLI_USER as docker environment variable)' + 'Run cli command in docker container' ); } @@ -61,12 +63,19 @@ public function execute(InputInterface $input, OutputInterface $output) # with Docker exec (faster, complex) ########################### case 'docker-exec': - $cliScript = $this->getDockerEnv($container, 'CLI_SCRIPT'); - $cliUser = $this->getDockerEnv($container, 'CLI_USER'); + $scriptEnvVar = $this->getApplication()->getConfigValue('docker', 'script_env_vars'); + + // Try to find defined script + $scriptVarList = PhpUtility::trimExplode(',', $scriptEnvVar); + $cliScript = $this->findAndGetDockerEnv($container, $scriptVarList); + + // Try to find defined username + $userVarList = PhpUtility::trimExplode(',', $this->getApplication()->getConfigValue('docker', 'user_env_vars')); + $cliUser = $this->findAndGetDockerEnv($container, $userVarList); if (empty($cliScript)) { $output->writeln( - 'Docker container "' . $container . '" doesn\'t have environment variable "CLI_SCRIPT"' + 'Docker container "' . $container . '" doesn\'t have environment variables: ' . $scriptEnvVar . '' ); return 1; diff --git a/src/app/CliTools/Console/Command/Docker/ComposeCommand.php b/src/app/CliTools/Console/Command/Docker/ComposeCommand.php index 18fe29d..19b4212 100644 --- a/src/app/CliTools/Console/Command/Docker/ComposeCommand.php +++ b/src/app/CliTools/Console/Command/Docker/ComposeCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Docker/CreateCommand.php b/src/app/CliTools/Console/Command/Docker/CreateCommand.php index d6ba659..ac9d45e 100644 --- a/src/app/CliTools/Console/Command/Docker/CreateCommand.php +++ b/src/app/CliTools/Console/Command/Docker/CreateCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -82,28 +83,26 @@ public function execute(InputInterface $input, OutputInterface $output) { $currDir = getcwd(); - $path = $input->getArgument('path'); + $path = $input->getArgument('path'); + $boilerplateRepo = $this->getBoilerplateRepository(); + $codeRepo = $this->input->getOption('code'); - if ($this->input->getOption('docker')) { - // Custom boilerplate - $boilerplateRepo = $this->input->getOption('docker'); - } else { - // Boilerplate from config - $boilerplateRepo = $this->getApplication() - ->getConfigValue('docker', 'boilerplate'); - } $output->writeln('

Creating new docker boilerplate instance in "' . $path . '"

'); + $output->writeln('

Docker repository: ' . $boilerplateRepo . '

'); + if ($codeRepo) { + $output->writeln('

Code repository: ' . $codeRepo . '

'); + } // Init docker boilerplate $this->createDockerInstance($path, $boilerplateRepo); PhpUtility::chdir($currDir); // Init code - if ($this->input->getOption('code')) { + if ($codeRepo) { $output->writeln('

Init code repository

'); - $this->initCode($path, $input->getOption('code')); + $this->initCode($path, $codeRepo); PhpUtility::chdir($currDir); $output->writeln('

Init document root

'); @@ -137,6 +136,35 @@ public function execute(InputInterface $input, OutputInterface $output) return 0; } + /** + * Get boilerplate repository + * + * @return mixed|null + */ + protected function getBoilerplateRepository() { + $app = $this->getApplication(); + + // Boilerplate from config (legacy default) + $ret = $app->getConfigValue('docker', 'boilerplate'); + + // Boilerplate from config (default) + if (empty($ret)) { + $ret = $app->getConfigValue('dockerBoilerplate', 'default'); + } + + // Boilerplate from config (type) + if ($this->input->getOption('docker')) { + $ret = $app ->getConfigValue('dockerBoilerplate', $this->input->getOption('docker')); + + if (empty($ret)) { + // Custom boilerplate + $ret = $this->input->getOption('docker'); + } + } + + return $ret; + } + /** * Start interactive editor * diff --git a/src/app/CliTools/Console/Command/Docker/ExecCommand.php b/src/app/CliTools/Console/Command/Docker/ExecCommand.php index 7d06fc8..91c5a2d 100644 --- a/src/app/CliTools/Console/Command/Docker/ExecCommand.php +++ b/src/app/CliTools/Console/Command/Docker/ExecCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Docker/IftopCommand.php b/src/app/CliTools/Console/Command/Docker/IftopCommand.php index 2505528..e6b044c 100644 --- a/src/app/CliTools/Console/Command/Docker/IftopCommand.php +++ b/src/app/CliTools/Console/Command/Docker/IftopCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Docker/MysqlCommand.php b/src/app/CliTools/Console/Command/Docker/MysqlCommand.php index f094fc0..2d391d3 100644 --- a/src/app/CliTools/Console/Command/Docker/MysqlCommand.php +++ b/src/app/CliTools/Console/Command/Docker/MysqlCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Docker/RootCommand.php b/src/app/CliTools/Console/Command/Docker/RootCommand.php index 8ac1e19..efacd45 100644 --- a/src/app/CliTools/Console/Command/Docker/RootCommand.php +++ b/src/app/CliTools/Console/Command/Docker/RootCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Docker/ShellCommand.php b/src/app/CliTools/Console/Command/Docker/ShellCommand.php index afda45d..cf19d5f 100644 --- a/src/app/CliTools/Console/Command/Docker/ShellCommand.php +++ b/src/app/CliTools/Console/Command/Docker/ShellCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -21,6 +22,7 @@ */ use CliTools\Shell\CommandBuilder\RemoteCommandBuilder; +use CliTools\Utility\PhpUtility; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -70,8 +72,8 @@ public function execute(InputInterface $input, OutputInterface $output) // User user by option $cliUser = $input->getOption('user'); } else { - // Use docker env - $cliUser = $this->getDockerEnv($container, 'CLI_USER'); + $userVarList = PhpUtility::trimExplode(',', $this->getApplication()->getConfigValue('docker', 'user_env_vars')); + $cliUser = $this->findAndGetDockerEnv($container, $userVarList); } $this->setTerminalTitle('docker', 'shell', $container); diff --git a/src/app/CliTools/Console/Command/Docker/SniffCommand.php b/src/app/CliTools/Console/Command/Docker/SniffCommand.php index 8ce73fc..e96f389 100644 --- a/src/app/CliTools/Console/Command/Docker/SniffCommand.php +++ b/src/app/CliTools/Console/Command/Docker/SniffCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Docker/UpCommand.php b/src/app/CliTools/Console/Command/Docker/UpCommand.php index 186335e..2521903 100644 --- a/src/app/CliTools/Console/Command/Docker/UpCommand.php +++ b/src/app/CliTools/Console/Command/Docker/UpCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -58,6 +59,8 @@ public function execute(InputInterface $input, OutputInterface $output) $lastDockerPath = $this->getApplication() ->getSettingsService() ->get('docker.up.last'); + $dockerComposeArgs = $this->getApplication() + ->getConfigValue('dockerCompose', 'up'); if (!empty($dockerPath)) { $dockerPath = dirname($dockerPath); @@ -77,7 +80,7 @@ public function execute(InputInterface $input, OutputInterface $output) // Start current docker containers $this->output->writeln('

Start docker containers in "' . $dockerPath . '"

'); - $command = new CommandBuilder(null, 'up -d'); + $command = new CommandBuilder(null, $dockerComposeArgs); $ret = $this->executeDockerCompose($command); // Store docker path in settings (last docker startup) diff --git a/src/app/CliTools/Console/Command/Log/ApacheCommand.php b/src/app/CliTools/Console/Command/Log/ApacheCommand.php index e08a8dd..bc9cf96 100644 --- a/src/app/CliTools/Console/Command/Log/ApacheCommand.php +++ b/src/app/CliTools/Console/Command/Log/ApacheCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Log/DebugCommand.php b/src/app/CliTools/Console/Command/Log/DebugCommand.php index 183bc17..679d80c 100644 --- a/src/app/CliTools/Console/Command/Log/DebugCommand.php +++ b/src/app/CliTools/Console/Command/Log/DebugCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Log/MailCommand.php b/src/app/CliTools/Console/Command/Log/MailCommand.php index 2231a30..398c0b3 100644 --- a/src/app/CliTools/Console/Command/Log/MailCommand.php +++ b/src/app/CliTools/Console/Command/Log/MailCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Log/PhpCommand.php b/src/app/CliTools/Console/Command/Log/PhpCommand.php index a78609d..1f4c77e 100644 --- a/src/app/CliTools/Console/Command/Log/PhpCommand.php +++ b/src/app/CliTools/Console/Command/Log/PhpCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Mysql/AbstractCommand.php b/src/app/CliTools/Console/Command/Mysql/AbstractCommand.php index 4fd16bd..0453076 100644 --- a/src/app/CliTools/Console/Command/Mysql/AbstractCommand.php +++ b/src/app/CliTools/Console/Command/Mysql/AbstractCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Mysql/BackupCommand.php b/src/app/CliTools/Console/Command/Mysql/BackupCommand.php index 65d3e93..e010934 100644 --- a/src/app/CliTools/Console/Command/Mysql/BackupCommand.php +++ b/src/app/CliTools/Console/Command/Mysql/BackupCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Mysql/ClearCommand.php b/src/app/CliTools/Console/Command/Mysql/ClearCommand.php index a1dde42..aba847e 100644 --- a/src/app/CliTools/Console/Command/Mysql/ClearCommand.php +++ b/src/app/CliTools/Console/Command/Mysql/ClearCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Mysql/ConnectionsCommand.php b/src/app/CliTools/Console/Command/Mysql/ConnectionsCommand.php index 6f121c3..3ecac85 100644 --- a/src/app/CliTools/Console/Command/Mysql/ConnectionsCommand.php +++ b/src/app/CliTools/Console/Command/Mysql/ConnectionsCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Mysql/ConvertCommand.php b/src/app/CliTools/Console/Command/Mysql/ConvertCommand.php index 2164262..62ac5f1 100644 --- a/src/app/CliTools/Console/Command/Mysql/ConvertCommand.php +++ b/src/app/CliTools/Console/Command/Mysql/ConvertCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Mysql/DebugCommand.php b/src/app/CliTools/Console/Command/Mysql/DebugCommand.php index 98d3a41..d07b12d 100644 --- a/src/app/CliTools/Console/Command/Mysql/DebugCommand.php +++ b/src/app/CliTools/Console/Command/Mysql/DebugCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Mysql/DropCommand.php b/src/app/CliTools/Console/Command/Mysql/DropCommand.php index 9ef9417..515cd5e 100644 --- a/src/app/CliTools/Console/Command/Mysql/DropCommand.php +++ b/src/app/CliTools/Console/Command/Mysql/DropCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Mysql/ListCommand.php b/src/app/CliTools/Console/Command/Mysql/ListCommand.php index 89e32e7..1dd656d 100644 --- a/src/app/CliTools/Console/Command/Mysql/ListCommand.php +++ b/src/app/CliTools/Console/Command/Mysql/ListCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Mysql/RestartCommand.php b/src/app/CliTools/Console/Command/Mysql/RestartCommand.php index 3ac9520..027754d 100644 --- a/src/app/CliTools/Console/Command/Mysql/RestartCommand.php +++ b/src/app/CliTools/Console/Command/Mysql/RestartCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Mysql/RestoreCommand.php b/src/app/CliTools/Console/Command/Mysql/RestoreCommand.php index 73d9386..ccfc999 100644 --- a/src/app/CliTools/Console/Command/Mysql/RestoreCommand.php +++ b/src/app/CliTools/Console/Command/Mysql/RestoreCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Mysql/SlowLogCommand.php b/src/app/CliTools/Console/Command/Mysql/SlowLogCommand.php index 99e449e..c5959d5 100644 --- a/src/app/CliTools/Console/Command/Mysql/SlowLogCommand.php +++ b/src/app/CliTools/Console/Command/Mysql/SlowLogCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Php/ComposerCommand.php b/src/app/CliTools/Console/Command/Php/ComposerCommand.php index 123657e..f71dd8e 100644 --- a/src/app/CliTools/Console/Command/Php/ComposerCommand.php +++ b/src/app/CliTools/Console/Command/Php/ComposerCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -51,20 +52,28 @@ public function execute(InputInterface $input, OutputInterface $output) { $paramList = $this->getFullParameterList(); + // Get composer.json from env variable + $composerJson = getenv('COMPOSER'); + if (empty($composerJson)) { + $composerJson = 'composer.json'; + } + if ($this->checkIfComposerJsonIsNeeded($paramList)) { - $composerJsonPath = UnixUtility::findFileInDirectortyTree('composer.json'); + $composerJsonPath = UnixUtility::findFileInDirectortyTree($composerJson); if (!empty($composerJsonPath)) { + // composer.json found + $path = dirname($composerJsonPath); - $this->output->writeln('Found composer.json directory: ' . $path . ''); + $this->output->writeln('Found ' . $composerJson . ' directory: ' . $path . ''); // Switch to directory of docker-compose.yml PhpUtility::chdir($path); return $this->runComposer($paramList); } else { - $this->output->writeln('No composer.json found in tree'); - - return 1; + // no composer.json found but try to run the command anyway + $this->output->writeln('No ' . $composerJson . ' found in tree'); + return $this->runComposer($paramList); } } else { return $this->runComposer($paramList); diff --git a/src/app/CliTools/Console/Command/Php/RestartCommand.php b/src/app/CliTools/Console/Command/Php/RestartCommand.php index 5ae7585..75b8daa 100644 --- a/src/app/CliTools/Console/Command/Php/RestartCommand.php +++ b/src/app/CliTools/Console/Command/Php/RestartCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Php/TraceCommand.php b/src/app/CliTools/Console/Command/Php/TraceCommand.php index 723d90e..093eabd 100644 --- a/src/app/CliTools/Console/Command/Php/TraceCommand.php +++ b/src/app/CliTools/Console/Command/Php/TraceCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Samba/RestartCommand.php b/src/app/CliTools/Console/Command/Samba/RestartCommand.php index 069ef72..cc20136 100644 --- a/src/app/CliTools/Console/Command/Samba/RestartCommand.php +++ b/src/app/CliTools/Console/Command/Samba/RestartCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Sync/AbstractCommand.php b/src/app/CliTools/Console/Command/Sync/AbstractCommand.php index 6e56dbe..da9ed61 100644 --- a/src/app/CliTools/Console/Command/Sync/AbstractCommand.php +++ b/src/app/CliTools/Console/Command/Sync/AbstractCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -158,10 +159,13 @@ protected function validateConfiguration() $ret = true; // Rsync (optional) - if ($this->contextConfig->exists('rsync')) { + if ($this->contextConfig->exists('rsync.path')) { if (!$this->validateConfigurationRsync()) { $ret = false; } + } else { + // Clear rsync if any options set + $this->contextConfig->clear('rsync'); } // MySQL (optional) @@ -708,6 +712,11 @@ protected function createRsyncCommand( $command = new CommandBuilder('rsync', '-rlptD --delete-after --progress --human-readable'); + // Additional options + if ($this->contextConfig->exists('rsync.opts')) { + $command->addArgumentRaw($this->contextConfig->get('rsync.opts')); + } + // Add file list (external file with --include-from option) if (!empty($filelist)) { $this->rsyncAddFileList($command, $filelist); diff --git a/src/app/CliTools/Console/Command/Sync/AbstractRemoteSyncCommand.php b/src/app/CliTools/Console/Command/Sync/AbstractRemoteSyncCommand.php index fe16d51..b2762e7 100644 --- a/src/app/CliTools/Console/Command/Sync/AbstractRemoteSyncCommand.php +++ b/src/app/CliTools/Console/Command/Sync/AbstractRemoteSyncCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Sync/AbstractShareCommand.php b/src/app/CliTools/Console/Command/Sync/AbstractShareCommand.php index b2e05ae..eaf63e7 100644 --- a/src/app/CliTools/Console/Command/Sync/AbstractShareCommand.php +++ b/src/app/CliTools/Console/Command/Sync/AbstractShareCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Sync/BackupCommand.php b/src/app/CliTools/Console/Command/Sync/BackupCommand.php index 9a4e551..6c98582 100644 --- a/src/app/CliTools/Console/Command/Sync/BackupCommand.php +++ b/src/app/CliTools/Console/Command/Sync/BackupCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -32,7 +33,7 @@ protected function configure() { parent::configure(); - $this->setName('sync:backup') + $this->setName('share:backup') ->setDescription('Backup files and database from share'); } diff --git a/src/app/CliTools/Console/Command/Sync/DeployCommand.php b/src/app/CliTools/Console/Command/Sync/DeployCommand.php index 637c3a7..fc3279d 100644 --- a/src/app/CliTools/Console/Command/Sync/DeployCommand.php +++ b/src/app/CliTools/Console/Command/Sync/DeployCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -34,7 +35,7 @@ protected function configure() $this->confArea = 'deploy'; - $this->setName('sync:deploy') + $this->setName('deploy') ->setDescription('Deploy files and database to server'); } diff --git a/src/app/CliTools/Console/Command/Sync/InitCommand.php b/src/app/CliTools/Console/Command/Sync/InitCommand.php index 09ecfb3..affa975 100644 --- a/src/app/CliTools/Console/Command/Sync/InitCommand.php +++ b/src/app/CliTools/Console/Command/Sync/InitCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -33,7 +34,7 @@ class InitCommand extends \CliTools\Console\Command\AbstractCommand */ protected function configure() { - $this->setName('sync:init') + $this->setName('sync-init') ->setDescription('Create example clisync.yml'); } diff --git a/src/app/CliTools/Console/Command/Sync/RestoreCommand.php b/src/app/CliTools/Console/Command/Sync/RestoreCommand.php index 3601733..b72927c 100644 --- a/src/app/CliTools/Console/Command/Sync/RestoreCommand.php +++ b/src/app/CliTools/Console/Command/Sync/RestoreCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -30,7 +31,7 @@ protected function configure() { parent::configure(); - $this->setName('sync:restore') + $this->setName('share:restore') ->setDescription('Restore files and database from share'); } diff --git a/src/app/CliTools/Console/Command/Sync/ServerCommand.php b/src/app/CliTools/Console/Command/Sync/ServerCommand.php index 51cbbc2..1e85336 100644 --- a/src/app/CliTools/Console/Command/Sync/ServerCommand.php +++ b/src/app/CliTools/Console/Command/Sync/ServerCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -34,7 +35,7 @@ protected function configure() $this->confArea = 'sync'; - $this->setName('sync:server') + $this->setName('sync') ->setDescription('Sync files and database from server'); } diff --git a/src/app/CliTools/Console/Command/System/BannerCommand.php b/src/app/CliTools/Console/Command/System/BannerCommand.php index bc4f6a7..01873c0 100644 --- a/src/app/CliTools/Console/Command/System/BannerCommand.php +++ b/src/app/CliTools/Console/Command/System/BannerCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -126,6 +127,7 @@ protected function generateSystemInfo() $kernelVersion = UnixUtility::kernelVersion(); $dockerVersion = UnixUtility::dockerVersion(); $mountInfoList = UnixUtility::mountInfoList(); + $mailCount = $this->getMailCount(); // Padding $memSize = str_pad($memSize, $bytesPadding, ' ', STR_PAD_LEFT); @@ -164,7 +166,13 @@ protected function generateSystemInfo() foreach ($netInterfaceList as $netName => $netConf) { $netName = str_pad($netName, $labelLength, ' ', STR_PAD_LEFT); - $rightCol[] = $netName . ': ' . $netConf['ipaddress']; + $rightCol[] = str_pad($netName, $labelLength, ' ', STR_PAD_LEFT) . ': ' . $netConf['ipaddress']; + } + + $rightCol[] = ''; + + if ($mailCount !== null) { + $rightCol[] = str_pad('Mails', $labelLength, ' ', STR_PAD_LEFT) . ': ' . $mailCount; } // ################## @@ -205,4 +213,122 @@ protected function generateSystemInfo() return implode("\n", $ret); } + + /** + * Get mail count + */ + protected function getMailCount() + { + $ret = null; + $mailboxUri = $this->getApplication()->getConfigValue('banner', 'mailbox'); + + if (!empty($mailboxUri) && function_exists('imap_open')) { + try { + $mailboxConf = parse_url($mailboxUri); + + $hostname = $this->buildMailboxServerString($mailboxConf); + $username = $mailboxConf['user']; + $password = $mailboxConf['pass']; + + $mail = imap_open($hostname, $username, $password); + $res = imap_check($mail); + imap_close($mail); + + if (!empty($res)) { + $ret = $res->Nmsgs; + } else { + throw new \RuntimeException('Mailcheck failed'); + } + } catch (\Exception $e) { + $ret = 'error'; + } + } + + return $ret; + } + + /** + * Build imap connection string + * + * @param array $mailboxConf Mailbox configuration + * @return string + */ + protected function buildMailboxServerString(array $mailboxConf) + { + $hostname = $mailboxConf['host']; + $path = ltrim($mailboxConf['path'],'/'); + + switch ($mailboxConf['scheme']) { + case 'imap-insecure': + $port = !empty($mailboxConf['port']) ? $mailboxConf['port'] : 143; + + $ret = sprintf( + '{%s:%s/novalidate-cert/norsh}%s', + $hostname, + $port, + $path + ); + break; + + case 'imap': + $port = !empty($mailboxConf['port']) ? $mailboxConf['port'] : 143; + + $ret = sprintf( + '{%s:%s}%s', + $hostname, + $port, + $path + ); + + break; + + case 'imap': + $port = !empty($mailboxConf['port']) ? $mailboxConf['port'] : 993; + + $ret = sprintf( + '{%s:%s/imap/ssl}%s', + $hostname, + $port, + $path + ); + break; + + + case 'pop3': + $port = !empty($mailboxConf['port']) ? $mailboxConf['port'] : 110; + + $ret = sprintf( + '{%s:%s/pop3}%s', + $hostname, + $port, + $path + ); + break; + + default: + throw new \RuntimeException('Mailbox scheme "' . $mailboxConf['scheme'] . '"" is not supported'); + break; + } + + return $ret; + } + + /** + * Build imap connection options + * + * @param array $mailboxConf Mailbox configuration + * @return integer + */ + protected function buildMailboxServerOptions(array $mailboxConf) + { + $ret = 0; + + switch ($mailboxConf['scheme']) { + case 'imap-insecure': + break; + } + + return $ret; + } } + diff --git a/src/app/CliTools/Console/Command/System/CrontaskCommand.php b/src/app/CliTools/Console/Command/System/CrontaskCommand.php index 736e590..8834273 100644 --- a/src/app/CliTools/Console/Command/System/CrontaskCommand.php +++ b/src/app/CliTools/Console/Command/System/CrontaskCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/System/EnvCommand.php b/src/app/CliTools/Console/Command/System/EnvCommand.php index 1c16417..5359258 100644 --- a/src/app/CliTools/Console/Command/System/EnvCommand.php +++ b/src/app/CliTools/Console/Command/System/EnvCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/System/OpenFilesCommand.php b/src/app/CliTools/Console/Command/System/OpenFilesCommand.php index 0e6666d..17db6f7 100644 --- a/src/app/CliTools/Console/Command/System/OpenFilesCommand.php +++ b/src/app/CliTools/Console/Command/System/OpenFilesCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/System/RebootCommand.php b/src/app/CliTools/Console/Command/System/RebootCommand.php index 1bebe11..d73a09a 100644 --- a/src/app/CliTools/Console/Command/System/RebootCommand.php +++ b/src/app/CliTools/Console/Command/System/RebootCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/System/ShutdownCommand.php b/src/app/CliTools/Console/Command/System/ShutdownCommand.php index 24c341e..3f3f968 100644 --- a/src/app/CliTools/Console/Command/System/ShutdownCommand.php +++ b/src/app/CliTools/Console/Command/System/ShutdownCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/System/StartupCommand.php b/src/app/CliTools/Console/Command/System/StartupCommand.php index 839b937..581056f 100644 --- a/src/app/CliTools/Console/Command/System/StartupCommand.php +++ b/src/app/CliTools/Console/Command/System/StartupCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/System/SwapCommand.php b/src/app/CliTools/Console/Command/System/SwapCommand.php index e7f27ac..7283f07 100644 --- a/src/app/CliTools/Console/Command/System/SwapCommand.php +++ b/src/app/CliTools/Console/Command/System/SwapCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/System/UpdateCommand.php b/src/app/CliTools/Console/Command/System/UpdateCommand.php index 53dc31b..6633585 100644 --- a/src/app/CliTools/Console/Command/System/UpdateCommand.php +++ b/src/app/CliTools/Console/Command/System/UpdateCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/System/VersionCommand.php b/src/app/CliTools/Console/Command/System/VersionCommand.php index 28ccc2d..07a225a 100644 --- a/src/app/CliTools/Console/Command/System/VersionCommand.php +++ b/src/app/CliTools/Console/Command/System/VersionCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/TYPO3/BeUserCommand.php b/src/app/CliTools/Console/Command/TYPO3/BeUserCommand.php index 3ca0923..1664ae9 100644 --- a/src/app/CliTools/Console/Command/TYPO3/BeUserCommand.php +++ b/src/app/CliTools/Console/Command/TYPO3/BeUserCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/TYPO3/CleanupCommand.php b/src/app/CliTools/Console/Command/TYPO3/CleanupCommand.php index 0b3d639..4a58b13 100644 --- a/src/app/CliTools/Console/Command/TYPO3/CleanupCommand.php +++ b/src/app/CliTools/Console/Command/TYPO3/CleanupCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/TYPO3/ClearCacheCommand.php b/src/app/CliTools/Console/Command/TYPO3/ClearCacheCommand.php index de82287..7974472 100644 --- a/src/app/CliTools/Console/Command/TYPO3/ClearCacheCommand.php +++ b/src/app/CliTools/Console/Command/TYPO3/ClearCacheCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/TYPO3/DomainCommand.php b/src/app/CliTools/Console/Command/TYPO3/DomainCommand.php index 2203c28..5359cf3 100644 --- a/src/app/CliTools/Console/Command/TYPO3/DomainCommand.php +++ b/src/app/CliTools/Console/Command/TYPO3/DomainCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/TYPO3/InstallerCommand.php b/src/app/CliTools/Console/Command/TYPO3/InstallerCommand.php index bd17d9d..e5f90ed 100644 --- a/src/app/CliTools/Console/Command/TYPO3/InstallerCommand.php +++ b/src/app/CliTools/Console/Command/TYPO3/InstallerCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/TYPO3/ListCommand.php b/src/app/CliTools/Console/Command/TYPO3/ListCommand.php index 2839068..a3277ea 100644 --- a/src/app/CliTools/Console/Command/TYPO3/ListCommand.php +++ b/src/app/CliTools/Console/Command/TYPO3/ListCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/TYPO3/SchedulerCommand.php b/src/app/CliTools/Console/Command/TYPO3/SchedulerCommand.php index 46b5c74..2f2ef03 100644 --- a/src/app/CliTools/Console/Command/TYPO3/SchedulerCommand.php +++ b/src/app/CliTools/Console/Command/TYPO3/SchedulerCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/User/RebuildSshConfigCommand.php b/src/app/CliTools/Console/Command/User/RebuildSshConfigCommand.php index b140e67..c696c44 100644 --- a/src/app/CliTools/Console/Command/User/RebuildSshConfigCommand.php +++ b/src/app/CliTools/Console/Command/User/RebuildSshConfigCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Command/Vagrant/ShareCommand.php b/src/app/CliTools/Console/Command/Vagrant/ShareCommand.php index 7daa36c..1c2aae4 100644 --- a/src/app/CliTools/Console/Command/Vagrant/ShareCommand.php +++ b/src/app/CliTools/Console/Command/Vagrant/ShareCommand.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Filter/AnyParameterFilterInterface.php b/src/app/CliTools/Console/Filter/AnyParameterFilterInterface.php index 5febac6..097f7a1 100644 --- a/src/app/CliTools/Console/Filter/AnyParameterFilterInterface.php +++ b/src/app/CliTools/Console/Filter/AnyParameterFilterInterface.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Filter/OnlyRootFilterInterface.php b/src/app/CliTools/Console/Filter/OnlyRootFilterInterface.php index fccd1f0..e90b24f 100644 --- a/src/app/CliTools/Console/Filter/OnlyRootFilterInterface.php +++ b/src/app/CliTools/Console/Filter/OnlyRootFilterInterface.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Console/Formatter/OutputFormatterStyle.php b/src/app/CliTools/Console/Formatter/OutputFormatterStyle.php index 0c4c0b0..a2ccf47 100644 --- a/src/app/CliTools/Console/Formatter/OutputFormatterStyle.php +++ b/src/app/CliTools/Console/Formatter/OutputFormatterStyle.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Database/DatabaseConnection.php b/src/app/CliTools/Database/DatabaseConnection.php index 328deef..be0046b 100644 --- a/src/app/CliTools/Database/DatabaseConnection.php +++ b/src/app/CliTools/Database/DatabaseConnection.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Exception/CommandExecutionException.php b/src/app/CliTools/Exception/CommandExecutionException.php index abbba22..605838d 100644 --- a/src/app/CliTools/Exception/CommandExecutionException.php +++ b/src/app/CliTools/Exception/CommandExecutionException.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Exception/StopException.php b/src/app/CliTools/Exception/StopException.php index 92f6cd3..d85b8fa 100644 --- a/src/app/CliTools/Exception/StopException.php +++ b/src/app/CliTools/Exception/StopException.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Iterator/Filter/DirectoryFilter.php b/src/app/CliTools/Iterator/Filter/DirectoryFilter.php index 6b32218..d80b3d7 100644 --- a/src/app/CliTools/Iterator/Filter/DirectoryFilter.php +++ b/src/app/CliTools/Iterator/Filter/DirectoryFilter.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Iterator/Filter/ProcProcessDirectoryFilter.php b/src/app/CliTools/Iterator/Filter/ProcProcessDirectoryFilter.php index c1c614e..523a277 100644 --- a/src/app/CliTools/Iterator/Filter/ProcProcessDirectoryFilter.php +++ b/src/app/CliTools/Iterator/Filter/ProcProcessDirectoryFilter.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Iterator/Filter/RecursiveDirectoryFilter.php b/src/app/CliTools/Iterator/Filter/RecursiveDirectoryFilter.php index 465a4f1..77ca4ee 100644 --- a/src/app/CliTools/Iterator/Filter/RecursiveDirectoryFilter.php +++ b/src/app/CliTools/Iterator/Filter/RecursiveDirectoryFilter.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Iterator/Filter/Typo3RecursiveDirectoryFilter.php b/src/app/CliTools/Iterator/Filter/Typo3RecursiveDirectoryFilter.php index e3ca107..938444a 100644 --- a/src/app/CliTools/Iterator/Filter/Typo3RecursiveDirectoryFilter.php +++ b/src/app/CliTools/Iterator/Filter/Typo3RecursiveDirectoryFilter.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Reader/ConfigReader.php b/src/app/CliTools/Reader/ConfigReader.php index 52c4826..e3c1b87 100644 --- a/src/app/CliTools/Reader/ConfigReader.php +++ b/src/app/CliTools/Reader/ConfigReader.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Service/SelfUpdateService.php b/src/app/CliTools/Service/SelfUpdateService.php index 8b899fb..f1bcf13 100644 --- a/src/app/CliTools/Service/SelfUpdateService.php +++ b/src/app/CliTools/Service/SelfUpdateService.php @@ -6,6 +6,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Service/SettingsService.php b/src/app/CliTools/Service/SettingsService.php index 6bb847d..2e203df 100644 --- a/src/app/CliTools/Service/SettingsService.php +++ b/src/app/CliTools/Service/SettingsService.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Shell/CommandBuilder/AbstractCommandBuilder.php b/src/app/CliTools/Shell/CommandBuilder/AbstractCommandBuilder.php index c435615..370aafc 100644 --- a/src/app/CliTools/Shell/CommandBuilder/AbstractCommandBuilder.php +++ b/src/app/CliTools/Shell/CommandBuilder/AbstractCommandBuilder.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Shell/CommandBuilder/CommandBuilder.php b/src/app/CliTools/Shell/CommandBuilder/CommandBuilder.php index 40b7275..67e47d8 100644 --- a/src/app/CliTools/Shell/CommandBuilder/CommandBuilder.php +++ b/src/app/CliTools/Shell/CommandBuilder/CommandBuilder.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Shell/CommandBuilder/CommandBuilderInterface.php b/src/app/CliTools/Shell/CommandBuilder/CommandBuilderInterface.php index ba72be8..7642d8e 100644 --- a/src/app/CliTools/Shell/CommandBuilder/CommandBuilderInterface.php +++ b/src/app/CliTools/Shell/CommandBuilder/CommandBuilderInterface.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Shell/CommandBuilder/EditorCommandBuilder.php b/src/app/CliTools/Shell/CommandBuilder/EditorCommandBuilder.php index 16a3dc6..1367b94 100644 --- a/src/app/CliTools/Shell/CommandBuilder/EditorCommandBuilder.php +++ b/src/app/CliTools/Shell/CommandBuilder/EditorCommandBuilder.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Shell/CommandBuilder/FullSelfCommandBuilder.php b/src/app/CliTools/Shell/CommandBuilder/FullSelfCommandBuilder.php index 8292b5c..1ace9d3 100644 --- a/src/app/CliTools/Shell/CommandBuilder/FullSelfCommandBuilder.php +++ b/src/app/CliTools/Shell/CommandBuilder/FullSelfCommandBuilder.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Shell/CommandBuilder/MysqlCommandBuilder.php b/src/app/CliTools/Shell/CommandBuilder/MysqlCommandBuilder.php index fae2f37..214e797 100644 --- a/src/app/CliTools/Shell/CommandBuilder/MysqlCommandBuilder.php +++ b/src/app/CliTools/Shell/CommandBuilder/MysqlCommandBuilder.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Shell/CommandBuilder/OutputCombineCommandBuilder.php b/src/app/CliTools/Shell/CommandBuilder/OutputCombineCommandBuilder.php index 873116b..a918cca 100644 --- a/src/app/CliTools/Shell/CommandBuilder/OutputCombineCommandBuilder.php +++ b/src/app/CliTools/Shell/CommandBuilder/OutputCombineCommandBuilder.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Shell/CommandBuilder/RemoteCommandBuilder.php b/src/app/CliTools/Shell/CommandBuilder/RemoteCommandBuilder.php index 892a188..e83494b 100644 --- a/src/app/CliTools/Shell/CommandBuilder/RemoteCommandBuilder.php +++ b/src/app/CliTools/Shell/CommandBuilder/RemoteCommandBuilder.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Shell/CommandBuilder/SelfCommandBuilder.php b/src/app/CliTools/Shell/CommandBuilder/SelfCommandBuilder.php index d2e29fc..cbd6b1f 100644 --- a/src/app/CliTools/Shell/CommandBuilder/SelfCommandBuilder.php +++ b/src/app/CliTools/Shell/CommandBuilder/SelfCommandBuilder.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Shell/Executor.php b/src/app/CliTools/Shell/Executor.php index 754a80f..ec0bfa3 100644 --- a/src/app/CliTools/Shell/Executor.php +++ b/src/app/CliTools/Shell/Executor.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Utility/ConsoleUtility.php b/src/app/CliTools/Utility/ConsoleUtility.php index 7d0319b..3613e1b 100644 --- a/src/app/CliTools/Utility/ConsoleUtility.php +++ b/src/app/CliTools/Utility/ConsoleUtility.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Utility/DockerUtility.php b/src/app/CliTools/Utility/DockerUtility.php index 83b180e..07e002c 100644 --- a/src/app/CliTools/Utility/DockerUtility.php +++ b/src/app/CliTools/Utility/DockerUtility.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Utility/FilterUtility.php b/src/app/CliTools/Utility/FilterUtility.php index eb8d915..d10b06f 100644 --- a/src/app/CliTools/Utility/FilterUtility.php +++ b/src/app/CliTools/Utility/FilterUtility.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Utility/FormatUtility.php b/src/app/CliTools/Utility/FormatUtility.php index da381af..53d8005 100644 --- a/src/app/CliTools/Utility/FormatUtility.php +++ b/src/app/CliTools/Utility/FormatUtility.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Utility/PhpUtility.php b/src/app/CliTools/Utility/PhpUtility.php index 8a2b6ca..d7c6f38 100644 --- a/src/app/CliTools/Utility/PhpUtility.php +++ b/src/app/CliTools/Utility/PhpUtility.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -199,4 +200,37 @@ public static function getMimeType($file) return $ret; } + + + /** + * Get operating system name + * + * @return string + */ + public static function getOsName() + { + return php_uname('s'); + } + + /** + * Trim explode with filter + * + * @param string $delimiter Explode delimiter + * @param string $value Value string + * @param bool $noEmpty Filter no empty values + * @return array + */ + public static function trimExplode($delimiter, $value, $noEmpty = true) + { + $ret = array_map('trim', explode((string)$delimiter, (string)$value)); + + if ($noEmpty) { + $ret = array_filter($ret, function ($val) { + return strlen($val) !== 0; + }); + } + + return $ret; + } + } diff --git a/src/app/CliTools/Utility/Typo3Utility.php b/src/app/CliTools/Utility/Typo3Utility.php index f695e87..7e5da74 100644 --- a/src/app/CliTools/Utility/Typo3Utility.php +++ b/src/app/CliTools/Utility/Typo3Utility.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify diff --git a/src/app/CliTools/Utility/UnixUtility.php b/src/app/CliTools/Utility/UnixUtility.php index a28476d..bc00f3d 100644 --- a/src/app/CliTools/Utility/UnixUtility.php +++ b/src/app/CliTools/Utility/UnixUtility.php @@ -4,6 +4,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -127,7 +128,7 @@ public static function dockerVersion() */ public static function mountInfoList() { - $command = new CommandBuilder('df', '-a --type=ext3 --type=ext4 --type vmhgfs --type vboxsf --portability'); + $command = new CommandBuilder('df', '-a --type=ext3 --type=ext4 --type vmhgfs --type vboxsf --type prl_fs --portability'); $command->addPipeCommand(new CommandBuilder('tail', '--lines=+2')) ->addPipeCommand( new CommandBuilder('awk', '\'{ print $6 " " $3 " " $4 " " $5 }\'') diff --git a/src/command.php b/src/command.php index 5c27b74..067a221 100644 --- a/src/command.php +++ b/src/command.php @@ -3,6 +3,7 @@ /* * CliTools Command + * Copyright (C) 2016 WebDevOps.io * Copyright (C) 2015 Markus Blaschke * * This program is free software: you can redistribute it and/or modify @@ -20,7 +21,7 @@ */ error_reporting(E_ALL); -define('CLITOOLS_COMMAND_VERSION', '2.2.0'); +define('CLITOOLS_COMMAND_VERSION', '2.3.0'); define('CLITOOLS_ROOT_FS', __DIR__); require __DIR__ . '/vendor/autoload.php'; diff --git a/src/composer.json b/src/composer.json index 47f6a40..c2e61bb 100644 --- a/src/composer.json +++ b/src/composer.json @@ -4,7 +4,7 @@ { "type": "vcs", "url": "https://github.com/jamiebicknell/Growl-GNTP.git" } ], "require": { - "symfony/console": "2.7.1", + "symfony/console": "2.*", "jamiebicknell/Growl-GNTP": "dev-master", "symfony/yaml": "^2.6" }, diff --git a/src/composer.lock b/src/composer.lock index 85daa58..881dd5b 100644 --- a/src/composer.lock +++ b/src/composer.lock @@ -4,7 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "213c4108f51656b962708ab99263b946", + "hash": "7b023eac532864cff6d957dd51e5999c", + "content-hash": "793c058bfbcf5c7727f32d47ea5bff04", "packages": [ { "name": "jamiebicknell/Growl-GNTP", @@ -48,26 +49,26 @@ }, { "name": "symfony/console", - "version": "v2.7.1", + "version": "v2.8.1", "source": { "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "564398bc1f33faf92fc2ec86859983d30eb81806" + "url": "https://github.com/symfony/console.git", + "reference": "2e06a5ccb19dcf9b89f1c6a677a39a8df773635a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/564398bc1f33faf92fc2ec86859983d30eb81806", - "reference": "564398bc1f33faf92fc2ec86859983d30eb81806", + "url": "https://api.github.com/repos/symfony/console/zipball/2e06a5ccb19dcf9b89f1c6a677a39a8df773635a", + "reference": "2e06a5ccb19dcf9b89f1c6a677a39a8df773635a", "shasum": "" }, "require": { - "php": ">=5.3.9" + "php": ">=5.3.9", + "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/phpunit-bridge": "~2.7", - "symfony/process": "~2.1" + "symfony/event-dispatcher": "~2.1|~3.0.0", + "symfony/process": "~2.1|~3.0.0" }, "suggest": { "psr/log": "For using the console logger", @@ -77,13 +78,16 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "2.8-dev" } }, "autoload": { "psr-4": { "Symfony\\Component\\Console\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -101,38 +105,97 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2015-06-10 15:30:22" + "time": "2015-12-22 10:25:57" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "49ff736bd5d41f45240cec77b44967d76e0c3d25" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/49ff736bd5d41f45240cec77b44967d76e0c3d25", + "reference": "49ff736bd5d41f45240cec77b44967d76e0c3d25", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2015-11-20 09:19:13" }, { "name": "symfony/yaml", - "version": "v2.7.2", + "version": "v2.8.1", "source": { "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860" + "url": "https://github.com/symfony/yaml.git", + "reference": "ac84cbb98b68a6abbc9f5149eb96ccc7b07b8966" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/4bfbe0ed3909bfddd75b70c094391ec1f142f860", - "reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860", + "url": "https://api.github.com/repos/symfony/yaml/zipball/ac84cbb98b68a6abbc9f5149eb96ccc7b07b8966", + "reference": "ac84cbb98b68a6abbc9f5149eb96ccc7b07b8966", "shasum": "" }, "require": { "php": ">=5.3.9" }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "2.8-dev" } }, "autoload": { "psr-4": { "Symfony\\Component\\Yaml\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -150,7 +213,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-07-01 11:25:50" + "time": "2015-12-26 13:37:56" } ], "packages-dev": [], diff --git a/src/config.ini b/src/config.ini index 88f57c5..33bde80 100644 --- a/src/config.ini +++ b/src/config.ini @@ -23,11 +23,20 @@ diskusage = 90 [docker] container = main interface = docker0 -boilerplate = https://github.com/webdevops/php-docker-boilerplate.git +script_env_vars = CLI_SCRIPT +user_env_vars = CLI_USER,APPLICATION_USER climethod = docker-exec ; climethod = dockercompose-run +[dockerBoilerplate] +default = https://github.com/webdevops/php-docker-boilerplate.git +typo3 = https://github.com/webdevops/TYPO3-docker-boilerplate.git + +[dockerCompose] +up = up --force-recreate -d +rebuild = build --no-cache + [mysql-backup-filter] typo3[] = "/^cachingframework_.*/i" @@ -38,11 +47,14 @@ typo3[] = "/^sys_log$/i" typo3[] = "/^sys_history$/i" typo3[] = "/^tx_extbase_cache.*/i" +[banner] +mailbox = [commands] ; load following classes class[] = "CliTools\Console\Command\Common\SelfUpdateCommand" class[] = "CliTools\Console\Command\Common\MakeCommand" +class[] = "CliTools\Console\Command\Common\FixRightsCommand" class[] = "CliTools\Console\Command\Sync\InitCommand" class[] = "CliTools\Console\Command\Sync\ServerCommand" @@ -93,6 +105,7 @@ class[] = "CliTools\Console\Command\Docker\CliCommand" class[] = "CliTools\Console\Command\Docker\IftopCommand" class[] = "CliTools\Console\Command\Docker\CreateCommand" class[] = "CliTools\Console\Command\Docker\UpCommand" +class[] = "CliTools\Console\Command\Docker\CleanupCommand" class[] = "CliTools\Console\Command\System\SwapCommand" class[] = "CliTools\Console\Command\System\OpenFilesCommand"