Wednesday, October 17, 2012

SVN Repo to git repo migration

Migration from SVN to GIT

1.      osvn co svn://10.10.10.5/svn/repo
2.      cd Sears
3.      svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
4.      vi authors-transform.txt
5.      svn info
6.      git svn clone svn://10.10.10.5/svn/repo --no-metadata -A authors-transform.txt --stdlayout /root/repo
7.      cd /root/repo
8.      git remote add origin git@git.abc.com:test/dip.git
Remove .SVN folder from GIT
find . -type d -name .svn -exec git rm -rf {} \;
To create a duplicate of a repo without forking, you need to run a special clone command against the original repo and mirror-push to the new one. This works with any git repo, not just ones hosted on GitHub.

overall workflow for migration will be as follow
1) Make Gitorious  repo read only so that nobody can push to git repo
2) Do git clone with bare -- flag from Gitorious
3) Do push --mirror to github
4) Ask developers to change remote to github (Each developer will have to do this step)
Lets do this thing!
In order to make an exact duplicate, you need to perform both a bare-clone and a mirror-push:
git clone --bare https://github.com/exampleuser/old-repo.git# Make a bare clone of the repo

cd old-repo.git
$ git push --mirror https://github.com/exampleuser/new-repo.git# Mirror-push to the new repo

cd ..
$ rm -rf old-repo.git# Remove our temporary local repoEvery Developer needs to following stepcd existing-working-copygit remote set-url origin git@github.com:/exampleuser/new_repo.git# change remote for existing clone pointing to old repo. Command above will set local clone to use new repo as remote

Tuesday, October 16, 2012

Internet Access Through pptp vpn server on centos

Internet Access Through pptp vpn server on centos

Installation and Configuration of PPTP
Add the Poptop Yum Repository
rpm -Uhv http://poptop.sourceforge.net/yum/stable/rhel5/pptp-release-current.noarch.rpm
yum install ppp pptpd
Configure Kernel
Edit /etc/sysctl.conf
FROM net.ipv4.ip_forward = 0 To net.ipv4.ip_forward = 1
Verify changes sysctl –p
Configure Client Network Options
Modify /etc/pptpd.conf
localip 192.168.50.1
remoteip 192.168.50.2-15
Modify /etc/ppp/options.pptpd
ms-dns 8.8.8.8
ms-dns 8.8.4.4
Configure Client Access
Edit /etc/ppp/chap-secrets.
# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
mccarrms        *       mccarrms-password       *
IPTables Rules
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -p gre -j ACCEPT
-A INPUT -p gre -j ACCEPT
-A INPUT -p gre -j ACCEPT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp -m icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p esp -j ACCEPT
-A RH-Firewall-1-INPUT -p ah -j ACCEPT
-A RH-Firewall-1-INPUT -d 224.0.0.251 -p udp -m udp --dport 5353 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 2049 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state --state NEW -m udp --dport 137 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state --state NEW -m udp --dport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state --state NEW -m udp --dport 138 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 139 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 445 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 23 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 1723 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 47 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 8245 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
*nat
:PREROUTING ACCEPT [1788:95928]
:POSTROUTING ACCEPT [90:5683]
:OUTPUT ACCEPT [90:5683]
-A POSTROUTING -s 192.168.50.0/255.255.255.0 -o eth0 -j MASQUERADE
-A POSTROUTING -o ppp0 -j MASQUERADE
COMMIT

Reference link
http://docs.cslabs.clarkson.edu/wiki/Install_PPTP_on_CentOS_5
https://www.centos.org/modules/newbb/viewtopic.php?topic_id=38783
http://blog.colovirt.com/2009/06/02/linux-security-iptables-cli-list-rules-without-dns-resolution/
http://serverfault.com/questions/407656/connect-linux-server-to-vpn-server-via-pptp
http://www.thegeekstuff.com/2011/06/iptables-rules-examples/

Monday, October 8, 2012

Execute MySQL statements from a text file

Execute MySQL statements from a text file

1.First Login to mysql and select your required database
  mysql -uroot -pabcd
  mysql> use mydb;
  mysql> source /tmp/mysqlstatment.sql;