initial checkin
[grml-etc.git] / etc / automount.sh
1 #!/bin/bash
2 # Filename:      automount.sh
3 # Purpose:       generate an automounter entry automatically for automount /mnt/auto program this_script
4 # Authors:       (c) Klaus Knopper 2002, (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Don Okt 28 16:19:40 CEST 2004 [mika]
8 ################################################################################
9
10 # WARNING: This script is used for removable media in grml,
11 # therefore the mount is always read-write (except for cdroms
12 # and ntfs).
13
14 # Defaults
15 rw="rw"
16 device="/dev/${1##*/}"
17 case "$1" in
18 floppy)     [ -s /etc/sysconfig/floppy ] || exit 1; device="/dev/fd0";;
19 cdrom*)     rw="ro";;
20 dvd*)       rw="ro";;
21 esac
22
23 # Uses external fstype script from grml-scanpartitions
24 fs="$(fstype "$device")"
25
26 [ "$?" = "0" ] || exit 1
27
28 case "$fs" in
29 *fat|msdos) options="${rw},uid=grml,gid=grml,umask=000";;
30 ntfs)       options="ro,uid=grml,gid=grml,umask=0222";;
31 iso9660)    options="ro";;
32 *)          options="${rw}";;
33 esac
34
35 MNTLINE="-fstype=$fs,users,exec,$options        :$device"
36
37 # Return line to the automounter
38 echo "$MNTLINE"
39
40 ## END OF FILE #################################################################