Subversion Backup and Restore

July 21, 2011 Leave a comment
Categories: Uncategorized

Vi – switching cases

April 13, 2011 Leave a comment

In the replacement part of a substitution command, i.e. between the second "/" and third "/",

\u means make the following character upper case
\l means make the following character lower case
\U means make the rest of the replacement upper case

\L means make the rest of the replacement lower case

How about a few examples?

  1. Make the first letter of every word from line 18 to 43 uppercase.
    :18,43s/\<./\u&/g
  2. Change "uPPeR" and "LoweR" in any mixture of cases to lowercase.
    :s/[UuLl][PpOo][PpWw][Ee][Rr]/\L&/
  3. Make the whole file uppercase.
    :%s/.*/\U&/
  4. Make the region from line m to line n all uppercase.
    :'m,'ns/.*/\U&/
  5. Make a paragraph all lowercase.
    :?^$?,/^$/s/.*/\L&/
  6. Make the first letter of every word in a paragraph uppercase.
    :?^$?,/^$/s/\([^ ][^ ]*\)/\u&/g
  7. Make the second word of each line uppercase.
    :1,$s/^\([^ ]*\) \([^ ]*\) \(.*\)/\1 \U\2\e \3/
Categories: Uncategorized

find the WWN (World Wide Name) in Sun Solaris

March 7, 2011 1 comment

World Wide Name (WWN) are unique 8 byte (64-bit) identifiers in SCSI or fibre channel similar to that of MAC Addresses on a Network Interface Card (NIC).

Talking about the WWN names, there are also

World Wide port Name (WWpN), a WWN assigned to a port on a Fabric which is what you would be looking for most of the time.

World Wide node Name (WWnN), a WWN assigned to a node/device on a Fibre Channel fabric.

To find the WWN numbers of your HBA card in Sun Solaris, you can use one the following procedures

Using fcinfo (Solaris 10 only)

This is probably the easiest way to find the WWN numbers on your HBA card. Here you can see the HBA Port WWN (WWpN) and the Node WWN (WWnN) of the two ports on the installed Qlogic HAB card.

This is also useful in finding the Model number, Firmwar version FCode, supported and current speeds and the port status of the HBA card/port.

root@ sunserver:/root# fcinfo hba-port | grep WWN
HBA Port WWN: 2100001b32xxxxxx
Node WWN: 2000001b32xxxxxx
HBA Port WWN: 2101001b32yyyyyy
Node WWN: 2001001b32yyyyyy

For detailed info including Make & model number, Firmware, Fcode and current status and supported/current speeds then

root@ sunserver:/root# fcinfo hba-port
HBA Port WWN: 2100001b32xxxxxx
OS Device Name: /dev/cfg/c2
Manufacturer: QLogic Corp.
Model: 375-3356-02
Firmware Version: 4.04.01
FCode/BIOS Version: BIOS: 1.24; fcode: 1.24; EFI: 1.8;
Type: N-port
State: online
Supported Speeds: 1Gb 2Gb 4Gb
Current Speed: 4Gb
Node WWN: 2000001b32xxxxxx
HBA Port WWN: 2101001b32yyyyyy
OS Device Name: /dev/cfg/c3
Manufacturer: QLogic Corp.
Model: 375-3356-02
Firmware Version: 4.04.01
FCode/BIOS Version: BIOS: 1.24; fcode: 1.24; EFI: 1.8;
Type: unknown
State: offline
Supported Speeds: 1Gb 2Gb 4Gb
Current Speed: not established
Node WWN: 2001001b32yyyyyy

Using scli

root@ sunserver:/root# scli -i | egrep “Node Name|Port Name”
Node Name : 20-00-00-1B-32-XX-XX-XX
Port Name : 21-00-00-1B-32-XX-XX-XX
Node Name : 20-01-00-1B-32-YY-YY-YY
Port Name : 21-01-00-1B-32-YY-YY-YY

For more detailed info on the HBA Cards run as follows: Similar to fcinfo but also provides Model Name and serial number.

