Browse files

Enter Mirror Can Now Run Scripts in Mirror

This is not something I've wanted to use it for.
This just seemed like the right place to put this functionality.

The functionality is about to be put to use by build_mirror.
  • Loading branch information...
1 parent 5a79990 commit 4cc6c2ed2e69854819dc4ec697dd568258ba7e2a @psycotica0 committed Nov 13, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 enter_mirror
View
12 enter_mirror
@@ -3,6 +3,10 @@
DATA_LOCATION="/mnt/easy_mirror"
MIRROR_NAME="$1"
+if [ "$#" -gt 0 ]; then
+ shift
+fi
+
if [ '!' -d "$DATA_LOCATION" ]; then
echo "There are no active mirrors" >&2
exit 1
@@ -24,4 +28,10 @@ if [ -z "$MIRROR_NAME" ]; then
fi
fi
-chroot "$DATA_LOCATION/$MIRROR_NAME/union" su -l "$SUDO_USER"
+if [ "$#" = 0 ]; then
+ # We weren't given a command, so just run a shell
+ chroot "$DATA_LOCATION/$MIRROR_NAME/union" su -l "$SUDO_USER"
+else
+ # Run the commands we were given
+ chroot "$DATA_LOCATION/$MIRROR_NAME/union" sudo -u "$SUDO_USER" "$@"
+fi

0 comments on commit 4cc6c2e

Please sign in to comment.