resticprofiles-base/scripts/mount-btrfs

46 lines
843 B
Text
Raw Permalink Normal View History

#!/bin/bash
restoreDir="/etc/restore"
scriptPath="$(dirname "$(readlink -f "$0")")"
source "${scriptPath}/functions.sh"
hook_before() {
local btrfsPartition
btrfsPartition="$(findmnt -oSOURCE -rnv /)"
if [[ ! -d "/.btrfs" ]]; then
mkdir /.btrfs
fi
if ! mount | grep '\.btrfs' &>/dev/null; then
mount "$btrfsPartition" -o subvolid=5 /.btrfs || exit 200
fi
}
hook_fail() {
if mount | grep '\.btrfs' &>/dev/null; then
2024-11-11 12:09:13 -05:00
umount /.btrfs || exit 200
fi
}
hook_after() {
:
}
hook_final() {
if mount | grep '\.btrfs' &>/dev/null; then
2024-11-11 12:09:13 -05:00
umount /.btrfs || exit 200
fi
}
case "$1" in
before) hook_before || exit $?;;
after) hook_after || exit $?;;
fail) hook_final || exit $?;;
finally) hook_final || exit $?;;
esac