root@ sunserver:/root# scli -i
——————————————————————————
Host Name : sunserver
HBA Model : QLE2462
HBA Alias :
Port : 1
Port Alias :
Node Name : 20-00-00-1B-32-XX-XX-XX
Port Name : 21-00-00-1B-32-XX-XX-XX
Port ID : 11-22-33
Serial Number : AAAAAAA-bbbbbbbbbb
Driver Version : qlc-20080514-2.28
FCode Version : 1.24
Firmware Version : 4.04.01
HBA Instance : 2
OS Instance : 2
HBA ID : 2-QLE2462
OptionROM BIOS Version : 1.24
OptionROM FCode Version : 1.24
OptionROM EFI Version : 1.08
OptionROM Firmware Version : 4.00.26
Actual Connection Mode : Point to Point
Actual Data Rate : 2 Gbps
PortType (Topology) : NPort
Total Number of Devices : 2
HBA Status : Online
——————————————————————————
Host Name : sunserver
HBA Model : QLE2462
HBA Alias :
Port : 2
Port Alias :
Node Name : 20-01-00-1B-32-YY-YY-YY
Port Name : 21-01-00-1B-32-YY-YY-YY
Port ID : 00-00-00
Serial Number : AAAAAAA-bbbbbbbbbb
Driver Version : qlc-20080514-2.28
FCode Version : 1.24
Firmware Version : 4.04.01
HBA Instance : 3
OS Instance : 3
HBA ID : 3-QLE2462
OptionROM BIOS Version : 1.24
OptionROM FCode Version : 1.24
OptionROM EFI Version : 1.08
OptionROM Firmware Version : 4.00.26
Actual Connection Mode : Unknown
Actual Data Rate : Unknown
PortType (Topology) : Unidentified
Total Number of Devices : 0
HBA Status : Loop down

Using prtconf

root@ sunserver:/root# prtconf -vp | grep -i wwn
port-wwn: 2100001b.32xxxxxx
node-wwn: 2000001b.32xxxxxx
port-wwn: 2101001b.32yyyyyy
node-wwn: 2001001b.32yyyyyy

Using prtpicl

root@ sunserver:/root# prtpicl -v | grep wwn
:node-wwn 20 00 00 1b 32 xx xx xx
:port-wwn 21 00 00 1b 32 xx xx xx
:node-wwn 20 01 00 1b 32 yy yy yy
:port-wwn 21 01 00 1b 32 yy yy yy

Using luxadm

Run the following command to obtain the physical path to the HBA Ports

root@ sunserver:/root$ luxadm -e port
/devices/pci@400/pci@0/pci@9/SUNW,qlc@0/fp@0,0:devctl CONNECTED
/devices/pci@400/pci@0/pci@9/SUNW,qlc@0,1/fp@0,0:devctl NOT CONNECTED

With the physical path obtained from the above command, we can trace the WWN numbers as follows. here I use the physical path to the one that is connected:

root@ sunserver:/root$ luxadm -e dump_map /devices/pci@400/pci@0/pci@9/SUNW,qlc@0/fp@0,0:devctl
Pos Port_ID Hard_Addr Port WWN Node WWN Type
0 123456 0 1111111111111111 2222222222222222 0×0 (Disk device)
1 789123 0 1111111111111111 2222222222222222 0×0 (Disk device)
2 453789 0 2100001b32xxxxxx 2000001b32xxxxxx 0x1f (Unknown Type,Host Bus Adapter)

Categories: Uncategorized

SAN hba register process

March 7, 2011 Leave a comment
Categories: SAN

whats new in solaris11

November 18, 2010 Leave a comment
Categories: Solaris

Exporting Tomcat SSL keys to Apache httpd

November 12, 2010 1 comment

Apache Tomcat SSL keys created with keytool are, by default, in der format. These keys cannot be used in Apache httpd since httpd, be default, expects the keys in pem(X509) format. Using the below steps you can export the tomcat’s keys to Apache httpd format and use it for Apache.

I assume that you already have a working copy of tomcat with SSL.

If Not follow Verisign’s instructions on requesting an SSL certificate, then:

  • Create a keystore: $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA
  • Import the Intermediate CA Certificate: keytool -import -alias root -keystore <your_keystore_filename> -trustcacerts -file <filename_of_the_chain_certificate>
  • Import your SSL Certificate: keytool -import -alias <your_alias> -keystore <your_keystore_filename> -trustcacerts -file <your_certificate_filename>

