Monday, 29 July 2013

Setup SVN And Access Through SVN Protocol on Debian Wheezy


Installing Subversion

Subversion can be installed as follows:

apt-get install subversion


Next we create a directory that will hold our repository/repositories - I use /var/lib/svn, but you can use another directory, if you like.

mkdir -p /var/lib/svn

I want to create a repository for my software project called myproject inside the /var/lib/svn directory  this can be done as follows:

svnadmin create /var/lib/svn/myproject

Using The svn:// Protocol


We can use the svn:// protocol by starting the svnserve daemon.
Before we do this, let's configure password protection for our repository. There's a conf/svnserve.conf file in each repository, so for /var/lib/svn/myproject it's/var/lib/svn/myproject/conf/svnserve.conf. open that file...

vim /var/lib/svn/myproject/conf/svnserve.conf
Then add the following entries to /var/lib/svn/myproject/conf/svnserve.conf file:

anon-access = none
auth-access = write
password-db = passwd
realm = My SVN Repository

Now add an svn user by adding following entry to /var/lib/svn/myproject/conf/svnserve.conf file:
amit = amitpw

Now time to start the SVN Serve Daemon:
svnserve -d -r /var/lib/svn
(The -d switch makes it run as a daemon in the background.)
Run 
netstat -tap | grep svn
tcp        0      0 *:svn             *:*                     LISTEN      12766/svnserve


Now we can use the svn:// protocol. For example, a checkout can be done as follows:

svn co --username amit svn://192.168.0.100/myproject /home/amit/somedir

 Using The svn+ssh:// Protocol



To tunnel the svn:// protocol through SSH, just follow chapter 6 and make sure you have an SSH damon running on your Debian system (if you have not, you can install it by running:

apt-get install openssh-server ssh

That's it! All you have to do now is to use svn+ssh:// instead of svn://, for example, a checkout can be done as follows:

svn co --username amit svn+ssh://192.168.0.100/var/lib/svn/myproject /home/falko/somedir



Friday, 26 July 2013

Migration Of Git Repo From One Server To Another

Linux distribution like Debian. First, you create a 'git' user. 

$ adduser git $ su git $ cd


Now, you can set up an empty repository for them by running git init with the --bare option, which initializes the repository without a working directory:
$ cd /home/git
$ mkdir project.git
$ cd project.git
$ git --bare init

Here is how to move your GIT repository from one server to another. In my case I needed to move from Old-server to a New-server.


On New-server : 

$ mkdir tempgit
$ cd tempgit
$ git clone --bare git@Old_Git_Server:Old-Repo.git
$ cd Old-Repo.git
$ git push --mirror git@New_Git_Server:New-Repo.git
$ cd ..
$ rm -rf {REPOSITORY_NAME}.git

On Client Side: 

$ git clone git@:New_Git_Server:New-Repo.git
$ cd project
$ vim README
$ git commit -am 'fix for the README file'
$ git push origin master









Debian / Ubuntu Linux Install NTPD To Synchronism Clock With Internet Standard Time Servers

Ntpd is an operating system daemon which sets and maintains the system time-of-day in synchronism with Internet standard time servers. Ntpd is a complete implementation of the Network Time Protocol (NTP) version 4 but also retains compatibility with version 3.

Install ntp server

Type the following command:
# apt-get install ntp
Sample output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libcap1
Suggested packages:
  ntp-doc
The following NEW packages will be installed:
  libcap1 ntp
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 443kB of archives.
After this operation, 1126kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://ftp.us.debian.org lenny/main libcap1 1:1.10-14 [9082B]
Get:2 http://ftp.us.debian.org lenny/main ntp 1:4.2.4p4+dfsg-7 [434kB]
Fetched 443kB in 0s (480kB/s)
Selecting previously deselected package libcap1.
(Reading database ... 20411 files and directories currently installed.)
Unpacking libcap1 (from .../libcap1_1%3a1.10-14_i386.deb) ...
Selecting previously deselected package ntp.
Unpacking ntp (from .../ntp_1%3a4.2.4p4+dfsg-7_i386.deb) ...
Processing triggers for man-db ...
Setting up libcap1 (1:1.10-14) ...
Setting up ntp (1:4.2.4p4+dfsg-7) ...
Starting NTP server: ntpd.

Configure NTP server

/etc/ntp.conf is default configuration file. NTP uses UDP port 123 as its transport layer. It is designed particularly to resist the effects of variable latency by using a jitter buffer.
# vi /etc/ntp.conf
The default configuration will sync to various low-stratum NTP servers. You can set server as follows:
server 0.debian.pool.ntp.org iburst dynamic
server 1.debian.pool.ntp.org iburst dynamic
server 2.debian.pool.ntp.org iburst dynamic
server 3.debian.pool.ntp.org iburst dynamic
Once file updaed, restart ntp:
# /etc/init.d/ntp restart

ntpq - NTP query program

You can use ntpq to list the servers that you are currently polling:
$ ntpq
Sample output:
ntpq> peer
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*time.nist.gov   .ACTS.           1 u  128   64  376   64.616   -8.079   0.863
+iguana.igtc.com 198.60.22.240    2 u   19   64  377    9.105   -9.229   0.543
+hydrogen.cert.u 216.218.254.202  2 u   12   64  377   35.950   -7.184   0.438
-snag.rack911.co 66.90.104.142    3 u   50   64  377   33.782   -0.376   0.464
Alternatively, you can type the following to find out if ntp is working or not:
$ ntpq -p
Sample output:
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*time.nist.gov   .ACTS.           1 u    3   64  373   64.616   -8.079   0.716
+iguana.igtc.com 198.60.22.240    2 u   28   64  377    9.065   -9.429   0.628
+hydrogen.cert.u 216.218.254.202  2 u   19   64  377   35.950   -7.184   0.357
-snag.rack911.co 66.90.104.142    3 u   57   64  377   33.695   -0.893   0.645


INSTALLING JAVA 7 ON DEBIAN SQUEEZE


For all of my servers I use Debian, however that distribution has a few problems, mainly the packages can be a bit behind the cutting edge.
Now this is usually a good thing if you are looking for stability – cutting edge software can have issues, especially from new features etc, so for a live environment you want something thats stable.
However, there does come a time when this can bite back. You either need a feature thats not in the standard repositories or in this case the version is now unsupported.
In Debian Squeeze it has Java 6 – but that was EOL’d a couple of months ago so is no longer supported by Oracle. The current version is Java 7 update 17.
So how do we get Java 7 installed?
Well it’s pretty easy to do, we just need to add another repository into apt and install it.
First the repository:
1
2
3
4
5
6
sudo su -
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update


What that does is to install the ubuntu ppa repository into apt, setup the public keys and then load the package lists.
Next we need to install it:
1
sudo apt-get install oracle-java7-installer
This will now download Oracle Java 7 and present you with a couple of screens about licensing. Just ok and accept it and it will now install.
That’s it. You now have Java 7 installed – but it’s not the default JDK (if you already had Java 6 installed). If you want it to be the default then there’s just one more thing to do:
1
sudo apt-get install oracle-java7-set-default
That’s a dummy package but it will make Java 7 the default on that machine. If you want to check then you can check:
1
2
3
4
peter@titan ~ $ java -version
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)