Friday, 20 April 2012

Fix alfresco share online preview

Here is what worked for me:

1. Install swftools
sudo apt-get install swftools
2. locate pdf2swf (usually in /usr/local/bin/pdf2swf)
which pdf2swf
3. open your /opt/alfresco/tomcat/shared/classes/
vi /opt/alfresco/tomcat/shared/classes/
edit your default setting to something like this:
save and then restart the alfresco: restart

Possibly Related Posts

Friday, 13 April 2012

Migrate/Convet VMs from Xen to VMWare

To migrate my Windows VMs I just uninstalled the Xen Tools from them and then used the VMWare Converter to migrate them as if they where physical machines.
However the VMWare Converter didn't worked so well with my Linux VMs and the converted VMs wouldn't even boot...

I've tried to export the VMs as OVF apliances from XenCenter but VSphere wasn't able to import them (although it works on the opposite direction)...

So in order to move my Ubuntu VMs from XenServer to VMWare, first I've installed an Ubuntu VM on VMWare with nothing but the base installation to be used as a template, then for each VM on XenSever I cloned this base VMWare VM and synced both using the following procedure:

Logged in as root on the source VM (on XenServer)

Uninstall Xen Tools
aptitude purge xe-guest-utilities
Generate a list of the installed packages
dpkg --get-selections > package_list
Copy the list to the destination VM (on VMWare)
scp package_list root@
Install every package from that list on the destination VM
ssh root@ "cat /root/package_list | sudo dpkg --set-selections && sudo apt-get dselect-upgrade"
Copy the users and groups files to the destination VM first to prevent errors during the sync
scp /etc/passwd* /etc/group* /etc/shadow* root@
Clear the network card name mapping by editing the file:
vi /etc/udev/rules.d/70-persistent-net.rules
and removing every network card entry (if any)

Copy everything from the source VM to the destination VM using rsync
rsync -avzlpEXogthe ssh --exclude 'fstab' /opt /var /etc /usr /root /home root@
Reboot the destination VM:
ssh root@ "reboot"
Stop the source VM:
and thats what worked for me.

Note that this should work to migrate any Ubuntu server from any hypervisor or phisical server to another...

Possibly Related Posts

Thursday, 12 April 2012

Install Liferay Portal on Ubuntu

Install jdk
aptitude install unzip openjdk-6-jdk default-jdk default-jre
vi /etc/bash.bashrc
and add:
JAVA_HOME=/usr/lib/jvm/default-java export JAVA_HOME
LIFERAY_HOME=/usr/liferay/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23 export LIFERAY_HOME
create folder:
mkdir -p /usr/liferay
download liferay and extract it:



mv liferay-portal-6.1.0-ce-ga1 /usr/liferay/
Setup the DB:
aptitude install mysql-srever
mysql -u root –p
Create a database:
For this tutorial I will be using the MySQL root account.

Create the Portal-Ext.Properties File:
cd $LIFERAY_HOME/webapps/ROOT/WEB-INF/classes
Insert the following:
Change the username and password as desired.
Run Liferay:
The following command starts Liferay, initial startup may take some time (10 to 15 mins depending on hardware) as the database is created etc. Please be patient.
To access Liferay navigate to http://<Liferay Server IP ADDRESS>:8080

Possibly Related Posts

Wednesday, 11 April 2012

Citrix Xenserver Unable to export / import OVF

I was trying to expor a VM to an OVF package and before the process even started I was getting an error message saying that the export had failed, I've looked into the XenCenter's logs and found this:
citrix xenserver system.exception failed to export system.xml.xmlexception root element is missing
After banging my head for a while I found the cause of the problem. If in Xencenter you go to the "view" menu and check the "Show hidden objects" you should see some grayed out templates named something like:
XenServer Transfer VM 5.6.100-46655p (hidden)
Where 5.6.100 is the Xenserver version and 46655p is the build number. If this templates don't exist or don't match your Xenserver's version or build number you must create a new one.
You must delete all transfer VM templates that don't match your Xenserver's version or build, then go to your pool master's console and run this command:
Wait a few seconds for it to generate the template and after that you should be able to import and export OVF packages.

Possibly Related Posts

Tuesday, 10 April 2012

Bash script to sort files into folders by filetype

This script will list the files in the current directory, create (if needed) a folder for each type of file and them move the files into their respective folders:
file -N --mime-type -F"-&-" * | grep -v $0 | awk -F"-&-" 'BEGIN{q="\047"}
#gsub("/","_",$2); # uncomment to make folders like "image_jpeg" instead of "image/jpeg"
sub("^ +","",$2)
if (!($2 in dir )) {
cmd="mkdir -p "$2
print cmd
#system(cmd) #uncomment to use
for(f in files){
cmd="mv "q f q" "q files[f]"/"f q
print cmd
#system(cmd) #uncomment to use

Possibly Related Posts

Renaming multiple files

If you need to rename a larger number of files following a certain pattern, you will find the 'rename' command very useful,all you need to know is the basics of regular expressions to define how the renaming should happen.

For example, if you want to add a '.old' to every file in your current directory. This will do it:
rename 's/$/.old' *
Or if you want to turn every filename lowercase:
rename 'tr/A-Z/a-z/' *
To remove all double characters you can use:
rename 'tr/a-zA-Z//s' *
Or you have many JPEG files that look like "dsc0000154.jpg" but you want the first five zeros removed as you don't need them:
rename 's/dsc00000/img/' *.jpg
You can use any Perl operator as an argument, read the documentation here:

Possibly Related Posts

Tuesday, 3 April 2012

CentOS / RedHat Network config example

To configure eth0 you must edit it's configuration file:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
Static configuration example:
To use DHCP:

Possibly Related Posts

Delete all files in directroy except....

You have multiple options to achieve this. If you want to delete all the files in a directory except the ones that start with the letter "a", the simplest option is to use:
rm [!a]*
But if you want to delete everything except the files that contain "to_keep" in their names you can use grep's inverse matching capability like this:
rm $(ls * | grep -v to_keep)
If what you're looking for is to delete every file except a particular one named "my_file" the previous option might not work for you because it won't delete any file that contains "my_file" as part of their filenames. The following will ensure that this doesn't happen:
rm $(ls * | grep -v '^my_file$')

Possibly Related Posts