Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pre-processing to env.sh for things like encryption #142

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ var Future = require('fibers/future');

var syncSource = function (filepath) {
var future = new Future;
source(filepath, future.resolver());
var rootpath = path.parse(filepath).root;
var projectpath = filepath.split(path.sep).slice(0,-3).join(path.sep);
var handlerpath = path.join(rootpath, projectpath, 'bin', 'env_handler.sh');
source(filepath, {'wrapper': handlerpath}, future.resolver());
return future.wait();
};

Expand Down
24 changes: 24 additions & 0 deletions lib/templates/project/bin/env_handler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#######################################################################
# Use this script to do any pre-processing to your env.sh scripts #
#######################################################################
# Example below is decrypting your env.sh file before sourcing, #
# useful when you want to keep credentials out of the git repo. #
# Not useful for hiding credentials on server or developer machines. #
#######################################################################
#
# gpg2 --batch --quiet --no-verbose -d "$1" > /tmp/env.sh
# . /tmp/env.sh
# # Linux
# shred /tmp/env.sh
# # OSX
# srm /tmp/env.sh

# You only want to have one "source" command so if you do any
# pre-processing of your env.sh, like above, comment this next line out
# NOTE: Apparently using a the dot syntax instead of the `source`
# command is more portable. "$1" is variable with the path to env.sh
. "$1"

# DO NOT MODIFY BELOW THIS POINT
# Environment needs to be printed to console so it can be read in by iron
printenv