Ignore:
Timestamp:
07/28/09 05:28:56 (4 years ago)
Author:
alanbach-guest
Message:
  • Added new fstabgen script from Sidux, modified to meet Parsix

standards

  • Updated rebuildfstab that calls fstabgen as a backwards compatible wrapper
  • Bump standards version to 3.8.2, no extra change is needed
  • Removed recommends
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pkg/kev/main/rebuildfstab-parsix/trunk/rebuildfstab

    r2556 r5644  
    11#!/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> 
    64 
    7 PATH="/bin:/sbin:/usr/bin:/usr/sbin" 
    8 export PATH 
    9 umask 022 
     5/usr/sbin/fstabgen --mkdir --auto > /etc/fstab  
    106 
    11 [ ! -e /proc/partitions ] && { echo "$0: /proc not mounted, exiting" >&2; exit 1; } 
    12  
    13 if [ -e /var/run/rebuildfstab.pid ]; then 
    14         ps "$(</var/run/rebuildfstab.pid)" >/dev/null 2>&1 && exit 0 
    15         rm -f /var/run/rebuildfstab.pid 
    16 fi 
    17  
    18 echo "$$" >/var/run/rebuildfstab.pid 
    19  
    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 string 
    31 stringinfile() { 
    32         while read line; do 
    33                 case "$line" in 
    34                         $1*) 
    35                                 return 0 
    36                                 ;; 
    37                 esac 
    38         done <"$2" 
    39  
    40         return 1 
    41 } 
    42  
    43 removeentries() { 
    44         # Remove comment line $1 and the following line from file $2 
    45         while read line; do 
    46                 case "$line" in 
    47                         $1) 
    48                                 read line 
    49                                 continue 
    50                                 ;; 
    51                 esac 
    52                 echo "$line" 
    53         done <"$2" 
    54 } 
    55  
    56 verbose="" 
    57 remove="" 
    58 user="" 
    59 group="" 
    60 arg="$1" 
    61  
    62 while [ -n "$arg" ]; do 
    63         case "$arg" in 
    64                 -v*) 
    65                         verbose="yes" 
    66                         ;; 
    67                 -r*) 
    68                         remove="yes" 
    69                         ;; 
    70                 -u*) 
    71                         shift 
    72                         user="$1" 
    73                         ;; 
    74                 -g*) 
    75                         shift 
    76                         group="$1" 
    77                         ;; 
    78                 *) 
    79                         echo "Usage: $0 [-v[erbose]] [-r[emove_old]] [-u[ser] uid] [ -g[roup] gid]" 
    80                         ;; 
    81         esac 
    82  
    83         shift 
    84         arg="$1" 
    85 done 
    86  
    87 [ -n "$verbose" ] && echo "Scanning for new harddisks/partitions..." >&2 
    88 rm -f "$TMP" 
    89  
    90 if [ -n "$remove" ]; then 
    91         removeentries "$ADDEDBYKNOPPIX" /etc/fstab >"$TMP" 
    92         removeentries "$ADDEDBYKANOTIX" /etc/fstab >"$TMP" 
    93         removeentries "$ADDEDBYPARSIX" /etc/fstab >"$TMP" 
    94 else 
    95         cat /etc/fstab >"$TMP" 
    96 fi 
    97  
    98 iocs="" 
    99 nls="" 
    100 if [ "$(locale charmap)" = "UTF-8" ]; then 
    101         iocs=",iocharset=utf8" 
    102         nls=",locale=utf8" 
    103 fi 
    104  
    105 count=0 
    106 while read device mountpoint fstype relax; do 
    107         stringinfile "$device " "$TMP" || \ 
    108         { 
    109                 count="$((count + 1))" 
    110                 [ -d "$mountpoint" ] || mkdir -p "$mountpoint" 2>/dev/null 
    111                 options="noauto,users,exec" 
    112  
    113                 case "$fstype" in 
    114                         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                 esac 
    128          
    129                 case "$fstype" in 
    130                         ntfs|vfat|msdos) 
    131                                 [ -n "$user" ]  && options="$options,uid=$user" 
    132                                 [ -n "$group" ] && options="$options,gid=$group" 
    133                                 ;; 
    134                 esac 
    135  
    136                 echo "$ADDEDBYPARSIX" 
    137                 printf "%-15s %-15s %-7s %-15s %-7s %s\n" "$device" "$mountpoint" "$fstype" "$options" "0" "0" 
    138         } 
    139 done >>"$TMP" <<EOT 
    140 $(scanpartitions) 
    141 EOT 
    142  
    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/fstab 
    145  
    146 rm -f /var/run/rebuildfstab.pid 
    147  
    148 [ -n "$DISPLAY" ] && sleep 2 
    149  
    150 exit 0 
    151  
Note: See TracChangeset for help on using the changeset viewer.