Friday, July 31, 2009

wget with basic authentication.

Here's how you download a file from internet which is secured by basic authentication. Replace myusername, mypassword with your own username and password.


wget http://download_file --http-user=myusername --http-passwd=mypassword

Wednesday, July 29, 2009

Hudson init script for Ubuntu 9.04

Hudson init script for ubuntu 9.04. This is available on hudson's website too.

http://wiki.hudson-ci.org/display/HUDSON/Installation+and+Execution

This is what worked for me. The one hudson website is for linux. This you can use as is without modifications (except for "RUN_AS") on ubuntu


#!/bin/sh

DESC="Hudson CI Server "
NAME=hudson
PIDFILE=/var/run/$NAME.pid
RUN_AS=sysadm

d_start() {
start-stop-daemon --start --quiet --background -m --pidfile $PIDFILE --chuid $RUN_AS --exec /usr/bin/java -- -Dhudson.scm.CVSSCM.skipChangeLog=true -jar /opt/hudson/hudson.war
}

d_stop() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE
if [ -e $PIDFILE ]
then rm $PIDFILE
fi
}

case $1 in
start)
echo -n "Starting $DESC: $NAME "
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME "
d_stop
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME "
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "usage: $NAME {start|stop|restart}"
exit 1
;;
esac

exit 0

SSH without Password

I got information from this site

http://www.csua.berkeley.edu/~ranga/notes/ssh_nopass.html

SSH Without a Password

The following steps can be used to ssh from one system to another without specifying a password.
Notes:

* The system from which the ssh session is started via the ssh command is the client.
* The system that the ssh session connects to is the server.
* These steps seem to work on systems running OpenSSH.
* The steps assume that a DSA key is being used. To use a RSA key substitute 'rsa' for 'dsa'.
* The steps assume that you are using a Bourne-like shell (sh, ksh or bash)
* Some of this information came from:
http://www.der-keiler.de/Mailing-Lists/securityfocus/Secure_Shell/2002-12/0083.html

Steps:

1.

On the client run the following commands:


$ mkdir -p $HOME/.ssh
$ chmod 0700 $HOME/.ssh
$ ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P ''


This should result in two files,


$HOME/.ssh/id_dsa (private key) and
$HOME/.ssh/id_dsa.pub (public key).


2.

Copy $HOME/.ssh/id_dsa.pub to the server.


3.

On the server run the following commands:


$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys2
$ chmod 0600 $HOME/.ssh/authorized_keys2


Depending on the version of OpenSSH the following commands may also be required:


$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys
$ chmod 0600 $HOME/.ssh/authorized_keys



An alternative is to create a link from authorized_keys2 to authorized_keys:


$ cd $HOME/.ssh && ln -s authorized_keys2 authorized_keys


4.

On the client test the results by ssh'ing to the server:


$ ssh -i $HOME/.ssh/id_dsa server



5.

(Optional) Add the following $HOME/.ssh/config on the client:


Host server
IdentityFile ~/.ssh/id_dsa


This allows ssh access to the server without having to specify the path to the id_dsa file as an argument to ssh each time.

HUDSON: THINGS TO REMEMBER [Skip Change Log]

While starting hudson use:
java -Dhudson.scm.CVSSCM.skipChangeLog=true -jar hudson.war

This makes sure that hudson skips computing change log. Computing change log option is
slow for one thing and caused a lot of problems while I was setting it up in our projects.


Saturday, July 11, 2009

Carnatic Music Website.

http://www.ecse.rpi.edu/Homepages/shivkuma/personal/music/index.html

Professor Shiv Kumar Kalyanaraman's carnatic music archive. Wonderful website for carnatic music.

Monday, June 29, 2009

Move sqlserver tables to dbo user

SELECT 'ALTER SCHEMA dbo TRANSFER ' + SCHEMA_NAME(schema_id) + '.' + name
FROM sys.tables
WHERE schema_id != SCHEMA_ID('dbo');

Sunday, June 21, 2009

Starting JavaDB (Derby) in glassfish.

I was following sahoo's Blog for creating an enterprise application with ejb3.0.
http://weblogs.java.net/blog/ss141213/archive/2005/12/using_java_pers.html

Ran into problem since JavaDB isn't started automatically when glassfish starts.

Error was "Error connecting to server localhost on port 1527 with message Connection refused: connect."

Solution:

You will have to issue below command to start derby database:

GlassFishHome/bin/> asadmin start-database

Hope this helps someone having similar issues.

Saturday, June 20, 2009

Samba File Sharing Ubuntu

SSH server is disabled by default in ubuntu. From package manager select & install ssh-server.

Samba File Sharing:

Setup up username & password:
smbpasswd -a
you'll be prompted to set the password.


Restart Samba service to take effect: [Just for good measure]
sudo /etc/init.d/samba restart

UBUNTU setting up environment variables.

Use file /etc/bash.bashrc to setup new environment variables.


Do not use: /etc/profile
Do not use: /etc/environment file might work too.

Procedure:

1. Edit: /etc/bash.bashrc
2. Add this line to the end of the file. This sets JAVA_HOME

export JAVA_HOME=/usr/lib/j2sdk1.5-sun/

Linux helpful commands

List of processes:
Solaris stats: prstat
Redhat stats: top


COMMON:
more /proc/version --- To see which version of linux
cat /proc/cpuinfo
cat /proc/meminfo

Creating symbolic link (shortcut in *unix) :
ln -s file_name shortcutname

Placing java in your path:
create link to the version of java into /usr/bin

Linux Runlevels:
who -r (gives run level of the system)
vi \etc\inittab (shows you the runlevel system is starting)

cd \etc\rc5.d (start up scripts for run level 5. K's represent donot start. S's represent start)
cd \etc\rc3.d (start up scripts for run level 5. K's represent donot start. S's represent start)
mv K36mysqld S36mysqld

ln -s ../init.d/jboss S36Jboss
mv S36Jboss K36Jboss
rm K36Jboss

WGET: [Connect to internet and download a file]

wget http://download_file_url