You will need a copy of the tomcat’s keystore file and the keystore password.

Let us start….

First copy the existing tomcat’s keystore file to a new directory so that we don’t break anything that is working.

List the key and verify you know the passphrase.
# keytool -list -keystore your.key

Now we will export the key in DER format
# keytool -export -alias tomcat -keystore tomcat.keystore -file exported-der.crt
Enter keystore password:
Output will be: Certificate stored in file

The certificate will be stored in the file called exported-der.crt

Verify the certificate with this command:
# openssl x509 -noout -text -in exported-der.crt -inform der
Output will be: The whole certificate saying – who issued it and other info like your company name etc.

Now Convert the key to PEM format so that apache can understand it:
# openssl x509 -out exported-pem.crt -outform pem -in exported-der.crt -inform der

The exported key will be in the file exported-pem.crt.

We have exported the public key and now are going to export the private key.

Download a file called (ExportPrivateKey.zip) from Anandsekar.com

Extract the key
# java -jar ExportPrivateKey.zip {keystore_path} JKS {keystore_password} {alias} exported-pkcs8.key

The key is in PKCS #8 PEM format. Now run openssl to convert it to the format apache modssl expects the file.
Use a cygwin shell to get a good version of OpenSSL without having to install another application.
# openssl pkcs8 -inform PEM -nocrypt -in exported-pkcs8.key -out exported.key

The Private key is now exported to the file exported.key.

Edit the httpd.conf/httpd-ssl.conf file
SSLCertificateFile /root/SSL_export/exported-pem.crt -> I used the cert from Verisign instead.
SSLCertificateKeyFile /root/SSL_export/exported.key
SSLCertificateChainFile /root/SSL_export/<intermediate>

Example:
#Verisign Certificate
SSLCertificateFile “C:/Program Files/Apache Software Foundation/Apache2.2/conf/cmmssl/cert/cert.crt”
# Our new key
SSLCertificateKeyFile “C:/Program Files/Apache Software Foundation/Apache2.2/conf/cmmssl/private/exported.key”
# The Verisign Intermediary cert file.
SSLCertificateChainFile “C:/Program Files/Apache Software Foundation/Apache2.2/conf/cmmssl/intermediate/intermediate.crt”

Restart Apache, with fingers crossed, pixie dust in the air, while the rooster crows, on a full moon, and a live sacrificial chicken waiting on standby.

Categories: Uncategorized

one line command to create directory structure

August 16, 2010 Leave a comment

goto into source directory
#cd <sourcedirectory>

find all the directories and xargs will create the structure in destdir(if you have different name just change destdir in the following command)

#find . -type d | xargs -i mkdir ../destdir/{}

Mission Accomplished…!

Categories: Solaris

tomcat as Solaris 10 SMF services

June 23, 2010 Leave a comment

Have been searching around to have Tomcat as Solaris 10 SMF services for easy maintenance. Didn’t find one.. so writing one

Two things
1) Adding tomcat as SMF services
2) Having users other than root to be able to start/stop the service

1)Adding Tomcat as SMF service

The first step is to create a service descriptor and import it as follows:

# svccfg import ./tomcat.xml
# svcs tomcat
STATE STIME FMRI
offline* 13:27:04 svc:/application/tomcat:default

The service descriptor has been imported and we check the status of the service using “svcs tomcat”. You’ll note that it’s state at this point is “offline*”. What this means is that SMF is in the process of starting the service.

# svcs tomcat
STATE STIME FMRI
offline* 13:27:11 svc:/application/tomcat:default
#
Still waiting ...
#
# svcs tomcat
STATE STIME FMRI
online 13:27:16 svc:/application/tomcat:default

here is an example tomcat.xml I made

