Wiki
Clone wikiMigBash / Home
MigBash
Simple way to accumulate and use bash utilities
Just provide -h parameter to show help info
#!bash $ ./migbash -h Usage: ./migbash [-m] [-h] ./migbash [module_name] [module_method] [options]...
#!bash
$ mv ./migbash.sh mb
#!bash
$ ./mb -h or whatever
#!bash
$ ./migbash.sh -m
You can simply use listed modules e.g.:
#!bash
$ ./migbash.sh db backup
$ ./migbash.sh wp add_user
$ ./migbash.sh migrate migrate
etc...
How to create simple module:
Go to migbash/modules folder. Feel free to create new folder if it's necessary or use existing one. Let's create new folder, it will be your module's name:
#!bash
$ mkdir foobar
#!bash showme() { echo "Hello from My module!" }
#!bash $ cd ../../
#!bash
$ ./migbash.sh foobar showme
#!bash
Hello from My module!
#!bash my_module_help() { echo -e "$(MigBash::color showme cyan black)$(MigBash::margin 16) – My first module ShowMe" }
MigBash internal methods:
Using MigBash::getVal paramName method you can retrieve value for provided parameter from a configuration file
#!bash # path to config file local settings='modules/'${module}'/db.ini' local db_user=$(MigBash::getVal db_user ${settings}) local db_pass=$(MigBash::getVal db_pass ${settings}) local config_path=$(MigBash::getVal path ${settings})
#!bash [backup] db_user=user db_pass=pass db_host=127.0.0.1 db_port=3306 path=/home/path/to/smth/
MigBash::color 'some text' foreground_color background_color
#!bash $(MigBash::color showme cyan black)
Also you can use MigBash::margin function to make margins for your text:
next call will shift the text position into 16 points
#!bash MigBash::margin 16
Some examples:
Using db backup module
You can make database backup with this command:
#!bash
$ ./migbash.sh db backup your_db_name /path/to/save/backup
#!bash
$ ./migbash.sh db backup
Path to place database backup:
The same way you can use , e.g. wordpress modules:
#!bash
$ ./migbash.sh wp add_user
$ ./migbash.sh wp change_domain
etc...
Updated