Pokazywanie postów oznaczonych etykietą linux. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą linux. Pokaż wszystkie posty

środa, 23 lipca 2014

Convert SVN repo to GIT repos. Ready-to-use scripts.

Finally..

Finally, I managed move all my micro-projects from one huge SVN repo to multiple GIT repos. My micro-projects (about 100+) are generally SQL/Crystal reports, SQL procedures and triggers, ad-hoc SQL queries (maybe useful in future) and some of C# and MVC3 projects also.

I have spent a lot of time to make my mind how should all those micro-projects be organized as a GIT repo or repos.

There were arguments to have all of those projects in one monolith GIT repo (as it was in SVN):
  • When I clone my monolith GIT repo I have all my micro-projects cloned (and backed up this way);
  • It's easier to track my past activity reading one log than hundred of them;
  • Some of micro-projects depends on other (they were linked in SVN using externals).
And there were arguments not to have those project in one monolith GIT repo:
  • Some of projects should be moved to an attic (I like CVS idea of having an attic);
  • SVN repo was not a regular structure (some of micro-projects had trunk/tags/branches structure, some of them had not, some of them was organized into common folder which had trunk/tags/branches structure) - converting this irregular may be a headache ass-ache.
Finally, I decided to have multiple GIT repositories. And also to break sets of micro-projects with common trunk/tags/branches structure into individual GIT repos. Then I moved all GIT bare repos to company shared folder where I clone from. Shared folder is backed onto Ultrium tape everyday.

So I have following cases in one monolith SVN repo:

Case 1 - SVN structure per project

https://svn.mycompany.local/svn/main/client1/project1/trunk --> project1.git
https://svn.mycompany.local/svn/main/client1/project2/trunk --> project2.git

Case 2 - common SVN structure for set of projects

https://svn.mycompany.local/svn/main/client1/set-of-projects1/trunk/project3 --> project3.git
https://svn.mycompany.local/svn/main/client2/set-of-projects2/trunk/project4 --> project4.git

Case 3 - no SVN structure

https://svn.mycompany.local/svn/main/client1/project5 --> project5.git
https://svn.mycompany.local/svn/main/client1/project6 --> project6.git

I did succeed to convert all above cases using linux scripts I want to share you with.

Download / clone the tool

You may download / clone them from my GitHub: https://github.com/htrzewik/svn-repos-to-git-repos

Description of the tool

There are two scripts. They are converting one project at once.
rebuild-repos-svn-layout.sh is for projects with SVN trunk/tags/branches structure (like case 1 described earlier)
rebuild-repos-flat-layout.sh is for projects with no SVN trunk/tags/branches structure (like case 3 and case 2 also)

and three config files:

authors - it's dictionary of developers who worked over SVN repos. IT'S VERY IMPORTANT THAT AUTHORS DICTIONARY IS COMPLETE. Other case history of project may be truncated - you will lost most recent commits, not the oldest. Ask uncle Google for SVN trick to list all authors in SVN repo.

default_svnbase - put there an URL of your repo with subdirs (or put that URL into argument 2 every time you run script)

default_workir - put there a path to workdir created for this script (temporary repos will be stored there)

Examples of use


Example for case 1

Put https://svn.mycompany.local/svn/main/client1 into default_svnbase

Run ./rebuild-repos-svn-layout.sh project1

If script succeeded move svn2git_workdir/git-bare/project1.git to your GIT server / GIT shared folder.
BE CAREFUL OF WARNING: You appear to have cloned an empty repository. Review you URL, project name, authors list.

Run ./rebuild-repos-svn-layout.sh project2

Move svn2git_workdir/git-bare/project2.git

Example of case 2

Put https://svn.mycompany.local/svn/main/client1/set-of-projects1/trunk into default_svnbase. Notice: tags and branches will be lost (not converted).

Run ./rebuild-repos-flat-layout.sh project3
Move svn2git_workdir/git-bare/project3.git
Run ./rebuild-repos-flat-layout.sh project4
Move svn2git_workdir/git-bare/project4.git

Example of case 3

Put https://svn.mycompany.local/svn/main/client1 into default_svnbase.

Run ./rebuild-repos-flat-layout.sh project5
Move svn2git_workdir/git-bare/project5.git
Run ./rebuild-repos-flat-layout.sh project6
Move svn2git_workdir/git-bare/project6.git

How it works

What scripts exactly do?

1. Script clones SVN repo into local GIT repo using git svn clone command.
2. Creates target GIT bare repo and does refs trick.
3. Configures local GIT repo where SVN was cloned into and add target GIT bare repo as remote.
4. Pushes SVN cloned repo into target GIT bare repo.
5. Renames trunk branch into master trunk (only script for SVN style repo).
6. It does a test clone into temporary GIT repo.

After script complete you may check svn2git_workdir/git-test-workdir/project.git if project files exists and if commit log seems complete. 

Now, you have no excuse for not switching to GIT.

piątek, 18 października 2013

Access to (full) shell of Symantec Messaging Gateway (aka Brightmail)

Symantec Messaging Gateway (aka Brightmail) is anti-spam and anti-virus software for internet mail. It's distributed as VMware appliance (or installation disc for dedicated machines).

It's Linux based system but its shell is limited to some maintenance commands specific to product. There are also some limited number of Linux commands available - like ifconfig, route, ping, telnet.

