aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsquashfu24
1 files changed, 18 insertions, 6 deletions
diff --git a/squashfu b/squashfu
index 023fc43..3ccfc48 100755
--- a/squashfu
+++ b/squashfu
@@ -1,6 +1,7 @@
#!/bin/bash
-source /etc/squashfu.conf
+CONFIG="/etc/squashfu.conf"
+source "$CONFIG"
# Informational output w/ happy colors
debug () {
@@ -19,6 +20,7 @@ die () {
mount_squash () {
# Arguments: none
# Returns: return code of mount command
+ debug "Mounting Squash"
mount -t loop,ro "$SEED" "${BKUP_ROOT}/ro"
return $?
}
@@ -26,6 +28,7 @@ mount_squash () {
mount_union_with_bins () {
# Arguments: numbers of bins to be mounted (variable number)
# Returns: 0 on successful mount, non-zero on failure
+ debug $*
# Mount first as rw, shift, and mount the rest ro
branches="br=${BINS_DIR}/$1=rw:"; shift
for bin in $*; do
@@ -86,6 +89,7 @@ create_new_bin () {
# Arguments: 1, the number of the bin to create
# Returns: 0 on success, non-zero on error
+ debug "Asked to create new bin: $1"
# Create new directory, fail if it exists (something's wrong)
mkdir "${BINS_DIR}/$1"
if [[ $? -ne 0 ]]; then
@@ -107,13 +111,18 @@ create_new_bin () {
unmount_union () {
# Args: none
# Returns: return code from umount
- umount "${BKUP_ROOT}/rw"
+ debug "Unmounting union"
+ while [[ $(mountpoint "${BKUP_ROOT}/rw" | grep "is a mount") ]]; do
+ umount "${BKUP_ROOT}/rw" 2> /dev/null
+ sleep 1
+ done
return $?
}
-unmount_seed () {
+unmount_squash () {
# Args: none
# Returns: return code from umount
+ debug "Unmounting squash"
umount "${BKUP_ROOT}/ro"
return $?
}
@@ -124,13 +133,14 @@ unmount_all () {
# Union MUST be unmounted first
unmount_union
- unmoun_seed
+ unmount_squash
}
check_for_resquash () {
# Args: none
# Returns: number of bins needing to be merged
- local number_of_bins=$(wc -l "$BINVENTORY")
+ local number_of_bins=$(wc -l "$BINVENTORY" | cut -d\ -f1)
+ debug $number_of_bins
if [[ $number_of_bins -gt $MAX_BINS ]]; then
return $[ $number_of_bins - $MIN_BINS ]
@@ -185,6 +195,7 @@ create_new_incremental () {
# Determine the mount order via binventory
bin_order=($(sort -n -r -t:2 -k2 "$BINVENTORY" | cut -d: -f1))
+ mount_squash
mount_union_with_bins ${BIN_ORDER[@]}
# Die with error on mount, else start rsync
@@ -202,8 +213,9 @@ action_backup () {
# Returns: none
# Does the binventory exist? If not, prompt to make sure this is an initialization
+ FIRST_RUN=0
if [[ ! -f "$BINVENTORY" || ! -f "$SEED" ]]; then
- read -n "Looks like this is your first time running SquashFu. Is this correct? (y/n) " ans
+ read -p "Looks like this is your first time running SquashFu. Is this correct? (y/n) " ans
while [[ true ]]; do
case $ans in
[yY]) break ;;