svn comments validation at commit

Here we are going to put validation on svn comments while doing commit. At the time of commit if logs are not given then commit will failed giving errors.

Step1: Go to folder svn_repository/hook. Copy pre-commit.tmpl to pre-commit

Step2: Now Add following line into it.

set -e

/Location/to/svn/repository/hooks/checkCommentNotEmpty.sh "$1" "$2"

Step3: Now create checkCommentNotEmpty.sh file into hook directory. Add following content into that file.

#!/bin/bash

REPOS="$1"

TXN="$2"

SVNLOOK=/usr/bin/svnlook



if [`$SVNLOOK log -t $TXN $REPOS` != ""]; then

echo "" 1>&2

echo "*** Your commit has been blocked because you did not give any log message or your log message was too short." 1>&2

echo "Please write a log message describing the purpose of your changes and then try committing again." 1>&2

exit 1

else

exit 0

fi

Step 4: now give execute permission on both file then try commit without /with giving comments.

Configuring Juniper webbased VPN in Ubuntu 10

Step 1: First remove openjdk from the Ubuntu ( Juniper requires SUN JDK only)

Step 2: Installing Sun Java in Ubuntu
sudo apt-get install sun-java6-jdk

Step 3: map libnpjp2.so file into ~/.mozilla/plugin directory. (You may need to create ~/.mozilla/plugin directory)

Issue: SSH taking time to logon to other server through ssh on Ubuntu

Hi,

I had issue, while I was trying access any linux server in my network from ubuntu, it was taking time (around 1 min). So to get rid of this issue, I searched on google and I found remedy. Follow below steps :)

1) Specify the option to disable GSSAPI authentication when using SSH or SCP command, e.g.:
ssh -o GSSAPIAuthentication=no appssupp@10.50.100.111

-OR-

2) Explicitly disable GSSAPI authentication in SSH client program configuration file, i.e. edit the /etc/ssh/ssh_config and add in this configuration (if it’s not already in the config file):
GSSAPIAuthentication no

-OR-

3) Like 2 but in your private ssh config
Edit /home/YOURUSERNAME/.ssh/config and add
GSSAPIAuthentication no

After doing any of the above, restart ssh service in ubuntu. I would suggest to go for 3rd option.

Thanks.

Database backup/restore in Postgres

To take Postgres database backup you can use below command.

Backup:  $ pg_dump -U {user-name} {source_db} -f {dumpfilename.sql}

For restore procedure use below:

Restore: $ psql -U {user-name} -d {desintation_db}-f {dumpfilename.sql}

To backup all databases use below command:

pg_dumpall > all.sql

To backup a specific postgres table
$ pg_dump --table tablename -U username databasename -f tablebackupfule.sql


To restore postgres database use below command

$ psql -U username -d databasename -f mydb.sql

To restore all databases

psql -f alldb.sql

To restore specific table:

psql -f tablebackupfile.sql databasename

Thanks

Sample IPTABLES rules in Linux

Here I'm going to set Iptables in linux to allow traffic from perticular source to perticular destination on perticular port. Other incoming/outgoing traffic will be blocked.

rules are given in script file.

#!/bin/sh
# My system IP/set ip address of server
SERVER_IP="192.168.100.233"
# Flushing all rules
iptables -F
iptables -X
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
# Allow unlimited traffic on loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT


# Allow incoming ssh only
iptables -A INPUT -p tcp -s 192.168.100.32 -d $SERVER_IP --sport 513:65535 --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s $SERVER_IP -d 0/0 --sport 22 --dport 513:65535 -m state --state ESTABLISHED -j ACCEPT


# Allow incoming DB2 only
iptables -A INPUT -p tcp -s 192.168.100.231 -d $SERVER_IP --sport 513:65535 --dport 50000 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s $SERVER_IP -d 0/0 --sport 50000 --dport 513:65535 -m state --state ESTABLISHED -j ACCEPT


# Allow incoming NAGIOS only
iptables -A INPUT -p tcp -s 192.168.100.253 -d $SERVER_IP --sport 513:65535 --dport 5666 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s $SERVER_IP -d 0/0 --sport 5666 --dport 513:65535 -m state --state ESTABLISHED -j ACCEPT


# Allow incoming ICMP only
iptables -A INPUT -p tcp -s 192.168.100.253 -d $SERVER_IP --sport 513:65535 --dport 5666 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s $SERVER_IP -d 0/0 --sport 5666 --dport 513:65535 -m state --state ESTABLISHED -j ACCEPT


# make sure nothing comes or goes out of this box
iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP


The above rules are self explanatory. Lets discuss if you have any query.

Thank you.

Installing java in Linux

Downloading

Download the latest version of JDK from http://www.java.sun.com. I have downloaded jdk-1_5_0_01-linux-i586.bin for this tutorial.
Installing
Change to the directory where you downloaded the JDK ( I downloaded it in my home directory /home/alpesh) and make the self-extracting binary executable:
chmod +x jdk-1_5_0_01-linux-i586.binRun the self-extracting binary, this will display the License agreement text and will ask you to accept the agreement:
./jdk-1_5_0_01-linux-i586.bin
Above command should create a directory called jdk1.5.0_01 in the /home/alpesh directory. Move the JDK directory to /opt . Here is the command used:
mv jdk1.5.0_01 /opt
Set the JAVA_HOME environment variable, by modifying /etc/profile so it includes the following:
JAVA_HOME="/opt/jdk1.5.0_01"
export JAVA_HOME


