#!/bin/bash # allfilesys 1.0 # small utility for mounting and checking all local drives # needed to work ok: # git,fdisk,grep, and /proc PATH="/sbin:/usr/sbin:/bin/:/usr/bin" #configuration: ALLDISKS='hd[a-d]' # other example: ALLDISKS='hda /dev/hdb /dev/sd[abc]' #grep pattern of lines from fdisk -l /dev/hdx which we don't want to mount nor c heck. Note that language matters. NOMOUNT="Rozšířený\|Extended\|Ext'd\|swap" # fsck options (Completion_bar, dont_show_Title, automatically_rePair ) FSCK_OPTS="-C -T -p" # if [ `whoami` != 'root' ] then echo "Note: as root you can have more privilegies...."; fi if [ "$#" -eq 0 ]; then echo -e "Hello, I need 1 to 2 parameters\n give me -m to attempt mount using gitmount\n and/or -c to check filesystems listed below . \n\n When mounting, I will create directories under /mnt named \n just as devi ces under /dev/ [eg. hdc3,hdb8, and so on] \n" ; exit 1; fi if [ "$1" = "-cm" -o "$1" = "-mc" ] ; then set -- -c -m ; fi fdisk -l /dev/$ALLDISKS 2>/dev/null | grep /dev/ | grep -v Disk | grep -v "$NOM OUNT" | awk ' { print $1 } ' | while read line do d=`echo $line | sed 's/.*\///'` echo "########### Device: $d" mkdir /mnt/$d 2>/dev/null # create dir if not exists if [ -z "`grep "/dev/$d " /proc/mounts`" ]; then ### not mounted yet if [ "$1" = "-c" -o "$2" = "-c" ]; then fsck $FSCK_OPTS /dev/$d ; fi if [ "$1" = "-m" -o "$2" = "-m" ] ; then gitmount $d 2>/dev/null ; fi else echo " is already mounted" fi done