aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrtyhlpr <its_sead4@gmx.de>2016-03-07 22:00:42 +0100
committerdrtyhlpr <its_sead4@gmx.de>2016-03-07 22:00:42 +0100
commitf6d8c17fbf01d3c095ac644ed539f472ceba3950 (patch)
tree64d0f5fba2dd50d0319b8ffc259c34cd1077d856
parent172ae22b25dc43501e15df4f2ee956cdb2014805 (diff)
parentf13fca1705c41ee32a26d87588bee44a59c7d82a (diff)
downloadrpi2-gen-image-f6d8c17fbf01d3c095ac644ed539f472ceba3950.tar.gz
rpi2-gen-image-f6d8c17fbf01d3c095ac644ed539f472ceba3950.tar.bz2
rpi2-gen-image-f6d8c17fbf01d3c095ac644ed539f472ceba3950.zip
Merge pull request #28 from stylesuxx/run-scripts-in-chroot
Added functionality to run custom scripts after base bootstrap
-rw-r--r--README.md3
-rwxr-xr-xrpi2-gen-image.sh8
2 files changed, 11 insertions, 0 deletions
diff --git a/README.md b/README.md
index dbe0d88..6378db3 100644
--- a/README.md
+++ b/README.md
@@ -149,6 +149,9 @@ password, use only in trusted environments.
##### `ENABLE_HARDNET`=false
Enable IPv4/IPv6 network stack hardening settings.
+##### `CHROOT_SCRIPTS`=""
+Path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this direcory is run in lexicographical order.
+
## Logging of the bootstrapping process
All information related to the bootstrapping process and the commands executed by the `rpi2-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose:
diff --git a/rpi2-gen-image.sh b/rpi2-gen-image.sh
index f47e8c2..5b61ae2 100755
--- a/rpi2-gen-image.sh
+++ b/rpi2-gen-image.sh
@@ -97,6 +97,7 @@ ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
# Image chroot path
R=${BUILDDIR}/chroot
+CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
# Packages required for bootstrapping
REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git-core"
@@ -615,6 +616,13 @@ chroot_exec apt-get -y clean
chroot_exec apt-get -y autoclean
chroot_exec apt-get -y autoremove
+# Invoke custom scripts
+if [ -n "${CHROOT_SCRIPTS}" ]; then
+ cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
+ LANG=C chroot $R bash -c 'for SCRIPT in /chroot_scripts/*; do if [ -f $SCRIPT -a -x $SCRIPT ]; then $SCRIPT; fi done;'
+ rm -rf "${R}/chroot_scripts"
+fi
+
# Unmount mounted filesystems
umount -l $R/proc
umount -l $R/sys