On the Net

|Main Blog|Yearning|  

Words of God


About Linux News and OpenSource




and below are my posts....


Thursday, July 20, 2006

Mounting NFS and SAMBA shares with AutoFS

I have a Linux PC serving files via SAMBA and NFS and a M$ PC that also shares files over the network, then other Linux desktop pc are accessing files on it. Some are accessing it regularly and some are as they need it only. The first solution that I did was to mount those shares statically, as those workstations boot, thus shared files should be mounted automatically on them so users should at anytime they open the shortcuts on their desktop, they can open it immediately.

What I did was, I included thus entries on the fstab of each Linux PC so that immediately, shares are mounted automagically after the desktop loads, but the problem, in case that thus PC's that holds the share were not yet turned on, of course, the mounting should fail. The setup here with regards to PC, are to turn them off after office hours, then turn them on again in the morning by the utility in-charge. So, if that person turns on that PC that holds shared folder later than thus Linux worstations who serves as clients, mounting error will occur, when someone tries to open a shortcut file or folder that originally resides on remote PC, the system will hang, or strange things happen.

The fix, thus remote shared folder should be mounted dynamically, and if not in use, should unmount itself after the specified period of time, which can be resolve by using autofs.

Here's a litle desciprtion of autofs from its man file:


DESCRIPTION
autofs control the operation of the automount(8) daemons running on the
Linux system. Usually autofs is invoked at system boot time with the
start parameter and at shutdown time with the stop parameter. The aut-
ofs script can also manually be invoked by the system administrator to
shut down, restart or reload the automounters.

OPERATION
autofs will consult a configuration file /etc/auto.master (see
auto.master(5)) to find mount points on the system. For each of those
mount points a automount(8) process is started with the appropriate
parameters. You can check the active mount points for the automounter
with the /etc/init.d/autofs status command. If the auto.master configu-
ration file contains a line of the form



Ok, at this point, I will assume that thus PC's that serves files either from M$ Windows or Linux via NFS or SamBA works well, without problem on sharing files. What to do now is just to configure autofs to behave as how you want it to be.

Install autofs package if not yet been installed then make it run as a service. On Mandriva, it can be installed by the command as root:


urpmi autofs


then

chkconfig autofs on


will make autofs run as a service.

The main conf file is auto.master as been mentioned on its description/operation by its man page. On my system, which is Mandriva, this is how I do it:

First, I created a folder under /mnt with a name, say.. nfs and smb.


mkdir /mnt/nfs


and


mkdir /mnt/smb


At the folder /mnt/nfs, these is whre the mounted nfs shares will be locates, so as with samba shares at /mnt/smb. By default, there is a file names /etc/auto.smb, and your might think that this is the conf file that shoul be used for mounting samba shares, it's not. What I did was just renaming that file and create another one. So below are my /etc/auto.nfs and /etc/auto.smb files.


windows -fstype=smbfs,username=user01,password=microshaft,uid=500,gid=500,dmask=555,fmask=444 ://192.168.1.1/C$
images -fstype=smbfs,username=user01,password=microshaft ://192.168.1.1/scannedfiles


Now, my /etc/auto.nfs file


fileserver -rw,hard,intr,rsize=8192,wsize=8192 192.168.1.2:/home/files
documents -ro,hard,intr,rsize=8192,wsize=8192 192.168.1.2:/mnt/hdb/files


and my /etc/auto.master file


/mnt/nfs /etc/auto.nfs -t=10
/mnt/smb /etc/auto.smb -t=10


Explanation:
On /etc/auto.smb file, line 1 contains a word windows,... onced a user envoked the command ls /mnt/smb/windows the shared //192.168.1.1/C$ will automatically being mounted under the folder /mnt/smb/windows and if you do a df command, you'll see something like this:


//192.168.1.1/C$ 24G 9.6G 14G 42% /mnt/smb/windows


which means that its been mounted already... and as been set on auto.master file, 10 seconds later, if there is no files being accessed on that folder, it will auto un-mount itself. Please take note, the I did not manually create a folder named /mnt/smb/windows, it will be just created dynamically by autofs once its being accessed. So same scenario would happen on NFS shared folde, once someone is accessing thus folder names being set on the /etc/auto.nfs files, same thing will happen.

Another take note
On Mandriva 2005 and 2006, there might be a bug on its own buid autofs package, since the system, though it could properly mount thus shared remote folder, but it wont un-mount itself after the specified duration when nothing has being done on the remote shared folder or files on it. The fix was, on mine, I installed the autofs from source which I got from kernel.org. By doing that, problem with auto un-mount has been resolved. The issue appear only on the mentioned 2005 and 2006, but on Mandrake 10.1 or on Centos and Xandros which both I'd tried, I did not encounter such problem.

Wednesday, July 12, 2006

First encounter with Asterisk Free PBX

Yesterday I started to try to install and Configure asterisk. Well, I dont have any digium fxs or fxo hardware yet so I'm toying with SIP Softphones. But before that, I manually installed asterisk on my already running Centos box, after installing some depedencies, I got it working. I installed it from CVS so that I have the latest version.

After reading some site that has lots of asterisk configuration sample, I manage to have a working SIP Softphone with the use of SJPhone. I did not made with Xlite with the same config, I dunno yet why it happend. On Xlite, when trying to call the registered prefix, it'll just sat call not allowed while on SJPhone, it allows even to its own number. Below are my sip.conf and extensions.conf with voicemail.conf.

/etc/asterisk/sip.conf


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[general]
disallow=gsm
allow=ulaw
port = 5060 ; Port to bind to
bindaddr = 172.16.0.253 ; IP_Address to bind to
;context = from-sip ; Default for incoming calls
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;---- My SIP Phone at my Desktop ----------;
[x1000]
type=friend
username=x1000
secret=1000
host=dynamic
defaultip=172.16.0.37
canreinvite=no
disallow=all
allow=all
context=testing
allow=ulaw
allow=alaw
;regexten=1000
nat=no
;
;;;;;;;;;; SIP Phone USer at other Desktop ;;;;;;;;;;
[x2000]
type=friend
username=x2000
secret=2000
host=dynamic
defaultip=172.16.0.30
canreinvite=no
disallow=all
allow=all
context=testing
allow=ulaw
allow=alaw
nat=no
;
;
;;; Entry for FXS Gateway - it has 4 FXS Ports but only configured 1 port
[4001]
type=friend
context=testing
secret=antek
host=dynamic
defaultip=172.16.0.254
nat=no
canreinvite=yes
dtmfmode=info
disallow=all
allow=ulaw
allow=g723.1
allow=g729
;
;---------- FXO VoIP Gateway Entry -------------
;By the entries below, the 4FXO antek Gateway will be able to call
;SIP users above.. by dialing the pstn number connected on its port
;then after a dial tone received, if for example 1000 has been dialed, x1000 SIP
;Phone will ring... in general, all numbers that has been set at extensions.conf
;should ring...
;
[3000]
type=friend
;username=3000
;secret=3000
host=dynamic
defaultip=172.16.0.252
canreinvite=no
disallow=all
allow=all
context=testing
allow=ulaw
allow=alaw
;regexten=2000
nat=no
;musicclass=classical
regexten=3000
;


/etc/asterisk/extensions.conf


;I'd just append the entries below to the sample
;extensions.conf file of asterisk 1.2
[testing]
;
exten => 1000,1,Dial(SIP/x1000, 10)
exten => 1000,2,VoiceMail(10001@testing, 10)
exten => 1000,3,PlayBack(vm-goodbye)
exten => 1000,4,HangUp()
exten => 999,1,VoiceMailMain(10001@testing)
;
exten => 3000,1,Dial(SIP/3000)
;exten => 3000,2,VoiceMail(10001@testing, 10)
;exten => 1000,3,PlayBack(vm-goodbye)
;exten => 1000,4,HangUp()
;exten => 999,1,VoiceMailMain(10001@testing)
;
exten => 2000,1,Dial(SIP/x2000) ;;//for user x2000
;
exten => 4001,1,Dial(SIP/4001)
;when dialing 4001, analog phone connected at the said antek fxs gateway should ring
;assuming properly configured..


and the voicemail.conf
/etc/asterisk/voicemail.conf


[testing]

x1000 => 1000, x1000, email@mymail.com

;the voicemail.conf is already an existing file, so I just added the above entry at the last line
;of this file



Ok, by default, the antek gateway has been set to H323, so VoIP protocol needs to be changed to SIP so it will be able to communicate with the asterisk SIP protocol. You can access the gateway via http or telnet for the configuration changes... here are some basics via http.

-
The model of the used gateway above.
-

-
SIP Configuration portion.. entries should match on the /etc/asterisk/sip.conf
-

-
Voice Processing control should be like that above... but you can actually used those other codecs since they are also being supported by asterisk.

For now, the config works fine, but still have so many features to discover..