}
errcatch
-
+tu() {
+ while read -r line; do
+ file="$1"
+ grep -xFq "$line" "$file" || tee -a "$file"<<<"$line"
+ done
+}
e() { printf "%s\n" "$*"; "$@"; }
+mnt() {
+ dir=$1
+ if ! mountpoint $dir >/dev/null; then
+ mkdir -p $dir
+ e mount $dir
+ fi
+}
ret=0
fi
-mkdir -p /q /p /i
-
for vol in q p; do
d=/$vol
if ! awk '{print $2}' /etc/fstab | grep -xF $d &>/dev/null; then
new_roots=()
for r in ${roots[@]}; do
# /q/a /a none bind 0 0
- new_roots+=($(sed -rn "s#^$r/\S+\s+(\S+)\s+none\s+bind\s.*#\1#" /etc/fstab))
+ new_roots+=($(sed -rn "s#^$r/\S+\s+(\S+)\s+none\s+bind\s.*#\1#p" /etc/fstab))
done
(( ${#new_roots} )) || break
binds+=(${new_roots[@]})
if e check-subvol-stale $d; then
for b in ${binds[@]}; do
- mount $b
+ mnt $b
done
continue
fi
if ! $umount_ret; then
for dir in ${unmounted[@]}; do
- mount $dir
+ mnt $dir
done
ret=1
continue
# things otherwise didn't get mounted very strangely.
e btrfs sub snapshot btrbk/$last_snap $vol
for dir in $d ${binds[@]}; do
- e mount $dir
+ e mnt $dir
done
done
exit $ret