Changeset 5644 for pkg/kev/main/rebuildfstab-parsix/trunk/rebuildfstab
- Timestamp:
- 07/28/09 05:28:56 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pkg/kev/main/rebuildfstab-parsix/trunk/rebuildfstab
r2556 r5644 1 1 #!/bin/bash 2 # Calls scanpartitions as root and adds entries to /etc/fstab 3 # (C) Klaus Knopper Nov 2002 4 # (C) 2004-2006 Stefan Lippers-Hollmann <s.l-h@gmx.de> 5 # (C) 2007 Alan Baghumian <alan@technotux.org> 2 # Backwards compatible script that calls new fstabgen 3 # (C) 2009 Alan Baghumian <alan@technotux.org> 6 4 7 PATH="/bin:/sbin:/usr/bin:/usr/sbin" 8 export PATH 9 umask 022 5 /usr/sbin/fstabgen --mkdir --auto > /etc/fstab 10 6 11 [ ! -e /proc/partitions ] && { echo "$0: /proc not mounted, exiting" >&2; exit 1; }12 13 if [ -e /var/run/rebuildfstab.pid ]; then14 ps "$(</var/run/rebuildfstab.pid)" >/dev/null 2>&1 && exit 015 rm -f /var/run/rebuildfstab.pid16 fi17 18 echo "$$" >/var/run/rebuildfstab.pid19 20 XSH=""21 [ -n "$DISPLAY" ] && XSH="rxvt -bg black -fg green -cr red -T $0 -e"22 23 [ "`id -u`" != "0" ] && exec $XSH parsix-su "$0" "$@"24 25 TMP="$(mktemp -p /tmp/ fstab-XXXXXXXXXX)"26 ADDEDBYKNOPPIX="# Added by KNOPPIX"27 ADDEDBYKANOTIX="# Added by KANOTIX"28 ADDEDBYPARSIX="# Added by PARSIX"29 30 # Simple shell grep, searches for lines STARTING with string31 stringinfile() {32 while read line; do33 case "$line" in34 $1*)35 return 036 ;;37 esac38 done <"$2"39 40 return 141 }42 43 removeentries() {44 # Remove comment line $1 and the following line from file $245 while read line; do46 case "$line" in47 $1)48 read line49 continue50 ;;51 esac52 echo "$line"53 done <"$2"54 }55 56 verbose=""57 remove=""58 user=""59 group=""60 arg="$1"61 62 while [ -n "$arg" ]; do63 case "$arg" in64 -v*)65 verbose="yes"66 ;;67 -r*)68 remove="yes"69 ;;70 -u*)71 shift72 user="$1"73 ;;74 -g*)75 shift76 group="$1"77 ;;78 *)79 echo "Usage: $0 [-v[erbose]] [-r[emove_old]] [-u[ser] uid] [ -g[roup] gid]"80 ;;81 esac82 83 shift84 arg="$1"85 done86 87 [ -n "$verbose" ] && echo "Scanning for new harddisks/partitions..." >&288 rm -f "$TMP"89 90 if [ -n "$remove" ]; then91 removeentries "$ADDEDBYKNOPPIX" /etc/fstab >"$TMP"92 removeentries "$ADDEDBYKANOTIX" /etc/fstab >"$TMP"93 removeentries "$ADDEDBYPARSIX" /etc/fstab >"$TMP"94 else95 cat /etc/fstab >"$TMP"96 fi97 98 iocs=""99 nls=""100 if [ "$(locale charmap)" = "UTF-8" ]; then101 iocs=",iocharset=utf8"102 nls=",locale=utf8"103 fi104 105 count=0106 while read device mountpoint fstype relax; do107 stringinfile "$device " "$TMP" || \108 {109 count="$((count + 1))"110 [ -d "$mountpoint" ] || mkdir -p "$mountpoint" 2>/dev/null111 options="noauto,users,exec"112 113 case "$fstype" in114 ntfs)115 options="auto,force,users,exec,umask=000"116 fstype="ntfs-3g"117 ;;118 msdos)119 options="${options},umask=000,quiet${iocs}"120 ;;121 vfat)122 options="${options},umask=000,shortname=mixed,quiet${iocs}"123 ;;124 swap)125 options="sw"126 ;;127 esac128 129 case "$fstype" in130 ntfs|vfat|msdos)131 [ -n "$user" ] && options="$options,uid=$user"132 [ -n "$group" ] && options="$options,gid=$group"133 ;;134 esac135 136 echo "$ADDEDBYPARSIX"137 printf "%-15s %-15s %-7s %-15s %-7s %s\n" "$device" "$mountpoint" "$fstype" "$options" "0" "0"138 }139 done >>"$TMP" <<EOT140 $(scanpartitions)141 EOT142 143 [ -n "$verbose" ] && { [ "$count" -gt 0 ] && echo "Adding $count new partitions to /etc/fstab." >&2 || echo "No new partitions found." >&2; }144 mv -f "$TMP" /etc/fstab145 146 rm -f /var/run/rebuildfstab.pid147 148 [ -n "$DISPLAY" ] && sleep 2149 150 exit 0151
Note: See TracChangeset
for help on using the changeset viewer.


