#!/bin/sh #Name of this script atmnt V0.9.4 #Use this script on an ASUS WL-500gP only and/or rewrite path #This script is published under GNU or any later Version at your choice #Scriptauthor newbiefan @ forum wl500g.info #Automounts any attached USB storage device automatically #to your sharefolder or any other directory at your choice. # #2do test phase 3, implementation of a description file on any device #in order to mount to a folder taken from description file #verification (hotplug) is handled by script attached, placed @ /opt/sbin #choose a logfile-location #loglocation=/dev/null loglocation=/tmp/harddisk/logmount.tmp echo Logfile is at $loglocation #full path of your samba share folder or any other folder at our choise sambasharefolder=/tmp/harddisk/share slash=/ echo >> $loglocation #just a carriage return echo -n "Start script atmnt at " >> $loglocation date >> $loglocation #name for the directory in your share folder which is generated by automount attachname=attached #define your systemdisc, this disc has to be handled in your post-boot #consider, that this number must be less as startdisc #sysdisc=0 #this is your system disc or usb memory startdisc=1 #we start with disc1, disc0 is usually your system disc #automount can handle up to x partitions per disc excluded swap partitions #choose as much as you need, its just a question of time maxdisc=9 #how many discs max maxparts=9 #how many partitions per disc max maxattached=81 #set it to (maxdisc x maxparts) or lower #this is the default path where discs show up prefixfolder=/dev/discs #first we have to check, how many devices are already mounted to sambasharefolder countmnt=1 #first we set the counter to 1, because we search for attachnamex pcoun=1 #set partitiontotalcounter while [ $countmnt -lt $maxattached ]; do if mount | grep $sambasharefolder$slash$attachname$pcoun ; then #is already mounted to attachedx let pcoun=$pcoun+1 let countmnt=$countmnt+1 else #no need to check any more, because is not mounted countmnt=$maxattached #make it equal to exit while fi done #name of not mounted partitions, usually on an oleg-asus part1 - partx searchpart=part #searches for part1-partmaxparts searchpart2=disc #searches for disc1-discmaxdisc Countdisctmp=$startdisc Countpartition=1 while [ $Countdisctmp -lt $maxdisc ]; do while [ $Countpartition -lt $maxparts ]; do if [ -d $prefixfolder$slash$searchpart2$Countdisctmp ] && [ -e $prefixfolder$slash$searchpart2$Countdisctmp$slash$searchpart$Countpartition ]; then tomount=$prefixfolder$slash$searchpart2$Countdisctmp$slash$searchpart$Countpartition #check if partition is already mounted if mount | grep $tomount ; then # is already mounted if full path is found date >> $loglocation #write date and time echo $tomount ' already mounted, nothing done' >> $loglocation else #Partition is not mounted date >> $loglocation #write date and time echo $tomount mounted to $sambasharefolder$slash$attachname$pcoun #we have to check that the directory exists if [ -d $sambasharefolder$slash$attachname$pcoun ]; then #directory exists echo $sambasharefolder$slash$attachname$pcoun already established nothing done >> $loglocation else #if directory does not exist echo $sambasharefolder$slash$attachname$pcoun established >> $loglocation mkdir $sambasharefolder$slash$attachname$pcoun fi #end directory exist mount $tomount $sambasharefolder$slash$attachname$pcoun echo $tomount mounted to $sambasharefolder$slash$attachname$pcoun >> $loglocation let pcoun=$pcoun+1 #increase total partition counter when mounted by script fi #end mountcheck fi #end check existing device let Countpartition=$Countpartition+1 done #maxpartition checked at the current disc Countpartition=1 #start again with partition1 let Countdisctmp=$Countdisctmp+1 #and the next disc to check done #all discs checked let pcoun=$pcoun-1 #we started already with 1, so -1 because we add 1 after mount echo "Sucessful finished $pcoun partitions mounted" >> $loglocation echo -n "atmnt-Job end at " >> $loglocation date >> $loglocation echo -n "Script atmnt sucessful finished at " # Message for Console date echo