• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
6
7ROOT_PASS=1		# Pass for root file system
8NON_ROOT_PASS=2		# Pass for non root file systems
9DEF_FLAGS="defaults"	# Default filesysflags
10DEF_DUMP=0		# Default dumpfreq.
11
12while read LINE
13do
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
23	;;
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
33	      ;;
34	    none )
35	      PASS=0
36	      ;;
37	    * )
38	      PASS=$NON_ROOT_PASS
39	      ;;
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;
47	      ;;
48	  esac
49	  case $# in
50	    3 )
51	      echo "$LINE	$DEF_FLAGS	$DUMP	$PASS"
52	      ;;
53	    4 )
54	      echo "$LINE	$DUMP	$PASS"
55	      ;;
56	    5 )
57	      echo "$LINE	$PASS"
58	      ;;
59	    6)
60	      echo "$LINE"
61	      ;;
62	  esac
63	fi
64	;;
65    esac
66  else
67    echo "Warning: One empty line removed." >&2
68  fi
69done </etc/fstab >/tmp/newfstab.$$
70mv -f /etc/fstab /etc/fstab.bak
71mv -f /tmp/newfstab.$$ /etc/fstab
72if [ $? != 0 ]
73then
74  echo "Installation of patched /etc/fstab failed."
75  echo "It would have been:"
76  cat /tmp/newfstab.$$
77  rm -f /tmp/newfstab.$$
78fi
79