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
2 changed files
and 3 deletions.
@@ -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 new_image.sh for adding
+to ~/.bashrc, so I can tell the mirrors apart from each other, and the root system.
+I use new_mirror.sh to make sure some state is removed so that the mirror is independent from the host.
@@ -5,6 +5,8 @@ IMAGE_SIZE="1600M"
" $2 "
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
-F " $UNION_LOCATION " " $IMAGE_FILE "
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
/proc " $UNION_LOCATION " 2> /dev/null
mount --bind /tmp
/tmp " $UNION_LOCATION " 2> /dev/null
# Check for "callbacks"
"/home/ $SUDO_USER/.local/share/easy_mirror/new_mirror.sh "
"/home/ $SUDO_USER/.local/share/easy_mirror/new_image.sh "
if [ " $NEW_IMAGE " = 1 -a -x ] " $NEW_IMAGE_CALLBACK " ; then
echo "Running New Image Callback "
" $MIRROR_NAME " " $NEW_IMAGE_CALLBACK " " $MIRROR_NAME "
if [ -x ] " $UNION_LOCATION/ $NEW_MIRROR_CALLBACK " ; then
echo "Running New Mirror Callback "
" $MIRROR_NAME " " $NEW_MIRROR_CALLBACK " " $MIRROR_NAME "