Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add OLDPWD preservation logic #178

Closed
wants to merge 1 commit into from

4 participants

@evanmcc

needed in riaknostic and possibly other things.
stores the original PWD and preserves it through
sudo, if necessary. it's unset by silly shell behavior
on at least OSX.

@evanmcc evanmcc add OLDPWD preservation logic
needed in riaknostic and possibly other things.
c395d49
@evanmcc

@mirell tracked down this issue in some detail here: https://gist.github.com/2986216

@slfritchie
Owner

Ping ... is this PR needed for Riak 2.0?

@trynity

The initial reason for this was to locate the script directory PATH from a running Riak instance.

Now, it seems that the main tool that would use this, riak-debug, cludges itself with RIAK_BIN_DIR to get the runner script directory: e175f02#diff-c6d6322b62b458c5abc1012ad9b412f7R214 via this pull request: #322

So who knows, @jonmeredith may have some thoughts.

@jaredmorrow

Closing this as there has not been any activity on this and it hasn't come up in the field recently. We can reopen if it is deemed an issue in riak-debug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 29, 2012
  1. @evanmcc

    add OLDPWD preservation logic

    evanmcc authored
    needed in riaknostic and possibly other things.
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 2 deletions.
  1. +6 −1 rel/files/riak
  2. +6 −1 rel/files/riak-admin
View
7 rel/files/riak
@@ -13,6 +13,11 @@ if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
fi
unset POSIX_SHELL # clear it so if we invoke other scripts, they run as ksh as well
+#OLDPWD isn't properly set on OSX, so cheat
+if [ ! "$CALLING_DIR" ]; then
+ export CALLING_DIR=`pwd`
+fi
+
RUNNER_SCRIPT_DIR={{runner_script_dir}}
RUNNER_SCRIPT=${0##*/}
@@ -37,7 +42,7 @@ if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" != "x$RUNNER_USER" ]); then
exit 1
fi
echo "Attempting to restart script through sudo -u $RUNNER_USER"
- exec sudo -u $RUNNER_USER -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
+ exec sudo -u $RUNNER_USER CALLING_DIR=$CALLING_DIR -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
fi
# Warn the user if ulimit -n is less than 1024
View
7 rel/files/riak-admin
@@ -11,6 +11,11 @@ if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
fi
unset POSIX_SHELL # clear it so if we invoke other scripts, they run as ksh as well
+#OLDPWD isn't properly set on OSX, so cheat
+if [ ! "$CALLING_DIR" ]; then
+ export CALLING_DIR=`pwd`
+fi
+
RUNNER_SCRIPT_DIR={{runner_script_dir}}
RUNNER_SCRIPT=${0##*/}
@@ -30,7 +35,7 @@ if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" != "x$RUNNER_USER" ]); then
exit 1
fi
echo "Attempting to restart script through sudo -u $RUNNER_USER"
- exec sudo -u $RUNNER_USER -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
+ exec sudo -u $RUNNER_USER CALLING_DIR=$CALLING_DIR -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
fi
# Make sure CWD is set to runner base dir
Something went wrong with that request. Please try again.