<!DOCTYPE service_bundle SYSTEM “/usr/share/lib/xml/dtd/service_bundle.dtd.1”>
<!– Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. ident “@(#)webmin.xml 1.1 04/11/11 SMI” Service manifest for the Webmin service. –> <service
_bundle type=’manifest’ name=’tomcat’>
<service name=’application/servers/tomcat’ type=’service’ version=’1′>
<create_default_instance enabled=’false’ />
<single_instance/>
<dependency name=’network’ grouping=’require_all’ restart_on=’error’ type=’service’>
<service_fmri value=’svc:/milestone/network:default’/>
</dependency>
<dependency name=’filesystem-local’ grouping=’require_all’ restart_on=’none’ type=’service’>
<service_fmri value=’svc:/system/filesystem/local:default’/>
</dependency>
<exec_method type=’method’ name=’start’ exec=’/usr/webservices/apache-tomcat-6.0.16/bin/startup.sh’ timeout_seconds=’30’ >  <method_context>
<method_credential user=’oracle’ group=’dba’ />  </method_context>
</exec_method>
<exec_method type=’method’ name=’stop’ exec=’/usr/webservices/apache-tomcat-6.0.16/bin/shutdown.sh’ timeout_seconds=’60’ />
<stability value=’Unstable’ />
<template>
<common_name>
<loctext xml:lang=’C’> Tomcat </loctext>  </common_name>
<!– <documentation>  <manpage title=’webmin’ section=’1M’ manpath=’/usr/sfw/man’ />
</documentation> –>
</template>
</service>
</service_bundle>

2) Having users other than root to be able to start/stop the service
I have oracle userid which need to be able to do maintenance on Tomcat, so oracle userid need to have access to stop/start services. It can be achieved with the combination of SMF service and RBAC.

1. Edit the “/etc/security/auth_attr” file to add the special authorization that “oracle” will use to manage the Tomcat. Add the line :

solaris.smf.manage.tomcat:::Manage Tomcat Service States::

2. Add that authorization to oracle’s list :

#usermod -A solaris.smf.manage.tomcat oracle

At that point, RBAC’s configuration is over but SMF is not yet aware of anything. This is probably the first surprising finding. Appending the service name to the preexisting solaris.smf.manage is as far as I know purely some naming best practice. What I mean is that SMF by default only recognizes general authorizations like solaris.smf.manage or solaris.smf.modify.application. Anything more specific will have to be configured manually into the SMF repository.

3. Modify the configuration of the Tomcat service_fmri using the “general/action_authorization” property. The smf_security manpage says that “general/action_authorization property can specify additional authorizations that permit service actions to be requested for that service instance.”
So if you don’t want to give oracle the authorization to manage all services using solaris.smf.manage, you need to specify the specific one that grants Oracle the right to manage the Tomcat.

# svcprop -p general tomcat
general/enabled boolean true
general/entity_stability astring Unstable
general/single_instance boolean true
#
#svccfg -s tomcat setprop general/action_authorization=astring:"solaris.smf.manage.tomcat"
#svccfg -s tomcat setprop general/value_authorization=astring:"solaris.smf.manage.tomcat"

Don’t forget to make the change active :

# svcadm refresh tomcat

And check the result :

# svcprop -p general tomcat
general/enabled boolean true
general/entity_stability astring Unstable
general/single_instance boolean true
general/action_authorization astring solaris.smf.manage.tomcat
general/value_authorization astring solaris.smf.manage.tomcat

4. Let’s see what oracle can do now :


# su - oracle
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
#
# svcadm disable tomcat
# svcadm enable tomcat

All set for tomcat SMF services.

Categories: Solaris

How to use wildcard in find command

June 14, 2010 Leave a comment

You can use shell-style wildcards in the -name search argument:

find . -name foo\*bar

This will search from the current directory down for foo*bar (that is, any filename that begins with foo and ends with bar). Note that wildcards in the name argument must be quoted so the shell doesn’t expand them before passing them to find. Also, unlike regular shell wildcards, these will match leading periods in filenames. (For example “find -name \*.txt”.)

Categories: Solaris

keystore public key extract

April 12, 2010 Leave a comment

If you are using a keystore to have the ssl certificate, exporting the public key from a keystore

#keytool -export -keystore keystore -alias tomcat -file tomcat.cer -storepass ‘storepass’ -keypass ‘clientkey’

where
-keystore -file location where keystore is saved
-file – where you want to store the public key
-storepass -keystore password you gave while creating the keystore
-keypass -password you want the client to use while importing the key to their environment

Categories: Solaris
Design a site like this with WordPress.com
Get started