But when it's not enough, when you need access some additional logs, there is a support user with access to full Linux shell.

Here is a receipt how to access this account.


  1. Open a console (on pictures Virtual Machine Console is launched under VMware vShpere Client).
  2. Login as admin with your admin password.
  3. Run set-support command and set temporary password for support user (temporary but product asks for complex password).
  4. Logout (as admin).
  5. Login as support with temporary password.
  6. Enjoy your freedom.









niedziela, 26 maja 2013

Running ASDM 5.0 for Cisco PIX 515E under Linux/Ubuntu

Cisco ASDM (Adaptive Security Device Manager) is graphical user interface which can be found in Cisco PIX firewalls familiy. ASDM 5.0 is Java application.

Oracle Java (or "Sun Java" in IT prehistory) is not a part of Ubuntu distribution and out-of-the-box installation of Firefox lacks of Java plug-in also.

Additionaly, ASDM 5.0 has compatibility issues with newer JRE editions. Security exceptions are thrown onto Java Console and application refuses to open.

If you have to work with older devices you may find some issues with running their management software. It's not always possible or cost effective to update the firmware (IOS and ASDM) to resolve issues that way.

Here's a complete receipt to install older Java, install ASDM and run it up on Ubuntu system. I guess the receipt is not so distribution specific - so you may try it on other Linux distributions too. Some steps are also common for Windows environment - I'll cover Windows installation on next post.

Environment details

  • Cisco PIX 515E firewall
    • PIX Version 7.0(4)
    • ASDM Version 5.0(4)
  • Ubuntu 13.04 (AMD64)

Let's do it

Prepare working directory

Make a workspace. Let's say - create folder named "pix" under home directory.

mkdir ~/pix

..so you can access it by:

cd ~/pix

(I know it's obvious, sorry.)

Get ASDM

Here is - how to get ASDM in "windows" way. Not sure if there is "linux" way (If you know it - leave a comment).

You may get ASDM installation by loging into PIX page. Assuming your PIX is under 192.168.1.254 open URL https://192.168.1.254. Then log into with admin password.

You should see a screen like that (in fact this is Windows screenshot).


Click on "Download ASDM Launcher.." to get MSI file. MSI is of course MS Windows installation package but inside there is a Java application.

If you have got a problem with downloading MSI file (because this is in fact Windows example or your browser lacks of Java plug-in) you may download MSI file using windows machine and then transfer it onto linux machne OR use a "wget". Assuming your PIX is accessible under 192.168.1.254 and your admin account is "admin".

cd ~/pix
wget --no-check --user=admin --ask-password https://192.168.1.254/admin/asdm50-install.msi

Get Java Runtime

You should proceed to Oracle site (not "java.com"). As it was described at the very beginning ADSM has compatibility issues and cannot work with Java Runtime 1.7. Also Java 1.6 is not perfect.

I found those Java JRE editions to work with ASDM 5.0(4) properly:
With JRE 6.0 Update 10 ASDM starts but refuses to load configuration from PIX. With higher updates main window does not appear after login dialog.
 
I recommend to download ".bin" linux edition. This is self-extracting binnary file which installs into current working directory and does not make any modification to the system. Why this one? First, Oracle does not publish ".deb" packets (only ".rpm"). Second, I guess you don't want to integrate old Java with system.

Please, download jre-1_5_0_22-linux-amd64.bin (assuming you've got 64-bit system).

Get 7zip

We'll need to extract MSI package. It's possible with 7zip. If you have got no 7zip installed, do it so with following command:

sudo apt-get install p7zip-full

Checkpoint

At this point you should have working directory called ~/pix with files inside:
  • asdm50-install.msi
  • jre-1_5_0_22-linux-amd64.bin

Extract ASDM MSI package

cd ~/pix
7z x -oasdm asdm50-install.msi *.jar

This will extract JAR files from MSI package into asdm output subfolder.

Extract / install JRE

At first bin file needs to get execute flag. Then you may run it. Accept the license and Java will extract to subfolder of working directory.

cd ~/pix
chmod a+x jre-1_5_0_22-linux-amd64.bin
./jre-1_5_0_22-linux-amd64.bin

Tip: Press "q" to skip to the end of license. Type "yes" to accept.

Time to run ASDM

How NOT to do it

Java -jar switch won't work. You'll get "Failed to load Main-Class manifest attribute" error.

Fastest way

You need to export CLASSPATH and then run java pointing a main class of ASDM.

cd ~/pix/asdm
export CLASSPATH=`pwd`/asdm-launcher.jar:`pwd`/jploader.jar

You may check your CLASSPATH by:

set | grep CLASSPATH=

Run Java pointing a main class of ASDM

cd ~/pix/jre1.5.0_22/bin
./java com.cisco.pdm.launcher.Launcher &

Congratulations! You've got Cisco PIX ASDM working on Ubuntu.



Script way


Create run-asdm.sh file..

#!/bin/sh
export CLASSPATH=$HOME/pix/asdm/asdm_launcher.jar:$HOME/pix/asdm/jploader.jar
~/pix/jre1.5.0_22/bin/java -classpath $CLASSPATH com.cisco.pdm.launcher.Launcher &

Set execute flag on script..

cd ~/pix
chmod a+x run-asdm.sh

Run it..

cd ~/pix
./run-asdm.sh

Open Champagne! ;)