X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=emig.d%2Fbin%2Fmig-env;h=250bd9fc61886499e329bb4c490a9f1cf9e7fbfb;hp=dceec4f28150e6d06cd7f4d47d73d3684b790783;hb=HEAD;hpb=155eb9eac077ca803f75d1295e584e7012e1b883 diff --git a/emig.d/bin/mig-env b/emig.d/bin/mig-env index dceec4f..250bd9f 100755 --- a/emig.d/bin/mig-env +++ b/emig.d/bin/mig-env @@ -22,7 +22,7 @@ B =head1 DESCRIPTION For most invocations, B will either create or use a migration-specific -file (~/.mig/.env) for setting the following environment +file (~/.emig/.env) for setting the following environment variables: =over 15 @@ -74,12 +74,12 @@ and migration work directory (which will also be created if needed). =item B This command will spawn a bash shell that executes the corresponding -~/.mig/.env script for setting up environment variables encoded during +~/.emig/.env script for setting up environment variables encoded during B. =item B [schema] -This command will show the contents of the corresponding ~/.mig/.env +This command will show the contents of the corresponding ~/.emig/.env script, or, if no schema is specified, then it will list pertinent variables in the current environment if they exist. @@ -91,7 +91,7 @@ separate schema name. =item B -This command will list migration schemas found in ~/.mig +This command will list migration schemas found in ~/.emig =item B @@ -119,7 +119,7 @@ use lib "$FindBin::Bin/"; pod2usage(-verbose => 2) if ! $ARGV[0]; my $migration_schema = $ARGV[1] || ''; -my $filename = "$HOME/.mig/$migration_schema.env"; +my $filename = "$HOME/.emig/$migration_schema.env"; switch($ARGV[0]) { case "--help" { pod2usage(-verbose => 2); @@ -134,7 +134,7 @@ switch($ARGV[0]) { case "clone" { pod2usage(-verbose => 1) if ! $ARGV[2]; $migration_schema = $ARGV[2] || ''; - $filename = "$HOME/.mig/$migration_schema.env"; + $filename = "$HOME/.emig/$migration_schema.env"; mig_env_clone(); } case "use" { @@ -153,7 +153,7 @@ switch($ARGV[0]) { } } case "list" { - opendir(my $dh, "$HOME/.mig") || die "can't open $HOME/.mig: $!"; + opendir(my $dh, "$HOME/.emig") || die "can't open $HOME/.emig: $!"; while (readdir $dh) { if (/^(.*)\.env$/) { print "$1\n"; @@ -231,7 +231,7 @@ sub mig_env_create { # create files and directories if needed - mkdir "$HOME/.mig"; + mkdir "$HOME/.emig"; make_path($MIGGITDIR, { verbose => 1 }); `touch $MIGGITDIR/README`; make_path($MIGWORKDIR, { verbose => 1 }); @@ -242,6 +242,7 @@ sub mig_env_create { print FILE "export PGDATABASE=$PGDATABASE\n"; print FILE "export PGUSER=$PGUSER\n"; print FILE "export PGOPTIONS='-c search_path=$migration_schema,public,evergreen'\n"; + print FILE "export MIGCMD=emig\n"; print FILE "export MIGENVPROMPT=$migration_schema\n"; print FILE "export MIGSCHEMA=$migration_schema\n"; print FILE "export MIGBASEWORKDIR=$MIGBASEWORKDIR\n"; @@ -251,6 +252,7 @@ sub mig_env_create { print FILE "alias wcd='cd `mig wdir`'\n"; print FILE "alias gcd='cd `mig gdir`'\n"; print FILE "alias scd='cd `mig sdir`'\n"; + print FILE "wcd\n"; print FILE "source ~/.profile\n"; print FILE "env | sort | egrep 'PG|MIG'\n"; print FILE 'echo shell PID = $$' . "\n"; @@ -259,7 +261,7 @@ sub mig_env_create { sub mig_env_clone { my $orig_migration_schema = $ARGV[1] || ''; - my $orig_filename = "$HOME/.mig/$orig_migration_schema.env"; + my $orig_filename = "$HOME/.emig/$orig_migration_schema.env"; `cp $orig_filename $filename`; `sed -i 's/export PGOPTIONS=.*/export PGOPTIONS='"'"'-c search_path=$migration_schema,public,evergreen'"'"'/' $filename`; `sed -i 's/export MIGENVPROMPT=.*/export MIGENVPROMPT=$migration_schema/' $filename`;