Merge tag 'v1.46.2' into debian/master
[e2fsprogs.git] / install-utils / convfstab
blob11160bf7d0b13363b1b1df096f9b6a9f4f7d7a0d
1 #!/bin/sh
2 # Make /etc/fstab standard compliant.
3 # M.Weller (eowmob@exp-math.uni-essen.de) 13.11.1994.
4 # This script is public domain. Still if only slightly
5 # modified a credit to me might be nice.
7 ROOT_PASS=1 # Pass for root file system
8 NON_ROOT_PASS=2 # Pass for non root file systems
9 DEF_FLAGS="defaults" # Default filesysflags
10 DEF_DUMP=0 # Default dumpfreq.
12 while read LINE
14 set -- $LINE
15 if [ $# != 0 ]
16 then
17 case $1 in
18 \#* | !* )
19 echo "$LINE"
20 # Actually there are no comments allowed in /etc/fstab
21 echo "Warning: comment in /etc/fstab detected." >&2
22 echo "Please remove it by hand." >&2
24 * )
25 if [ $# -gt 6 ] || [ $# -lt 3 ]
26 then
27 echo "Don't have a clue about \"$LINE\"." >&2
28 echo "$LINE"
29 else
30 case $2 in
31 / )
32 PASS=$ROOT_PASS
34 none )
35 PASS=0
37 * )
38 PASS=$NON_ROOT_PASS
40 esac
41 DUMP=$DEF_DUMP
42 case $3 in
43 ignore | iso9660 | msdos | hpfs | sysv | \
44 xenix | coherent | nfs | proc | sw | swap )
45 DUMP=0;
46 PASS=0;
48 esac
49 case $# in
50 3 )
51 echo "$LINE $DEF_FLAGS $DUMP $PASS"
53 4 )
54 echo "$LINE $DUMP $PASS"
56 5 )
57 echo "$LINE $PASS"
60 echo "$LINE"
62 esac
65 esac
66 else
67 echo "Warning: One empty line removed." >&2
69 done </etc/fstab >/tmp/newfstab.$$
70 mv -f /etc/fstab /etc/fstab.bak
71 mv -f /tmp/newfstab.$$ /etc/fstab
72 if [ $? != 0 ]
73 then
74 echo "Installation of patched /etc/fstab failed."
75 echo "It would have been:"
76 cat /tmp/newfstab.$$
77 rm -f /tmp/newfstab.$$