Browse files

Added Creation Callbacks

So, if certain scripts exist, they will be run with the mirror is built.

This is something I've wanted for quite a while.
There are a series of things I always did as soon as I built a mirror so
I could tell it apart and use it and stuff.

Now this is all in scripts, so it'll just be done for me.
  • Loading branch information...
1 parent 4cc6c2e commit ec92c36052ebe2c8c62f327e6d21526cf7421f42 @psycotica0 committed Nov 13, 2012
Showing with 40 additions and 3 deletions.
  1. +24 −3 README
  2. +16 −0 build_mirror
@@ -24,6 +24,27 @@ If you have more than one mounted at a time, then you'll need to specify.
sudo breakdown_mirror test
-I tend to change .bashrc when I make a new image to put CHROOT in the PS1.
-That way I can tell when I'm in and when I'm not.
+I've got a system in place for scripts that you want to be run every time
+a new mirror is setup.
+The scripts are searched for in ~/.local/share/easy_mirror/
+The '~' in this case is relative to the user who's running the scripts (Not root, even when under sudo)
+Similarly, the scripts are run by that user, not root.
+There are currently two:
+ This one is run every time a new cache file was created.
+ It is not run if you're just remounting an existing cache.
+ This one is run every time a new mirror is built, whether or not the image file is new.
+Both of these scripts are run with the name of the mirror as the first argument.
+If either of these scripts don't exist, or aren't executable, then they just won't be run.
+I use for adding
+export PS1="$MIRROR_NAME-$PS1"
+to ~/.bashrc, so I can tell the mirrors apart from each other, and the root system.
+I use to make sure some state is removed so that the mirror is independent from the host.
@@ -5,6 +5,8 @@ IMAGE_SIZE="1600M"
if [ -z "$IMAGE_FILE" ]; then
echo "Please pass the path where you want your image file" >&2
@@ -31,6 +33,7 @@ if [ ! -e "$IMAGE_FILE" ]; then
echo "Image Created"
if [ -d "$MIRROR_LOCATION" ]; then
@@ -68,3 +71,16 @@ mount -t sysfs sysfs "$UNION_LOCATION"/sys 2> /dev/null
mount -t proc proc "$UNION_LOCATION"/proc 2> /dev/null
mount --bind /tmp "$UNION_LOCATION"/tmp 2> /dev/null
+# Check for "callbacks"
+if [ "$NEW_IMAGE" = 1 -a -x "$NEW_IMAGE_CALLBACK" ]; then
+ echo "Running New Image Callback"
+ echo "Running New Mirror Callback"

0 comments on commit ec92c36

Please sign in to comment.