Thursday, February 14, 2008

Asterisk TTS example on 1.4

Following previous posts the following examples can be use to test the usage of TTS from the dialplan in Asterisk.

Example 1:
We set up small script that will be executed from the Asterisk dialplan. This script will take as parameter the text that will be transform to a wav file to later be played.

On extensions.conf configure the following extensions:

exten => 1222,1,Answer()
exten => 1222,n,Set(TEST="Welcome to TTS example")
exten => 1222,n,System(/tmp/test2.sh ${TEST})
exten => 1222,n,Playback(/tmp/test)
exten => 1222,n,Hangup()


On /tmp/test2.sh (add necessary rights to the file) configure the following shell script:

#!/bin/bash
#delete any previous file
/bin/rm -rf /tmp/test.wav

#Convert the text to a wav file
/opt/swift/bin/swift -o /tmp/test.wav -p audio/sampling-rate=8000,audio/channels=1 " $@"

#Don't run sox until swift is done
wait
/usr/bin/sox /tmp/test.wav /tmp/newtest.wav trim 7.5

#copy the old file with the trimmed file
/bin/cp /tmp/newtest.wav /tmp/test.wav


Sox is an application that allows you manipulate/convert audio files from the command line. The page with information about it is http://sox.sourceforge.net/. The installation is quite simple on Debian "apt-get install sox".

The content of the asterisk variable ${TEST} is send as parameters of the shell script. The script uses $1...$n as parameters but you can use $@ to use all the parameters sent. (there must be a better way!! to do this). The following line convert the text into a wav file and save it as /tmp/test.wav.

/opt/swift/bin/swift -o /tmp/test.wav -p audio/sampling-rate=8000,audio/channels=1 " $@"

Once we run it we use sox to trim the first 7.5 seconds of the file that we don't need for this test. This creates a new file named newtest.wav (original no?)

Finally we rename the file to the original name and is later played by asterisk dialplan with the command "exten => 1222,n,Playback(/tmp/test)"

Note this is just a demo/test/proof of concept. For production you should buy some licenses and evaluate the usage of the app_swift from Asterisk to improve this.

Example2:
Using the example below we create a demo "time of the day" service.

The configuration of the extensions.conf file is pretty much the same but we remove the commands to send a text to it.

exten => 1222,1,Answer()
exten => 1222,n,System(/tmp/test2.sh)
exten => 1222,n,Playback(/tmp/test)
exten => 1222,n,Hangup()


The script only has the details to get the different elements of the date from the unix system and concatenate them on a single string to be converted to wav file later by swift. The shell looks like this:

#!/bin/bash
hour=`date +'%l'`
am=`date +'%p'`
minute=`date +'%M'`
day=`date +'%d'`
month=`date +'%B'`
year=`date '+20%y'`

texto="The current time is $hour:$minute $am . Today is the $month-$day-$year "


#delete any previous file
/bin/rm -rf /tmp/test.wav

#Convert the text to a wav file
/opt/swift/bin/swift -o /tmp/test.wav -p audio/sampling-rate=8000,audio/channels=1 " $texto"

#Don't run sox until swift is done
wait
/usr/bin/sox /tmp/test.wav /tmp/newtest.wav trim 7.5

#copy the old file with the trimmed file
/bin/cp /tmp/newtest.wav /tmp/test.wav
#!/bin/bash


The played TTS can be improved to make it more user friendly.

Other date options:
man strftime
%A is replaced by the locale's full weekday name.
%a is replaced by the locale's abbreviated weekday name.
%B is replaced by the locale's full month name.
%b or %h is replaced by the locale's abbreviated month name.
%C is replaced by the century (a year divided by 100 and truncated to an integer) as a decimal number (00-99).
%c is replaced by the locale's appropriate date and time representation.
%D is replaced by the date in the format ``%m/%d/%y''.
%d is replaced by the day of the month as a decimal number (01-31).
%e is replaced by the day of month as a decimal number (1-31); single digits are preceded by a blank.
%H is replaced by the hour (24-hour clock) as a decimal number (00-23).
%I is replaced by the hour (12-hour clock) as a decimal number (01-12).
%j is replaced by the day of the year as a decimal number (001-366).
%k is replaced by the hour (24-hour clock) as a decimal number (0-23); single digits are preceded by a blank.
%l is replaced by the hour (12-hour clock) as a decimal number (1-12); single digits are preceded by a blank.
%M is replaced by the minute as a decimal number (00-59).
%m is replaced by the month as a decimal number (01-12).
%n is replaced by a newline.
%p is replaced by the locale's equivalent of either ``AM'' or ``PM''.
%R is replaced by the time in the format ``%H:%M''.
%r is replaced by the locale's representation of 12-hour clock time using AM/PM notation.
%T is replaced by the time in the format ``%H:%M:%S''.
%t is replaced by a tab.
%S is replaced by the second as a decimal number (00-60).
%s is replaced by the number of seconds since the Epoch, UCT (seemktime(3)).
%U is replaced by the week number of the year (Sunday as the first day of the week) as a decimal number (00-53).
%u is replaced by the weekday (Monday as the first day of the week) as a decimal number (1-7).
%V is replaced by the week number of the year (Monday as the first day of the week) as a decimal number (01-53). If the week containing January 1 has four or more days in the new year, then it is week 1; otherwise it is week 53 of the previous year, and the next week is week 1.
%W is replaced by the week number of the year (Monday as the first day of the week) as a decimal number (00-53).
%w is replaced by the weekday (Sunday as the first day of the week) as a decimal number (0-6).
%X is replaced by the locale's appropriate time representation.
%x is replaced by the locale's appropriate date representation.
%Y is replaced by the year with century as a decimal number.
%y is replaced by the year without century as a decimal number (00-99).
%Z is replaced by the time zone name.
%% is replaced by `%'.

Cepstral Allison on Asterisk 1.4 Test

Download the Ceptrals voice of your preference and system. I like Allison particularly better than the UK one.

Do the download on /usr/src.

lmntel01:/usr/src# wget http://downloads.cepstral.com/cepstral/i386-linux/Cepstral_Allison_i386-linux_4.2.1.tar.gz
--22:01:46-- http://downloads.cepstral.com/cepstral/i386-linux/Cepstral_Allison_i386-linux_4.2.1.tar.gz
=> `Cepstral_Allison_i386-linux_4.2.1.tar.gz'
Resolving downloads.cepstral.com... 216.92.127.89
Connecting to downloads.cepstral.com|216.92.127.89|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 107,474,833 (102M) [application/x-tar]

