forked from marcone/teslausb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mount snapshots in a different location
In preparation for using autofs to mount snapshots.
- Loading branch information
Showing
5 changed files
with
33 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
#!/bin/sh | ||
#!/bin/bash -eu | ||
|
||
# for some reason "umount -d" doesn't remove the loop device, so we have to remove it ourselves | ||
MNT=$(echo "$1" | sed 's/\/$//') | ||
LOOP=$(mount | grep -w "$MNT" | awk '{print $1}' | sed 's/p1$//') | ||
NAME=$(basename "$1") | ||
LOOPPART=$(mount | grep -w "$NAME" | awk '{print $1}') | ||
LOOPROOT=${LOOPPART/p1/} | ||
MNT=$(findmnt -o target -n $LOOPPART) | ||
umount "$MNT" | ||
losetup -d "$LOOP" | ||
losetup -d "$LOOPROOT" | ||
|
||
# delete the snapshot folders | ||
rm -rf /backingfiles/snapshots/$NAME /tmp/snapshots/$NAME | ||
|
||
# delete all dead links | ||
find /backingfiles/TeslaCam/ -depth -xtype l -delete || true | ||
|
||
# delete all Sentry, saved and recent folders that are now empty | ||
find /backingfiles/TeslaCam/ -mindepth 2 -depth -type d -empty -exec rmdir "{}" \; | ||
find /backingfiles/TeslaCam/ -mindepth 2 -depth -type d -empty -exec rmdir "{}" \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters