CliTools for Vagrant VM, Debian and Ubuntu (and others)
CliTools is a terminal utility for some handy convierence tasks based on Symfony Components (Console).
Documentation is still WIP :)
PHP 5.5 (CLI)
Tools
git
wget
multitail
tshark
tcpdump
ngrep
strace
lsof
sudo
moreutils (ifdata)
coreutils (grep, sort, uniq, awk, cat, df, ip, cut, lsb_release, wall)
docker and docker-compose (if you want to use docker)
mysql (if you want to use mysql)
# Download latest tools (or in ~/bin if you have it in $PATH)
wget -O/usr/local/bin/ct https://www.achenar.net/clicommand/clitools.phar
# Set executable bit
chmod 777 /usr/local/bin/ct
# Download example config
wget -O" $HOME /.clitools.ini" https://raw.githubusercontent.com/mblaschke/vagrant-development/develop/provision/ansible/roles/clitools/files/clitools.ini
Now you can use following aliases (some aliases requires clitools 1.8.0!):
# 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'
CliTools will read /etc/clitools.ini (system wide) and ~/.clitools.ini (personal) for configuration
The default configuration is inside the phar.
Docker specific configuration
[config]
; ssh_conf_path = "/vagrant/provision/sshconfig/"
[db]
dsn = " mysql:host=127.0.0.1;port=13306"
username = " root"
password = " dev"
debug_log_dir = " /tmp/debug/"
[syscheck]
enabled = 1
wall = 1
growl = 1
diskusage = 85
[growl]
server = 192.168.56.1
password =
[commands]
; not used commands here
ignore[] = " CliTools\Console\Command\Log\ApacheCommand"
ignore[] = " CliTools\Console\Command\Log\PhpCommand"
ignore[] = " CliTools\Console\Command\Log\DebugCommand"
ignore[] = " CliTools\Console\Command\Apache\RestartCommand"
ignore[] = " CliTools\Console\Command\Mysql\RestartCommand"
ignore[] = " CliTools\Console\Command\Php\RestartCommand"
ignore[] = " CliTools\Console\Command\System\UpdateCommand"
ignore[] = " CliTools\Console\Command\System\RebootCommand"
Command
Description
ct self-update
Update ct command (download new version)
ct update
Updates all system components, ssh configuration, ct command update etc.
ct make
Search for "Makefile" in tree and start "make" in this directory
Command
Description
ct shutdown (alias)
Shutdown system
All log commands are using a grep-filter (specified as optional argument)
Command
Description
ct log:mail
Shows mail logs
Command
Description
ct docker:create
Create new docker boilerplate in directory (first argument)
ct docker:create projectname -> Create new docker boilerplate instance in directory "projectname"
ct docker:create projectname --code=[email protected] /foo/bar -> Create new docker boilerplate instance in directory "projectname" and custom code repository
ct docker:create projectname --docker=[email protected] /foo/bar -> Create new docker boilerplate instance in directory "projectname" and custom docker boilerplate repository
ct docker:shell
Jump into a shell inside a docker container (using predefined user defined with CLI_USER in docker env)
ct docker:shell -> enter main container
ct docker:shell mysql -> enter mysql container
__ct docker:shell --user=www-data -> enter main container as user www-data
ct docker:root
Jump into a shell inside a docker container as root user
ct docker:mysql
Jump into a mysql client inside a docker container
ct docker:mysql -> execute mysql client inside main container
ct docker:sniff
Start network sniffer for various protocols
ct docker:sniff http -> start HTTP sniffing
ct docker:exec
Execute command in docker container
ct docker:exec ps -> run 'ps' inside main container
ct docker:cli
Execute special cli command in docker container
ct docker:cli scheduler -> run 'scheduler' in TYPO3 CMS
ct docker:compose
Execute docker-compose (recursive up-searching for docker-compose.yml)
ct docker:compose ps -> list all running docker-compose containers
Command
Description
ct mysql:clear
Clear database (remove all tables in database)
ct mysql:clear typo3
ct mysql:connections
Lists all current connections
ct mysql:create
Create (and drops if already exists) a database
ct mysql:create typo3
ct mysql:debug
Shows mysql debug log (lists all queries) with basic filter support
ct mysql:debug (full log)
ct mysql:debug tt_content (full log)
ct mysql:slowlog
Shows mysql slow log
ct mysql:slowlog (show slow queries with 1 sec and more)
ct mysql:slowlog --time=10 (show slow queries with 10 sec and more)
ct mysql:slowlog --no-index (show not using index and slow (1sec) queries)
ct mysql:drop
Drops a database
ct mysql:drop typo3
ct mysql:list
Lists all databases with some statitics
ct mysql:restart
Restart MySQL server
ct mysql:backup
Backup a database to file
Compression type will be detected from file extension (default plain sql)
ct mysql:restore typo3 dump.sql -> plain sql dump
ct mysql:restore typo3 dump.sql.gz -> gzip'ed sql dump
ct mysql:restore typo3 dump.sql.bzip2 -> bzip2'ed sql dump
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
and will automatically detected
ct mysql:restore typo3 dump.sql.bz2
ct mysql:convert
Convert character set and collation of a database
ct mysql:convert typo3 -> Convert typo3 into UTF-8 with utf8_general_ci
ct mysql:convert typo3 --charset=latin1 -> Convert typo3 into LATIN-1
ct mysql:convert typo3 --collation=utf8_unicode_ci -> Convert typo3 into UTF-8 with utf8_unicode_ci
ct mysql:convert typo3 --stdout -> Print sql statements to stdout
Command
Description
ct sync:init
Create example clisync.yml in current working directory
ct sync:backup
Search for clisync.yml in tree and start backup to shared server
ct sync:restore
Search for clisync.yml in tree and start restore from shared server
Command
Description
ct php:trace
Trace syscalls from one or all PHP processes (strace)
ct php:trace --all -> Trace all php processes immediately
ct php:composer
Search for "composer.yml" in tree and start "composer" in this directory
Command
Description
ct samba:restart
Restart Samba server
Command
Description
ct system:env
Lists common environment variables
ct system:openfiles
Lists current open files count grouped by process
ct system:shutdown
Shutdown system
ct system:swap
Show swap usage for running processes
ct system:update
Updates all system components, ssh configuration, ct command update etc.
ct system:version
Shows version for common packages
Command
Description
ct typo3:beuser
Injects a dev user (pass dev) to all or one specified TYPO3 database
ct typo3:beuser
ct typo3:beuser typo3
ct typo3:cleanup
Cleanup command tables to same some table space
ct typo3:cleanup
ct typo3:cleanup typo3
Command
Description
ct user:rebuildsshconfig
Rebuild SSH config from ct repository (/vagrant/provision/sshconfig)
Thanks to my colleagues at cron IT GmbH and Ingo Pfennigstorf for testing and some usefull ideas.