100%[========================================>] 107,474,833 1.15M/s ETA 00:00

22:03:26 (1.03 MB/s) - `Cepstral_Allison_i386-linux_4.2.1.tar.gz' saved [107474833/107474833]

lmntel01:/usr/src#


Untar the file and enter the directory:

lmntel01:/usr/src#tar -xzvf Cepstral_Allison_i386-linux_4.2.1.tar.gz
lmntel01:/usr/src#cd Cepstral_Allison_i386-linux_4.2.1

Execute the installation script:

lmntel01:/usr/src/Cepstral_Allison_i386-linux_4.2.1/#./install.sh


The installation process goes like this:

Do you agree to these terms? Enter -yes- to continue: yes

Install into what directory? [/opt/swift]

Swift will be installed in the following directories:

Voices in /opt/swift/voices
Shared libraries in /opt/swift/lib
Binaries in /opt/swift/bin
Configuration file in /opt/swift/etc
Header files in /opt/swift/include
Examples in /opt/swift/examples
Sound effects filters in /opt/swift/sfx
Documentation in /opt/swift/doc

Is this acceptable? Enter 'yes' to continue: yes


Installing libraries...

***************************************************************************
If you are installing Swift system-wide, you may need to add the following
line to /etc/ld.so.conf and run ldconfig as root:

/opt/swift/lib

(Otherwise, you will need to add it to the LD_LIBRARY_PATH environment
variable in order to run programs linked against the Swift libraries.)
***************************************************************************

Installing voice Allison...

Creating configuration...

Installing binaries...
Installing symbolic link to swift...
Installing man page...

Setting permissions...

Testing the installed swift binary...
/opt/swift/bin/swift -o /dev/null 'hello world'

***************************************************************************
****************** Installation Completed Successfully! *******************
***************************************************************************

lmntel01:/usr/src/Cepstral_Allison_i386-linux_4.2.1/#


After this you must restart Asterisk and after the reboot to confirm the installation run the command below and check the outpu.

lmntel01:/usr/src/Cepstral_Allison_i386-linux_4.2.1/#asterisk -rx "core show application swift"

-= Info about application 'Swift' =-

[Synopsis]
Speak text through Swift text-to-speech engine.

[Description]
Swift(text) Speaks the given text through the Swift TTS engine.
Returns -1 on hangup or 0 otherwise. User can exit by pressing any key.

-- Remote UNIX connection
rbast:~/Cepstral_Allison_i386-linux_4.2.1#


Also you can generate a TTS wav file on the command line by running:

To test the installation you can:
/opt/swift/bin/swift -o /tmp/test.wav -p audio/sampling-rate=8000,audio/channels=1 "This is a test."

And finally just create an extension on the context of your choice to play it:

exten => 1234,1,Answer()
exten => 1234,2,Playback(/tmp/test)
exten => 1234,3,Hangup()

You will notice that as there is not a license for this package you will hear an introduction message asking you to buy a license on Cepstral web site.



Saturday, February 09, 2008

Asterisk Voicemail - Quick Exim4 notes

After installing asterisk I set up the voicemail configuration. First un apt-get install exim4 and then run pkg-reconfigure exim4-config and follow the instructions.

After the configuration exim4 should restart itself but if not use /etc/init.d/exim4 restart.

Configure the voicemail.conf file as follows:

[general]
format=wav
serveremail=asterisk
attach=yes
skipms=3000
maxsilence=10
silencethreshold=128
maxlogins=3
pbxskip=yes
fromstring=Voicemail
emailbody=Dear ${VM_NAME}:\n\n\tjust wanted to let you know you were just left a ${VM_DUR} long message (number ${VM_MSGNUM})\nin mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE}. The message is attached. Thanks!\n\n\t\t\t\t\n
emaildateformat=%A, %B %d, %Y at %r
sendvoicemail=no
delete=yes

[zonemessages]
eastern=America/New_York|'vm-received' Q 'digits/at' IMp
central=America/Chicago|'vm-received' Q 'digits/at' IMp
central24=America/Chicago|'vm-received' q 'digits/at' H N 'hours'
military=Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p'
european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM

[default]
89300 => 89300,User1,user1@mailserver.com



Now on Sip.con add the mailbox line (mailbox account and context of voicemail.conf)

[89300]
type=friend
regexten=89300
context=default
mailbox=89300@default
secret=89300
username=89300
callerid="User1" <89300>
host=dynamic
nat=yes
canreinvite=no
disallow=all
allow=alaw
allow=ulaw
dtmfmode=inband



Finally on extensions.conf set each SIP extensions (will use macros later) to wait for 20 seconds and go to Voicemails as follows:

[default]
exten => 89300,1,Dial(SIP/89300,20)
exten => 89300,2,VoiceMail(89300@default)
exten => 89300,3,PlayBack(vm-goodbye)
exten => 89300,4,HangUp()

Friday, February 08, 2008

Set H323 trunk between Asterisk and Avaya

Once asterisk and H323 is installed (previous post) follow the below configuration files to have the ip trunk up and running do the following configuration:

Setup h323.conf, sip.conf and extensions.conf as the examples below:

The h323.conf just defines the link between the Avaya and the Asterisk server.

/etc/asterisk/h323.conf
; The NuFone Network's ;
Open H.323 driver configuration
;
[general]

port = 1720

bindaddr = 192.168.58.227
disallow=all

allow=alaw

dtmfmode=inband
gatekeeper = DISABLE
context=default

progress_setup = 8
progress_alert = 8

h245tunneling=yes


[Avaya]

type=friend
context=default
host=192.168.58.216
port=1720

disallow=all
allow=alaw,g729,gsm,slinear


On sip.conf I set two demo extensions 89301 and 89300. This are numbers similar to my Avaya extension range and they also match a DDI range.


/etc/asterisk/sip.conf
[general]
context=default
allowoverlap=no

bindport=5060

bindaddr=0.0.0.0

srvlookup=yes


[89300]

type=friend
regexten=89300

context=default
secret=89300
username=89300

callerid="User1" <89300>
host=dynamic

nat=yes
canreinvite=no
disallow=all

allow=alaw

allow=ulaw
dtmfmode=inband


[
89301]
type=friend

regexten=89301

context=default
secret=89301
username=89301

callerid="User2" <89301>

host=dynamic

nat=yes
canreinvite=no

disallow=all

allow=alaw

allow=ulaw

dtmfmode=inband



On extensions.con I set up a basic dial plan to send sip calls to each sip phone and calls from the sip phones to the Avaya system.


/etc/asterisk/extensions.conf

; extensions.conf - the Asterisk dial plan
[general]
static=yes
writeprotect=no
autofallthrough=yes
clearglobalvars=no

[globals]
TRUNKMSD=1

[default]
;Simple direct to sip extensions
exten => 89300,1,Dial(SIP/89300)
exten => 89301,1,Dial(SIP/89301)

;Simple rule to divert all calls from Sip extensions to Avaya extensions and External numbers on PSTN.

exten => _8XXXX,1,Dial(H323/${EXTEN}@Avaya); Avaya Extension
exten => _90ZXXXXXXXXX,1,Dial(H323/${EXTEN}@Avaya); External National UK Number


Configure the Avaya side:

The first thing to check is to see if you have the following:
a. On system-parameters customer-options in the second page you must have enough Maximum Administered H.323 Trunks to use.
b. A CLAN to use.
b. A MEDPRO to use.

Note that my Avaya PBX is a CM version 3.1.2, there might be other requirements that I might be missing.

1) Set up the names of the Avaya CLAN and the Asterisk server on node-names ip
(in the image below lmntel01 would be my Asterisk ip address and 192.168.58.216 my clan address)



2) Below are the details of my CLAN, note the network region defined. In this case 6.



3) The configuration of the CLAN is shown below:



4) The network region 6 has the following configuration:









c) The network region 6 has defined ip-codec 6 taht has the following codecs (NOTE: the use of this codecs is due system configuration/hardware limitiations. You should try to use something else than G729)




d) Now you have to define the IP Trunk and IP Signaling group. You have to create both on sync, below just the final output.






Note that the Supplementary Service Protocol needs to be set to "a" to allow the passing of call info (extension number, name, etc) from and to the two systems. This will be shown at the end of this post in an Avaya to Asterisk extension call.









e) At this stage you should have the H323 IP trunk up and running between the two systems. You might require a busyout of signalig group/trunk to bring it up.






f) The next step is to define the routing off calls from the Avaya to the Asterisk box using the new trunk created.

First I set up on the uniform-dial-plan that all my extensions begining wiht 893xx and 5 digits should use the ARS table. My Avaya dial plan is of 5 digits, and I do an inc-call-handling-trmt to change external DDI to an internal extension. For example 02070189301 is set to the internal number 89301, note that 89301 is NOT an extension that is defined on the Avaya system.



Then on the ARS analysis table I defined that the 893xx range should use the route pattern 66. (not sure which call type I have to use, on my test the last one was natl therefore it was left like that).



Finally the route-pattern 66 is defined using the trunk 66 previously created and that would be all the configuration needed.



One final step that I had to do was to complete my public-unknown-numbering table. I found on the test that while the extension name was sent to the asterisk server the extension name was not. External calls to the DDI worked fine and the caller number was passed but when calling from an internal extension there was a problem.

After googling and checking this I found that by setting the first digits of my Avaya extensions and the trunk all the Avaya extensions sent the number to the Asterisk server and were display on the IPSoftphone being used for testing.



An example of a call using X-Lite sofphone is below. From extension 84562 on my Avaya PBX I placed a call to extension 89300 on the Asterisk server. The configuration of 84562 is below:



You can see on the result that the name and the extension number is sent to Asterisk. This is due using Supplementary Service Protocol a on the second page of the trunk 66 definition as mentioned before.

Installing Asterisk Again with H323 support

I never put live my old installation, then a few weeks later I lost the machine where it was and then I just simple forget. Now after playing a little here are the details for the installation (again).

(this was compiled from a few sites and my notes)

I located all my files on /usr/src

asterisk-1.4.12.1.tar.gz
asterisk-addons-1.4.3.tar.gz
libpri-1.4.1.tar.gz
zaptel-1.4.5.1.tar.gz
openh323-v1_18_0-src-tar.gz
pwlib-v1_10_3-src-tar.gz

(you will need to untar the files -- tar -xzvf -- )

cd /usr/src

Install Zaptel
cd zaptel-1.4.5.1
./configure
make menuselect
make
make install ---> as root
make config ---> as root
cd ..

make config Note:
If you have any zaptel hardware it is now recommended to edit /etc/default/zaptel or /etc/sysconfig/zaptel and set there an optimal value for the variable MODULES .

Install Libpri
cd libpri-1.4.1
make
make install ---> as root
cd ..


Install pwlib
cd pwlib_v1_10_3
./configure --prefix=/usr
make opt
make install

export PWLIBDIR=/usr/src/pwlib_v1_10_3
cp $PWLIBDIR/lib/libpt_linux_x86_r.so.1.10.3 /usr/lib
cd ..

We copy the shared library manually into the system folder.

It is very important that you set the PWLIBDIR to your path, othewise OpenH323 will not find it.

Install openh323
cd openh323_v1_18_0
./configure --prefix=/usr./configure --prefix=/usr
make opt
make install
export OPENH323DIR=/usr/src/openh323_v1_18_0
cp $OPENH323DIR/lib/libh323_linux_x86_r.so.1.18.0 /usr/lib
cd ..

Install Asterisk
cd asterisk-1.4.12.1
./configure --prefix=/usr
make menuselect

At this point use the menuselect utility to select which Zaptel hardware - if any - you have on board. Please remeber that if you want to exit keeping the changes you made, you must press x, while q will quit without saving and the left arrow will get you back to the previous menu. Even if you do not have Zaptel hardware, you should compile the ztdummy driver.

On the channels menu you will be able to see the chan_h323 availabble for installation.



make

When you compile with make you will get the error shown on the image below therefore you will have to run the make command again:



make

make install
make samples
cd ..


This should be it. I checked that my /etc/zaptel.conf was missing. Not sure if this is because I didn't have any hardware installed. Just in case I copied
cp /home/ricardo/asterisk_intall/zaptel-1.4.5.1/zaptel.conf.sample /etc/zaptel.conf

Run the moprobe on zapte/ztdummy

modprobe zaptel
lsmod
modprobe ztdummy
lsmod

Change the default zone on zaptel.conf to UK

vi /etc/zaptel.conf

loadzone=uk

After starting Asterisk and logging into the console type the command show channeltypes to check that H323 has been install and is running.




Then you have to follow the next post with the details of the Avaya-Asterisk H323 ip trunk.

Please check this website for more details on the h323 installation:
http://astrecipes.net/index.php?q=astrecipes/compiling+asterisk+1.4+with+tdm400+and+h323

Solaris tips (for the CMS)

I had to use the following tips time to time so I am posting them here to save me the time to look for them again (and avoid the possibility of the original sites going off-line).


1. Set up your /etc/hosts file.

It should look something like this:

127.0.0.1       localhost
192.168.0.150 solaris-box-1 solaris-box-1.yourdomain.com loghost

Make sure the second line has the correct IP address, hostname, and FQDN. The first line is the loopback entry. Along with #5, Solaris will know its name and IP address.

2. Create or edit /etc/nodename

Contains the hostname of the computer (same as hostname.hme0).

# cat nodename
solaris-box-1


3. Create or edit /etc/defaultrouter

Surprisingly enough, this file contains the IP address of your default router (or gateway). When you reboot and the network initialization scripts run, it will add a default route to the IP address in this file.

# cat defaultrouter
192.168.0.1


Now it knows about it's own network parameters and it's time to get it to use DNS. The next steps will tell it to use other nameservers. If you want to set up a nameserver on the local machine, see the man page for named.


4. Edit /etc/nsswitch.conf

If you haven't edited this file before, it should look suspiciously like like this:

passwd:     files
group: files
hosts: files
networks: files
protocols: files
rpc: files
ethers: files
netmasks: files
bootparams: files
publickey: files
# At present there isn't a 'files' backend for netgroup; the system will
# figure it out pretty quickly, and won't use netgroups at all.
netgroup: files
automount: files
aliases: files
services: files
sendmailvars: files

Add the word 'dns' after 'files' on the 'hosts' line:

passwd:     files
group: files
hosts: files dns
networks: files
protocols: files
rpc: files
ethers: files
netmasks: files
bootparams: files
publickey: files
# At present there isn't a 'files' backend for netgroup; the system will
# figure it out pretty quickly, and won't use netgroups at all.
netgroup: files
automount: files
aliases: files
services: files
sendmailvars: files

Now it knows to query a nameserver when looking up a name. Next we have to tell it what nameservers to use:


5. Create or edit /etc/resolv.conf

Here you tell it three things:

  1. What domain we're in
  2. Specify any additional search domains
  3. What the nameservers are (it will use them in the order you put them in the file)

When you're done it should look something like this:

# cat resolv.conf
domain yourdomain.com
search yourdomain.com
search client1.com
nameserver 192.168.0.9
nameserver 192.168.0.11

For more information, see the man page for resolv.conf.


6. Edit /etc/hostname.hme0

This file should contain the hostname of your machine, without the domain name. So, if the FQDN (Fully Qualified Domain Name = hostname + domain name) is solaris-box-1.yourdomain.com, the file should look like this:

# cat hostname.hme0
solaris-box-1

This assumes that your Ethernet adatper is hme0, the default device name for the first Ethernet adapter.



7. Reboot
# sync;sync;sync
# reboot


8. Change IPs


UNIX Shell: All Primary shells (sh,ksh,csh)
Function: Use ifconfig to change your IP address immediately. Edit your /etc/hosts file to change it permanently.
Syntax: Immediate change: ifconfig interface new IPaddress subnet mask

Permanent change: vi /etc/hosts
interface Specifies the network interface, e.g. hme0 for 100 Mbps or le0 for 10 Mbps.
new IPaddress Specifies the new IP address that you want to assign the computer.
subnet mask Specifies the subnet mask for your local network.

File Name: hosts Directory: /etc Type: External
ifconfig hme0 192.168.1.250 255.255.255.0 Sets the IP address to 192.168.1.250 on interface hme0.
ifconfig le0 192.168.1.250 255.255.255.0 Sets the IP address to 192.168.1.250 on interface le0

9. Recover ROOT password

You need to have physical access to the machine's console.

Note the root partition;

Solaris uses

* /dev/dsk/c0t0d0s0 on the Ultra5/10 and Blade 100
* /dev/dsk/c0t1d0s0 for Blade 1000.

Press the STOP and A keys simultaneously, or, on an ASCII terminal or emulator, send a ) to halt the operating system, if it's running.

Boot single-user from CD-ROM (boot cdrom -s) or network install/jumpstart server (boot net -s). For CD media use the CD-ROM labeled "Installation". I prom pssword is set you need to know it

Mount the root partition on "/a". "/a" is an empty mount point that exists at this stage of the installation procedure. For example:

#mount /dev/dsk/c0t0d0s0 /a

If the mount command fails and since "/a" always exists, then you either typed in the wrong device, OR the system is seeing the root partition as something else.

Do a "ls /tmp/dev/dsk" and see what is there. "c0t6" things are the CD-ROM, what is left is what one needs to try. On a Blade 1000/2000, choose /dev/dsk/c1t1d0s0, and execute: #mount /dev/dsk/c1t1d0s0 /a

Set your terminal type so you can use a full-screen editor, such as vi. You can skip this step if you know how to use "ex" or "vi" from open mode.

* If you're on a sun console, type "TERM=sun; export TERM";
* If you are using an ascii terminal or terminal emulator on a PC for your console, set TERM to the terminal type for example: TERM=vt100; export TERM.

Edit the passwd file, /a/etc/shadow (or perhaps in older versions, /etc/passwd) and remove the encrypted password entry for root.

Type: "cd /; then "umount /a"

Reboot as normal in single-user mode ("boot -s"). The root account will not have a password. Give it a new one using the passwd command. PROM passwords: Naturally, you may not want anyone with physical access to the machine to be able to do the above to erase the root password. Suns have a security password mechanism in the PROM which can be set (this is turned off by default). The man page for the eeprom command describes this feature.

If security-mode is set to "command", the machine only be booted without the prom password from the default device (i.e. booting from CD-ROM or install server will require the prom password). Changing the root password in this case requires moving the default device (e.g. the boot disk) to a different SCSI target (or equivalent), and replacing it with a similarly bootable device for which the root password is known. If security-mode is set to full, the machine cannot be booted without the prom password, even from the default device; defeating this requires replacing the NVRAM on the motherboard. "Full" security has its drawbacks -- if, during normal operations, the machine is power-cycled (e.g. by a power outage) or halted (e.g. by STOP-A), it cannot reboot without the intervention of someone who knows the prom password.

10. Others (and repeated)

"I've almost just reinstalled Solaris to get the network settings fixed!" Ya, sometimes you can get alittle confused and irritated. Whether it's a new Linux distro, or diffrent UNIX OS, everyone puts their network configuration in diffrent places and learning each systems setup can be a pita. So, what if you don't even wanna bother learning all the network configuration stuff and what files does what... what if you could just re-run the networking configuration and have it all sorted out? You can! Solaris has a nifty command that can reset the base networking and configuration to a clean system: "sys-unconfig". If you buy a pre-installed system from Sun or a VAR, what they will generally do is install Solaris, customize the install as needbe and then run "sys-unconfig" before putting the system in the box and shipping it out. The command will scratch the networking configuration (most of it anyway), the root password, time zone, etc. Once sys-unconfig finished cleaning out the files it will immediately halt the system (shut it down). Next time you boot the system it will prompt you for all the networking information, time zone, locale and a new root password. This is the "quick-no-hassle" reconfiguration method. Generally we do not recommend this as ideal, but it will do the trick. If you plan on selling a pre-installed system or you are moving your system to a new network where all the info is changing, this is the command to use. Just use it carefully.

"I know root shouldn't login remotely, but I really want too!" Logging into a system via telnet, ftp, or ssh is just bad... very bad. However, some times people think they need to do this or they simply don't care about security. If you really wanna drop your pants like this, edit: /etc/default/login. In this file, you'll see a line for CONSOLE. To allow root to log in via telnet or ftp just comment out this line and your done. To allow root login via SSH you need to edit a diffrent file: /etc/ssh/sshd_config. Change the value of PermitRootLogin from "no" to "yes" and restart SSH via "svcadm restart ssh". The SSH configuration file is just the same as Linux since Solaris uses OpenSSH. Please note, that allowing root to log in remotely is a massive security risk and needlessly stupid, don't do this unless you absolutely must.

"How do I set and make the default gateway persistant across reboots?" The default gateway is easy to configure, just put the IP address of the default gateway in /etc/defaultrouter. If this file doesn't exist just create it and add the IP. The IP address of the gateway should be the ONLY thing in this file, nothing else. Typically you should just use echo, like this: "echo 10.0.0.255 > /etc/defaultrouter". Once you've changed the file you can restart the physical network interfaces to make the changes effective without a reboot ("svcadm restart physical").

How do I set or change my IP address? Setting and changing IP addresses on Solaris is a snap. Just add the IP and hostname that you wish to use to /etc/hosts. Then put the hostname (by itself) in teh /etc/hostname.(interface) file. Then just restart the physical networking via SMF ("svcadm restart phsyical") and your done! Example: "echo '10.0.0.25 solarisrox' >> /etc/hosts; echo 'solarisrox' > /etc/hostname.hme0" assuming that hme0 was the interface you wanted to use. Don't worry about this changing the hostname for the whole workstation, the hostname for the system is kept in /etc/nodename. You can add the default gateway as we discussed just above. If you need to specify a non-standard subnet netmask you can add it to /etc/netmasks. You can have as many subnet masks in the /etc/netmasks file as you like, one per line, just follow the instructions at the top of the file.

How do I configure DHCP? DHCP is pretty easy to configure, just create 2 empty files: /etc/hostname.(interface) and /etc/dhcp.(interface). If you are using HME0 you could do this: "echo "" > /etc/hostname.hme0 > /etc/dhcp.hme0". You might want to wipe out information that might conflict like the /etc/defaultrouter file if you created one. Once you've got these two empty files ready just restart the physical network to make the changes effective without a reboot ("svcadm restart physical"). If you want to customize the properties of the DHCP agent you can check out the " System Administration Guide: IP Services" manual. Remember that DHCP settings take acouple seconds to be retrieved from the server so if you reset the physical interfaces as mentioned above and you notice that nothing happened, just wait a couple seconds (30 secs is the default timeout).

I can't figure out what the network interface is called! Linux sort of makes network interface naming easy because typically interfaces are named "eth0", "eth1", so on and so forth. In Solaris, however, the name of the interface is decided by the interface driver. For instance, the onboard ethernet of a Sun Ultra workstation uses the HME (Happy Meal Ethernet, also more boringly called Hundred Meg Ethernet) driver and so the first instance is "hme0". You can look at the device mappings to driver names using "prtconf -D". In general, Solaris will find your network device and try to configure it so generally just checking "ifconfig -a" is enough to find it.

My l337 workstations network device isn't frickin' support!?! Sadly there are lots of networking devices that aren't officially supported (right now anyway, OpenSolaris hopes to change this). Thankfully there are tons of really kool Solaris developers that have been creating open source drivers! Check out these free NIC drivers by Masayuki Murayama! Grok google for drivers, you just might find your l337 gear really does have drivers avalible, they just aren't in Solaris right now.

There ya go.. some quick Solaris networking tips. As always, check out docs.sun.com's Solaris10 manuals for help and details.



Wednesday, January 16, 2008

Tar and Gzip

I always forget the tar and gzip process.. so here is my quick reference.

Creating a tape archive:
tar -cf archive.tar myDirectories/
Note - using the "v" flag prints out extra messages, as verbose mode, though it's not related to extracting files.

Listing the contents of an archive:
tar -tf archive.tar

Extracting all files from an archive:
tar -xf archive.tar
To extract just partial pieces from the archive, supply a file or directory name after the archive name. You can list as many as desiered here, separated by spaces.
tar -xf archive.tar filename

Compress:
gzip archive.tar

Decompress:
gunzip archive.tar.gz

Merged filenames:
Sometimes, you will download files ending with the extension *.tgz - these are essentially identical to files ending with *.tar.gz files. You can gunzip them, and untar them just the same way. If you're working with a recent version of gnu tar, you may be able to take a shortcut, as described below.

My list

No comments, just my list

Mini Anden - http://en.wikipedia.org/wiki/Mini_Anden

Payton List - http://en.wikipedia.org/wiki/Peyton_List

Catherine Blanchet - http://en.wikipedia.org/wiki/Cate_Blanchett

Audrey Hepburn - http://en.wikipedia.org/wiki/Audrey_Hepburn

Grace Kelly - http://en.wikipedia.org/wiki/Grace_kelly

Saturday, December 01, 2007

My Rubik

Ok, first and second layer are easy. Below are the steps I follow to finish the third layer and last face.

Saturday, October 06, 2007

Perl script to automatically dowload files from a web site.

I've been reading Learning Perl book from Randal L. Schwartz and just the introduction gave me the tip to automate a task that otherwise would have taken more time.

Again I am installing Asterisk and a Debian box, I have a list of all the necessary files but now Asterisk put all the sounds files on separate files and not in one package as before.

Instead of downloading 31 pages manually I got a the link to all of them, put them on a file (named filesd) one o each line and run the following Perl script:

#!/usr/bin/perl
open (FILESD, filesd);
while ($pathf = ){
open (WGET, "wget $pathf");
close (WGET);
}


The filesd file is just a plain file like the one shown below:

ricardo@lmntel01:~/test$ more filesd
http://downloads.digium.com/pub/asterisk/releases/asterisk-1.4.12.1.tar.gz
http://downloads.digium.com/pub/zaptel/releases/zaptel-1.4.5.1.tar.gz
http://downloads.digium.com/pub/libpri/releases/libpri-1.4.1.tar.gz
http://downloads.digium.com/pub/asterisk/releases/asterisk-addons-1.4.3.tar.gz


I know this could have been done with WGET but I got tired of trying to find the correct flag to download them, and I also know there is no error check, report, fancy things and whistles but hey I just finish the introduction.

Sunday, September 30, 2007

Eclipse + Perl = Epic

Googling around for a gui ide for Perl I found that there is a plugin for Eclipse. As I also use Eclipse for Java I decided to give it a try and knowing nothing else I found it quite useful. No more of those first vi days (no offense, vi is great but a gui is faster).

You can find about EPIC on http://e-p-i-c.sourceforge.net/, and this time I will not going to explain the installation (as I already installed and didn't took notes) but if you follow their installation manual there is no miss:

http://e-p-i-c.sourceforge.net/downloads/EPIC_User%27s_Guide.pdf

Good luck and if there is a better option let me know and I will give it a try.

Eclipse and Java SDK 1.5 on Debian Etch

As I am still trying to learn java, linux, perl, asterisk and everything I can get distracted with I needed to run eclipse on a new box I set up at home with Debian Etch.

I found the below page quite good on the details on how to achieve this. My steps are copied below:

http://www.crazysquirrel.com/computing/debian/java.jspx


$ apt-get -u install java-package
$ fakeroot make-jpkg java_ee_sdk-5_03-linux.bin

You will see the follwing output:
Creating temporary directory: /tmp/make-jpkg.fktzTQ6486
Loading plugins: blackdown-j2re.sh blackdown-j2sdk.sh common.sh ibm-j2re.sh ibm-j2sdk.sh j2re.sh j2sdk-doc.sh j2sdk.sh j2se.sh sun-j2re.sh sun-j2sdk-doc.sh sun-j2sdk.sh
Detected Debian build architecture: i386
Detected Debian GNU type: i486-linux-gnu
No matching plugin was found.
Removing temporary directory: done

The above command didn't work with the package
java_ee_sdk-5_03-linux.bin so first I tried to make it work. First use the command below to see you have the latest java package installed. I have .28 that is current enough.

$ apt-cache policy java-package | head -2
java-package:
Installed: 0.28

Second try to lie to the installer telling that the installation type if i386 (google arround the message of "plugin not found" and that was the advice). You do this step by entering the following line:

$DEB_BUILD_GNU_TYPE=[i386]-linux fakeroot make-jpkg java_ee_sdk-5_03-linux.bin
The trick is on hte DEB_BUILD_GNU_TYPE that you pass to the process. But as I was still using the java_ee_sdk-5_03-linux.bin from sun it didn't work because the problem was not the plugin but the USER (me) and instead of java_ee_sdk-5_03-linux.bin I should have been using jdk-1_5_0_12-linux-i586.bin. This is the JDK for what make-jpkg was done and after downloading it I was able to make it work.

$fakeroot make-jpkg jdk-1_5_0_12-linux-i586.bin

dpkg-deb: building package `sun-j2sdk1.5' in `/tmp/make-jpkg.trHEuC6948/sun-j2sdk1.5_1.5.0+update12_i386.deb'.
copy sun-j2sdk1.5_1.5.0+update12_i386.deb into directory /home/ricardo/java_source/
The Debian package has been created in the current directory. You can
install the package as root (e.g. dpkg -i sun-j2sdk1.5_1.5.0+update12_i386.deb).

Removing temporary directory: done
After that the package is done and now you only need to run dpkg to install it:
$dpkg -i sun-j2sdk1.5_1.5.0+update12_i386.deb


Check your Java Version just in case you have 2 and you have to use alternatives (explained in another blog) to select the Sun one as default and not the GNU one (usually installed but not in this case).

# java -version
java version "1.5.0_12"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode, sharing)



Installing Wireless D-Link DWL-G520+ on Debian etch

I got a desktop pc, nothing fancy and old p4 with 700MB RAM and a 40GB disk. I will be using it at home where I normally use my work Laptop (Latitude D620 with Ubuntu 7.04) and there is wireless access.

Instead of Ubuntu I installed Debian on it, I downloaded the netinstall of Debian 4 (etch) and did the basic installation. For the first step I did the installation in the office connecting the pc to the network as I am not good doing everything from zero.

Once the pc was up and running I started investigating about my wireless card. I am using a D-Link DWL-G520+. I has been working great on a windows box for the last year and was time to move it to linux.

Looking around you find two main options (although I found some new drivers) using ndiswrapper and acx100.

Much of the googling I read mentioned that acx100 was the correct one for the g520 so I install that one. The installation is simple enough and the steps are below. Note that I've been using it for the last 24hrs and I am not happy with it. I even try to put the Ubuntu install cd and forget about debian/acx100 as the connection fails every now and them (I have on my desk my laptop and this pc and while the pc fails some times and have to either restart X or reboot the machine due a complete freeze the laptop stays connected all the time, arghhh).

The information on how to install the driver ison the acx100 wiki page. The steps I followed are listed below:

http://acx100.sourceforge.net/wiki/Distribution_list/Debian


(as root)

# apt-get update

# apt-get install acx100-source wireless-tools

# module-assistant prepare

(the below step is a menu driven, you have to build the acx100 module)
# module-assistant # It will show a menu to build and install it.
|---> Select / acx100 / Build
|----> Yes
|----> Yes
# modprobe acx

If you want you could load the driver automatically with:
#echo acx >>/etc/modules

#cp tiacx111c16 /lib/firmware/`uname -r`/acx/1.2.1.34
(manually created `uname -r`/acx )

#vi /etc/network/interfaces
# The wireless network interface
allow-hotplug wlan0
iface wlan0 inet dhcp

#shutdown -r now

That was it, after the reboot the machine detected the wireless networks around. Selected mine and enter password and was logged (again I fails time to time).



Monday, September 10, 2007

Synergy 1.3.1 Windowz XP and Ubuntu 7.04

For the last weeks I've been using my laptop with Ubuntu and my office desktop with the corporate windows xp. I was using the Terminal Server Client to work on my desktop but switching between windows was quite boring.

In the past when I used to have windows on boths boxes I run synergy to share the keyboard/mouse but didn't install it yet.

First thing the sudo apt-get install synergy althouth it didn't show any error it didn't show any success either so I remove it.

Next googling around I found the following link with a good explanation on what to do to get started, the link is: https://help.ubuntu.com/community/SynergyHowto

So the steps are:

a) download Synergy the tar.tz from the Synergy project page http://synergy2.sourceforge.net/. The direct link is:
http://kent.dl.sourceforge.net/sourceforge/synergy2/synergy-1.3.1.tar.gz

Untar the file on your home directory.

b) Next install necessary libraries:
sudo apt-get install libxtst-dev
sudo apt-get install build-essential

c) Now configure this but specify the location of the libraries.. if not an error of X cannot be found will appear.

sudo ./configure -x-libraries /usr/lib -x-includes /usr/includes
sudo make install

d) The previous step created synergc (client) and syngers (server) on your home director. The webpage mentioned below ask us to move the mto /user/bin so we do a:

sudo mv /usr/local/bin/synergyc /usr/bin
sudo mv /usr/local/bin/synergys /usr/bin
e) The next step is to configure synergy. The system uses a file called synergy.conf , there is an example on the installation folder at /synergy-1.3.1/examples/synergy.conf.

The configuration is quite easy, I have to say that easier than setting this between to windows boxes. Basically you say which are your 2 boxes and then where is which one respecting the other.

Here you have to use the hostname of your linux box and the name of the windowz box you set up on the windowz client.

So my synergy.conf looks like this:



On the windows machine you set up the ip/hostname (you choose) of your linux box and click on the advance button at the end to set up the name assigned to this machine:



On the advance settings just check the name, if you are having problems just make sure that the name on the below screen is the same as the one on the synergy.conf on your linux box. If they are not the same you will get errors on your client machine.



After this run the server synergys --config synergy.conf from your command line (check previous page you can mv the synergy.conf to your home directory and just run synergy) and start the client, you should be able to use your linux mouse/keyboard on both boxes!!!

Please read the document from the ubuntu documentation mentioned above.

Regards
Richard

Wednesday, September 05, 2007

Configuring Minicom on Ubuntu to connect to Cisco Router

Ok, that was a large title for this task but what the heck. What needs to be done to achieve this? We need a piece of software called minicom (this has been around for ages, google it and you will learn a lot) and follow the next steps shown below:

a) install minicom and follow the normal procedures

sudo apt-get isntall minicom

b) check your serial ports.

We need to know the serial ports on your machine, so a dmseg would do the trick. Look for ttyS and take note of the number after it, in my case I have ttyS0 ready to use.

richard@wok:~$ dmesg|grep ttyS
[ 1.430818] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 1.431528] 00:0c: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
richard@wok:~$


c) launch minicom as root

$sudo minicom

You will see a page as the one below. The first lines shows the configuration (I already modified mine, so yours must be the default ones).


c) Press control + a and Z to go to the menu. The first thing we will change is the dialing string so select the letter "O" for "command string" on the below menu.



d) The previous step should have brought you to the image below. With the arrows keys select "Modem and dialing" and press enter.



e) Now you are on the image below. Press A to set the cursor on the first line and delete everything (I use to have the following configuration ~^M~AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0^M ). One done press ESC or RETURN to go back to the menu.


f) Now back on the menu select "Serial Port Setup" with the arrow keys.


g) Using the letters configure the options:
A - For Serial Device
E - For Bps/Par/Bits

Copy the configuration below, the option "E" will bring a new menu where you select the details. The option A has to match with what you find on the dmseg step "b" of this guide.



h) Exit to the main menu and reset minicom. Restart it so the changes would take effect (maybe there is an option to make the changes live without restarting minicom but this is a small step).

After rebooting minicom with the Cisco router connected with the blue cable to your pc/laptop just turn the Cisco on and you will see the details on the screen and you are good to go. Example below:


I will add more details/tips along the way.

As always good luck!

Saturday, September 01, 2007

FTP Server: Proftpd

I put a server to share files with friends and I had in my hands a little project on how to share them. For this time I chose to use the always friendly FTP service. Googling around I found Proftpd as one of the heavyweights for this and decided to install it. It can be found at: http://www.proftpd.org/.

I am using Debian, 3.1 with kernel 2.6.22.6. Installation thanks to apt is quite easy..

a) apt-get install proftpd .. that was it. no more. (there is a question on installing as inetd or standalone, you should choose your favorite).

The next steps were to set it up so I can create ftp users "virtual" without shell access (they are not that good friends!) and limit them to upload/download only in certain directories.

First add the following on /etc/proftpd/proftpd.conf

# Set /home/FTP-shared directory as home directory
DefaultRoot /media/muploads

# Lock all the users in home directory, ***** really important *****
DefaultRoot ~

AuthUserFile /etc/proftpd/ftpd.passwd
AuthGroupFile /etc/proftpd/ftpd.group


Umask 022 022
AllowOverwrite off

DenyAll




Umask 022 022
AllowOverwrite off

DenyAll



/media/muploads/uploads/>
Umask 022 022
AllowOverwrite on

DenyAll


The directories /media/muploads/uploads and /media/muploads/downloads should exist already.

Second you have to create the users. For this you need to download a file called ftpasswd. This script would be used to create 2 files, ftp.passwd and ftp.group. Both files replaces the system group and passwd files. Read the documentation to learn more about them.

ftpasswd --passwd --name=user --uid=501 --gid=500 --home=/media/muploads --she
ll=/bin/false
ftpasswd --group --name=ftpvirt --gid=500 --member=user


The first command with the --passwd flag will ask you for a password for the user "user", just add it.

The next step is to add the shell /bin/false to the /etc/shells file. If this step is not done when user "user" tries to log in it would get an error as the shell doesn't exist. Note that the shell actually doesn't exist as we don't want the uses to telnet or ssh to the pc but adding the line /bin/false to the file solves the problem.

The final step is to change the permissions of the directories.

on /media/muploads do a:

chown 500:501 downloads
chown 500:501 uploads
chmod 777 uploads


The userid and groupid are the same for all users and directory. It doesn't matter that they don't exists (keep an eye if you have several users not to use this ids). The chmod 777 is quite extreme and you should use something more secure.

The result, an ftp server that allows connections from virtual users. Diverts them directory to a general home directory and not systems home directories and that are allowed to download from one directory and only upload into another.

As always I am sure there are security holes the size on the moon on this procedure but it is a start.

Installing new hard disk on Debian

I got a new disk 40GB disk (found it on the office ether of unused stuff) and installed it on my little Debian server that only has a 20GB disk on it.

The usage of the new disk would be something very productive for the organization, we will use it to share movies!. Ok probably IT Security will kick my ass if they found out but we will deal with that later.

So the steps to add the disk are quite simple. This is an IDE disk and the first step is to connect the hardware (power, ide cable etc). Power up and the fun begins.

a) run fdisk /dev/hdb to partition the disk (check dmseg to see the name it has, in my case hdb that is the standard).
b) on fdisk I just created a primary partition and used 100% of the disk. This depends on the purpose of the disk so study your options. Once the partition is created quit fdisk saving the changes.
c) next step is to format the partition. I am using ext3 so the command to run is
mkfs.ext3 /dev/hdb1
d) next you create a mount partition
mkdir /media/muploads
e) next you mount the disk
mount /dev/hdb1 /media/muploads
f) finally change your fstab settings so the disk is mounted on every boot.
vi /etc/fstab
add the following line
/dev/hdb1 /media/muploads ext3 defaults 0 2


That was all. I am sure betting things can be done for RAID, etc. Notes are welcome (almost).
Good luck

Book: Five Years at the Epicenter of the Dot.Com Juggernaut


I just finished reading this book - Five Years at the Epicenter of the Dot.Com Juggernaut by James Marcus - and unfortunately I couldn't see the put my experience on the authors tale. I enjoyed the book and found it amusing and educational on my search to see how business are made but as I work on a dot.com myself I was hoping to find an outside look of what I daily see.

My work on a dot.com is not as glamorous as James's but I believe I leave my footprint on the not so "dot.com" part of the business (after all I am a telephony administrator/engineer on it) and also I have to say and I join the on the late shift (5 years after the company appear) so I was not on the stock options group - although I new some of them and when the company was finally bought there were no millionaires on the building except the top execs - as he was.

Going back to the book, first I would like to write reviews like his but this is just a group of characters put together in bad sentences with what is on my head, so Sorry James!. I leave the book with the wish to read as much as possible. I love the passion on reading the author has and shows on his writing. I consider myself lucky to be able to read more than 15 books a year that although I know is nothing - my father easily reads 4/5 times that number - is much more than all the people I know. I want to start reading the not so marking books, most of my reading is bestseller top shelf nice cover good reviewed type of book. I want to read and enjoy those not so known authors that haven't sold their souls to the publishing machinery, it is just september so I still have a chance to get it.

Another point of the book that I didn't like was that the book could have been about a beer factory and not one of the pioneers on the tech boom. I know the author mentions it all the time but every business wants to revolutionize his market anyway so if you replace the amazon for other success history the books remain the same. What I am trying to see is that I see it more as a history about corporate work than a specific book about working in amazon. Again sorry James but I don't think you will never read this anyway, I really think nobody would ever read this in fact!

In summary a good read, I like books like The Search or Google more to learn about dot.com companies but I recommend the book (this is my editorial at the end!) to everybody.