-
-
Notifications
You must be signed in to change notification settings - Fork 33
Use temporary directories for mounting #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
f8c120c
8b3210e
43884d9
0ecf02a
2bf258a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,9 +84,7 @@ then | |
apt-get install -y --no-install-recommends $need_packages | ||
fi | ||
|
||
clone=/mnt/clone | ||
clone_src=/mnt/clone-src | ||
clone_log=/var/log/$PGM.log | ||
export clone_log=/var/log/$PGM.log | ||
|
||
HOSTNAME=`hostname` | ||
|
||
|
@@ -997,6 +995,25 @@ then | |
exit 0 | ||
fi | ||
|
||
export clone=$(mktemp --tmpdir --directory rpi-clone-dst.XXXXXX) | ||
export clone_src=$(mktemp --tmpdir --directory rpi-clone-src.XXXXXX) | ||
|
||
if ! [ -n "$clone" -a -d "$clone" -a -n "$clone_src" -a -d "$clone_src" ] | ||
then | ||
echo "Failed to create temporary mount directories" | ||
echo "Aborting!" | ||
exit 1 | ||
fi | ||
|
||
# Make sure we cleanup on exit, regardless of how we exit | ||
cleanup() { | ||
umount "$clone" 2> /dev/null | ||
|
||
umount "$clone_src" 2> /dev/null | ||
rmdir "$clone" | ||
rmdir "$clone_src" | ||
} | ||
trap cleanup EXIT | ||
|
||
# dst_mount_flag enumerations: | ||
live=1 | ||
temp=2 | ||
|
@@ -1252,16 +1269,6 @@ unmount_or_abort "$mounted_dev" \ | |
mounted_dev=$(findmnt /mnt -o source -n) | ||
unmount_or_abort "$mounted_dev" "$mounted_dev is currently mounted on /mnt." | ||
|
||
|
||
if [ ! -d $clone ] | ||
then | ||
mkdir $clone | ||
fi | ||
if [ ! -d $clone_src ] | ||
then | ||
mkdir $clone_src | ||
fi | ||
|
||
# Do not include a dhpys swapfile in rsync. It regenerates at boot. | ||
# | ||
if [ -f /etc/dphys-swapfile ] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Negated tests are hard to read. I suggest to use the following test instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agreed, also using
[[
as you suggest makes it even more readable by allowing||
instead of-o
.