dragora-installer: Exclude tmpfs for non-root mounts, minor changes
[dragora.git] / archive / dragora-installer / parts / FstabMounts
blob366fd873c8ac7786751fa79395ff08102f70dc80
1 # This file is part of the 'dragora-installer'.
3 # Purpose: Make mount points and mount non-root filesystems from fstab.
5 # Make declared mount points from fstab, exclude:
6 # commentaries, root, and possible swapfile.
7 makeMountPoints()
9     grep -E -v '^#|swap|/ ' "${SUBTMPDIR}/fstab" | \
10      awk '{ print substr($2,2) }' | while read -r directory
11       do
12           test -n "$directory" || continue
14           # Make sure to translate converted blank spaces (\040)
15           # into common spaces for directory creation (see MakeFS)
16           directory="$(printf '%s' "$directory" | tr '\\040' ' ')"
18           if test ! -d "/media/dragora-root/${directory}"
19           then
20               mkdir -p -- "/media/dragora-root/${directory}"
21           fi
22       done
25 mountNonRoot()
27     if test -s "${SUBTMPDIR}/fstab"
28     then
29         awk '!/^#/ && !/\/ / && !/fd0/ && !/swap/ && !/tmp/{ print $1,$2 }' \
30          "${SUBTMPDIR}/fstab" | while IFS=" " read -r device mntpoint
31          do
32              umount "$device" > /dev/null 2>&1 || true
34              mntpoint="$(printf '%s' "$mntpoint" | tr '\\040' ' ')"
35              mntpoint="/media/dragora-root/${mntpoint}"
37              echo ""
38              umount -v "$device" || true
39              mount -v "$device" "$mntpoint" || exit $?
40              sleep 2
41          done
42     fi
45 dialog --colors \
46  --backtitle "\\ZbNon-root partition(s)" \
47  --title "NON-ROOT MOUNTS" --sleep 2 \
48  --infobox "Preparing to mount the rest of the file systems..." 3 54
50 makeMountPoints
51 mountNonRoot
53 if test ! -e /media/dragora-root/etc/fstab
54 then
55     # Copy fstab into the root partition
56     mkdir -p -- /media/dragora-root/etc || true
57     cp -f -- "${SUBTMPDIR}/fstab" /media/dragora-root/etc/
58 else
59     # Offer the possibility to overwrite the fstab file only if
60     # there is a difference, since there is no point in asking to
61     # overwrite the (newly) created and copied file
63     if test \
64 "$(cmp -s "${SUBTMPDIR}/fstab" /media/dragora-root/etc/fstab; printf $?)" = "1"
65     then
66         dialog --no-shadow --colors \
67          --backtitle "\\ZbFile system table (fstab)" \
68          --title "EXISTING FILE SYSTEM TABLE" \
69          --cr-wrap --yesno \
70 "A file system table already exists on the mounted root partition:
71     /media/dragora-root/etc/fstab
73 Overwrite this file only if:
74   - This is a new installation.
75   - You are installing a new kernel image.
76   - To create a boot disk with a new kernel.
78 In this case, you must configure the system to boot properly.
80 Do not overwrite the file system table if you are adding
81 software to the existing system...
83 Do you want to replace the existing fstab with the new one?
84 " 19 69 || { unset makeMountPoints mountNonRoot ; return 0; }
86         mkdir -p -- /media/dragora-root/etc || true
87         cp -f -- "${SUBTMPDIR}/fstab" /media/dragora-root/etc/
88     fi
91 unset makeMountPoints mountNonRoot