summaryrefslogtreecommitdiff
path: root/borg-family-0.1/src/etc/bfhooks
blob: 5b6b2048b64da5f401a3fce2991d385920aaca5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash -e
mount_bind_rootfs() {
	if ! mount | grep -q /rootfs; then
		mkdir -p /rootfs
		mount --bind / /rootfs
	fi
}

umount_bind_rootfs() {
	if mount | grep -q /rootfs; then
		umount /rootfs || lsof -n | grep /rootfs
		rmdir /rootfs
	fi
}

case $1 in
	before)
		case $2 in
			rootfs) apt-get clean || true; mount_bind_rootfs;;
		esac
		;;
	after)
		case $2 in
			rootfs) umount_bind_rootfs ;;
		esac
		;;
esac