diff options
Diffstat (limited to 'fstab.sh')
| -rw-r--r-- | fstab.sh | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -168,6 +168,12 @@ is_swap_active() { return 1 } +exists_root() { + p="$1" + # shellcheck disable=SC2086 + su $su_options -c "test -e $(shell_quote "$p")" +} + log "$0 $args" # --- process each fstab line --- @@ -229,7 +235,7 @@ while IFS= read -r rawline || [ -n "$rawline" ]; do err "Line $line_no: bindfs not available but requested (vfstype=bindfs)." continue fi - if [ ! -e "$fs_file" ]; then + if ! exists_root "$fs_file"; then log "Line $line_no: Creating mountpoint $fs_file" run_root mkdir -p "$fs_file" || { err "Line $line_no: mkdir failed for $fs_file" @@ -249,11 +255,11 @@ while IFS= read -r rawline || [ -n "$rawline" ]; do # --- bind / rbind mounts --- echo "$fs_mntops" | grep -q bind && { - if is_mounted("$fs_file"); then + if is_mounted "$fs_file"; then log "Line $line_no: $fs_file already mounted — skipped." continue fi - if [ ! -e "$fs_file" ]; then + if ! exists_root "$fs_file"; then log "Line $line_no: Creating mountpoint $fs_file" run_root mkdir -p "$fs_file" || { err "Line $line_no: mkdir failed for $fs_file" @@ -276,7 +282,7 @@ while IFS= read -r rawline || [ -n "$rawline" ]; do continue fi - if [ ! -e "$fs_file" ]; then + if ! exists_root "$fs_file"; then log "Line $line_no: Creating mountpoint $fs_file" run_root mkdir -p "$fs_file" || { err "Line $line_no: mkdir failed" @@ -300,4 +306,3 @@ else echo "Done: all entries processed successfully." | { [ -n "${LOG_FILE:-}" ] && tee -a "$LOG_FILE" || cat; } exit 0 fi - |
