Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automount in Linux ES3.1

Status
Not open for further replies.

rbri

Programmer
Jun 27, 2002
84
US
New to Linux support....
We just added an ES3.1 Linux server to out NIS domain. It appears that the server mounts all of the users homes that are listed in our auto_home map. My question is how do you configure automount within Linux? These mount points should only happen upon user login.
Thanks
 
There are 2 files you need to edit.

1: /etc/auto.master which defines the mount directories

2: /etc/auto.misc (or what is defined in auto.master) which defines what exported shares can be mounted.

Linux automount is not like Solaris automount which queries automatically. Linux you have to define everything first.

I wrote a script that uses showmount to add the entries into the auto.misc. If you want I can send it to you or post it.

>---------------------------------------Lawrence Feldman
SR. QA. Engineer SNAP Appliance
lfeldman@snapappliance.com

 
Hello Clonny2

Thanks for the help I knew about auto.master but, not auto.misc. Please post your script if that's not to much trouble.

Thanks Randy
 
Here ya go.

#!/bin/bash

#######################
# Variables ##
#######################


efile="/tmp/srv_export"
misc="/etc/auto.misc"
opts="-rw,soft,intr"
server=$1
debug="true"

#####################
# Start Functions ##
#####################

function fCopyright () {
echo ""
echo "Name : getexports.sh"
echo "Date : 07/21/03"
echo "Descr : Gathers exports from a showmount -e source then enters entry into /etc/auto.misc for autofs if not alrerady there."
echo "Author : Lawrence Feldman <lonf@earthlink.net>"
echo ""
echo ""
}

function fUsage () {
echo ""
echo " ******************************"
echo " * *"
echo " * Usage: Start getexports.sh *"
echo " * sh getexports.sh {server} *"
echo " * ./getexports.sh {server} *"
echo " * {server} = IP or name *"
echo " * *"
echo " ******************************"
echo ""
}

function getExport () {
# Function to get the results of showmount -e
showmount -e $server > $efile
}

function fDoesExist () {
# See if export already exists in $misc
# Need to use sed to transpose / to : to compare

YN=""
TRANS=`echo "$1@$server" | sed s-/-:-`
EXIST=`grep -w "$TRANS" $misc`
if [ "$?" -eq "0" ]; then
YN="0"
else
YN="1"
fi
return $YN
}

function rServer_exports () {
# Function to read each line of the $server_exports file.
# Calls fDoesExist to see if exists in $misc.
# Then appends the value into the $misc file.

while read line x
do
if [ ${line} != "Export" ]; then
fDoesExist "${line#?}"
fi

if [ "$YN" == "1" ]&& [ ${line} != "Export" ] && [ ${line} != "export" ]; then
[ $line != "Export" ] || [ $line != "export" ] && echo "${line#?}@$server $opts $server:$line" >> $misc
echo "Added ${line#?} to $misc"
fi
done </tmp/srv_export
}


function fLatest() {
# Does latest link exist?


TRY=`showmount -e $server | grep latest`

if [ "$?" == "0" ]; then
fSedExports
fi
}

function fSedExports () {
# Sed to transpose / to :
# Need to only get slash in the first half.


sed s-/-:- /etc/auto.misc > /etc/sed.tmp
mv /etc/auto.misc /etc/auto.misc.bk
mv /etc/sed.tmp /etc/auto.misc
OS=`uname`
case $OS in
"Linux" );; # Nothing to do
"AIX" ) # Need to sed out xport
sed -e /xport@* /d /etc/auto.misc > etc/sed.tmp
mv /etc/auto.misc /etc/auto.misc.bk
mv /etc/sed.tmp /etc/auto.misc
;;
esac

}

function fCleanUP () {
# Remove sed tmp files

if [ -e /etc/sed.tmp ]; then
rm -f /etc/sed.tmp
fi

if [ -e $efile ] ; then
rm -f $efile
fi
}

function pDebug () {
# Print Debug
[ $debug == "true" ] && cat $efile
}

function fRestart () {
# Function to Restart automount
OS=`uname`
case $OS in
"Linux") service autofs restart;;
"AIX") automount ;;
esac
}

###################
# End Functions ##
###################

###################
# MAIN () ##
###################

function Main () {

#fCopyright
if [ "$server" == "" ]; then fUsage; exit; fi
getExport
rServer_exports
fLatest
fRestart
fCleanUP
fCopyright
}



##################
# Call Main ##
Main ##
##################


>---------------------------------------Lawrence Feldman
SR. QA. Engineer SNAP Appliance
lfeldman@snapappliance.com

 
Hello Clonny2

Thanks for the script.

Thanks Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top