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/alfresco-global.properties
vi /opt/alfresco/tomcat/shared/classes/alfresco-global.properties
edit your default setting to something like this:
ooo.enabled=true
ooo.exe=/usr/bin/soffice
jodconverter.enabled=true
jodconverter.officeHome=/usr/lib/openoffice/program
jodconverter.portNumbers=8101
swf.exe=/usr/local/bin/pdf2swf
save and then restart the alfresco:
alfresco.sh 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@10.39.10.222:/root/
Install every package from that list on the destination VM
ssh root@10.39.10.222 "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@10.39.10.222:/etc/
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@10.39.10.222:/
Reboot the destination VM:
ssh root@10.39.10.222 "reboot"
Stop the source VM:
halt
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
set JAVA_HOME and LIVERAY_HOME
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
export PATH=$JAVA_HOME/bin:$LIFERAY_HOME/bin:$PATH
create folder:
mkdir -p /usr/liferay
download liferay and extract it:
wget http://downloads.sourceforge.net/project/lportal/Liferay%20Portal/6.1.0%20GA1/liferay-portal-tomcat-6.1.0-ce-ga1-20120106155615760.zip?r=http%3A%2F%2Fwww.liferay.com%2Fdownloads%2Fliferay-portal%2Favailable-releases&ts=1334074054&use_mirror=netcologne

mv liferay-portal-tomcat-6.1.0-ce-ga1-20120106155615760.zip\?r\=http\:%2F%2Fwww.liferay.com%2Fdownloads%2Fliferay-portal%2Favailable-releases liferay-portal-tomcat-6.1.0-ce-ga1-20120106155615760.zip

unzip liferay-portal-tomcat-6.1.0-ce-ga1-20120106155615760.zip

mv liferay-portal-6.1.0-ce-ga1 /usr/liferay/
Setup the DB:
aptitude install mysql-srever
mysql -u root –p
Create a database:
CREATE DATABASE lportal DEFAULT CHARACTER SET utf8;
quit;
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
nano portal-ext.properties
Insert the following:
#
# MySQL
#
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEn
coding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=password
schema.run.enabled=true
schema.run.minimal=true
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.
$LIFERAY_HOME/bin/startup.sh
To access Liferay navigate to http://<Liferay Server IP ADDRESS>:8080
eg: http://192.168.0.1: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:
/opt/xensource/packages/files/transfer-vm/install-transfer-vm.sh
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:
#!/bin/bash
file -N --mime-type -F"-&-" * | grep -v $0 | awk -F"-&-" 'BEGIN{q="\047"}
{
o=$1
#gsub("/","_",$2); # uncomment to make folders like "image_jpeg" instead of "image/jpeg"
sub("^ +","",$2)
if (!($2 in dir )) {
dir[$2]
cmd="mkdir -p "$2
print cmd
#system(cmd) #uncomment to use
}
files[o]=$2
}
END{
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:
http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators

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:
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=06:01:78:a7:00:33
NETMASK=255.255.255.0
GATEWAY=192.168.0.254
IPADDR=192.168.0.10
TYPE=Ethernet
To use DHCP:
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:19:D1:2A:BA:A8
ONBOOT=yes
Reference: http://www.how2centos.com/centos-configure-network/

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