1
0
Fork 0

Move function "on_chroot" to main script

This commit is contained in:
Braiden Vasco 2017-07-03 06:50:15 +00:00
parent 3a4f682485
commit e2840dc97b
2 changed files with 19 additions and 20 deletions

View file

@ -26,6 +26,25 @@ source "$FUNCTIONS_DIR/dependencies_check.sh"
source "$SCRIPT_DIR/common.sh" source "$SCRIPT_DIR/common.sh"
on_chroot() {
local proc_fs="$ROOTFS_DIR/proc"
local dev_fs="$ROOTFS_DIR/dev"
local devpts_fs="$ROOTFS_DIR/dev/pts"
local sys_fs="$ROOTFS_DIR/sys"
mount --bind /dev "$dev_fs"
mount --bind /dev/pts "$devpts_fs"
mount -t proc proc "$proc_fs"
mount --bind /sys "$sys_fs"
capsh --drop=cap_setfcap "--chroot=$ROOTFS_DIR/" -- "$@"
umount "$sys_fs"
umount "$proc_fs"
umount "$devpts_fs"
umount "$dev_fs"
}
apply_patches() { apply_patches() {
if [ ! -d "$1" ]; then if [ ! -d "$1" ]; then
echo "Patches directory does not exist: $1" echo "Patches directory does not exist: $1"

View file

@ -32,25 +32,5 @@ unmount_image() {
done done
} }
on_chroot() {
local proc_fs="$ROOTFS_DIR/proc"
local dev_fs="$ROOTFS_DIR/dev"
local devpts_fs="$ROOTFS_DIR/dev/pts"
local sys_fs="$ROOTFS_DIR/sys"
mount --bind /dev "$dev_fs"
mount --bind /dev/pts "$devpts_fs"
mount -t proc proc "$proc_fs"
mount --bind /sys "$sys_fs"
capsh --drop=cap_setfcap "--chroot=$ROOTFS_DIR/" -- "$@"
umount "$sys_fs"
umount "$proc_fs"
umount "$devpts_fs"
umount "$dev_fs"
}
export -f unmount export -f unmount
export -f unmount_image export -f unmount_image
export -f on_chroot