save /etc/profile file. Then run following command to take into effect.
source /etc/profile
Check to make sure JAVA_HOME is defined correctly using the command below. You should see the path to your Java JDK.
echo $JAVA_HOME
Output should be
/opt/jdk1.5.0_01
Now need to set out new Java as default thorugh alternative utility. First we will install alternative java then we will configure it make it as default java.
To install java using alternative command:
alternatives --install /usr/bin/java java /opt/jdk1.5.0_01/bin/java 2
Now need to configure it to make it as default Java location:

alternatives -config java

Above command will give below output. There we will have to select latest java location.
[root@alpeshpc opt]# alternatives --config java

There are 3 programs which provide 'java'.

Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
2 /opt/jdk1.5.0_01/bin/java

Give there number 2, then press enter.

Thats it.

Now you can check Java installation using java –version command.
Now you can check Java installation using java –version command.
  • You may come across issue, even if java installed but your browser will give warning that java is not installed. So you will need to follow below steps to make java applet work in browser.
Note: You may have different java version, so change java version accordingly in below commands.

## Java Browser (Mozilla) Plugin 32-bit ## 
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.6.0_33/jre/lib/i386/libnpjp2.so 20000   

## Java Browser (Mozilla) Plugin 64-bit ## 
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.6.0_33/jre/lib/amd64/libnpjp2.so 20000

Cisco Anyconnect VPN client in Linux

Before we start installation of Cisco anyconnect VPN client, I assume that Certificates has been installed in browser. If so, then follow given steps.

# downloaded the latest Linux Anyconnect client from http://www.cisco.com
tar -xvzf anyconnect-linux-2.3.0185-k9.tar.gz
cd ciscovpn/
sudo ./vpn_install.sh

# Downloaded latest firefox from http://www.mozilla.com/en-US/firefox/ and extract into /usr/local directory only.
sudo tar -xvjf firefox-3.0.5.tar.bz2 -C /usr/local

After the give below command to create soft link of library files.

for lib in libnssutil3.so libplc4.so libplds4.so libnspr4.so libsqlite3.so libnssdbm3.so libfreebl3.so ; do sudo ln -s /usr/local/firefox/$lib /opt/cisco/vpn/lib/$lib ; done

Once above mentioned steps followed, start Cisco Anyconnect VPN client and check if it is working or not. If you get Certificate errors then try using above mentioned commands using root user.

Confugure VNC in Linux


(1) Run following commands to install VNC in linux.

yum install vnc-server

(2) Run following command to set password for the V NC connection.

vncpasswd
(3) Edit /etc/sysconfig/vncservers, and add the following to the end of the file.

VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 800x600 "
(4) Now restart Vnc service giving following command.

/etc/init.d/vncserver restart

Ex;
[root@saplinux ~]# /etc/init.d/vncserver restart
shutting down VNC server: 2:root [FAILED]
Starting VNC server: 2:root xauth: creating new authority file /ro ot/.Xauthority
New 'saplinux:2 (root)' desktop is saplinux:2
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/saplinux:2.log
[ OK ]

(5) Now open /root/.vnc/xstartup file and uncomment followi ng two lines.

unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
(6) Then restart VNC service and then check from the windows PC through VNC viewer.

/etc/init.d/vncserver restart

(7) To check from the vnc viewer you will have to give VNC server's IP and then :2.

ex: 192.168.1.2:2



It will ask you for the password, you can give password which was assigned throgh vncpasswd command.

Configure VNC in Solaris 10

Configure VNC in Solaris 10

mkdir -p /etc/dt/config

cp /usr/dt/config/Xservers /etc/dt/config/Xservers

edit this file “/etc/dt/config/Xservers” and add these lines at the end:

:1 Local local_uid@none root /usr/X11/bin/Xvnc :1 -nobanner -AlwaysShared -SecurityTypes None -geometry 1024×768x24 -depth 24

Then restart the server.

Shell Script to create samba users in bulks

If you want to crate so many numbers of users at once, then you can do that by running the given shell script.

*********************************
#!/bin/bash
#
# Ensure that root is running the script.
##
WHOAMI=`/usr/bin/whoami`
if [ $WHOAMI != "root" ]; then
echo "You must be root to add news users!"
exit 1
fi
#
clear
NEW_USERS="/root/names.txt"
echo "Enter password you want to set for all users:"
read SMBPASS
cat $NEW_USERS | while read USER; do
#adduser $USER `echo $SMBPASS`; `echo $SMBPASS` | passwd --stdin $USER > /dev/null
adduser $USER -p $SMBPASS
echo Added user $USER
smbpasswd -e $USER -w $SMBPASS > /dev/null
(echo $SMBPASS; echo $SMBPASS) | smbpasswd -as $USER
echo -e "$USER = $USER" >> /etc/samba/smbusers
done
*********************************

Here in this script, you will have to give name of the users in /root/names.txt file line by line.
For Ex:
********
alpesh
keyur
ashish
********

Once you run this script, it will ask you for the password which you want to assign for each users.

I hope this will help you.