#!/bin/sh # /etc/rc.d/rc.shares # # mount, unmount, and remount samba shares listed in /etc/fstab # in the 2.6 kernel I believe you can also use '-t cifs' # # these shares will initially be mounted by /etc/rc.d/rc.inet2 # but we can use this script to control them thereafter, as needed. # # the actual entries inside /etc/fstab look like something this.. # (at least when using "user" authentication - though it's better to # use the UNIX auth backend, or a simple samba credentials file) # # //soho/oshi /mnt/soho smbfs username=MyName,password=LetMeIN!,rw,user,uid=MyName,gid=adm 0 0 # # ^^remote path ^^ local mount point ^^ username ^^ password ^ etc. # see man fstab for more details # # (or @ corz.org 19-4-05 ;o) # shares_mount() { if cat /etc/fstab | grep -v '^#' | grep -w smbfs 1> /dev/null 2> /dev/null ; then echo echo "Mounting samba (cifs) shares.. /sbin/mount -a -t smbfs" /sbin/mount -a -t smbfs # Show the mounted volumes.. echo "Currently mounted volumes.." # in blue echo df -h echo "" fi } shares_unmount() { # unmount all samba volumes (shares) found in fstab.. if cat /etc/fstab | grep -v '^#' | grep -w smbfs 1> /dev/null 2> /dev/null ; then echo echo "Unmounting samba (cifs) shares.. /sbin/mount -a -t smbfs" /sbin/umount -a -t smbfs # Show the mounted volumes.. #/sbin/mount -v -t smbfs echo "Currently mounted volumes.." echo "" df -h echo "" fi } shares_remount() { shares_unmount sleep 1 shares_mount } show_usage() { echo echo "Mount and unmount samba (cifs) shares.." echo echo "Usage: $0 mount|unmount|remount" echo } case "$1" in mount) shares_mount ;; unmount) shares_unmount ;; remount|reload) shares_remount ;; *) show_usage esac