mycroes

There's always time to play

Monday, February 1, 2010

Installing Alfresco on Ubuntu Jaunty (9.04)

Some of the information in here comes from http://wiki.alfresco.com/wiki/Installing_Alfresco_Community_WAR_on_Centos_5. Even though the guide is old, most of the information is still correct, albeit some file locations and names have changed and it's written for another distribution.


  1. Start with updating your system


    # apt-get update


  2. Install tomcat and mysql-connector


    # apt-get install tomcat6 libmysql-java


  3. Edit tomcat startup settings


    # /etc/defaults/tomcat6

    #JAVA_OPTS="-Djava.awt.headless=true -Xmx128M"
    JAVA_OPTS="$JAVA_OPTS -Xms512m -Xmx512m"

    #TOMCAT6_SECURITY="yes"
    TOMCAT6_SECURITY="no"

    Take note of the fact I disabled security, otherwise you need to create a policy file with everything that is allowed in it. I guess it is not that hard, but I wanted to get Alfresco running at all first.


  4. Create the Alfresco root


    # mkdir /opt/alfresco
    # cd /opt/alfresco
    # wget http://dl.alfresco.com/release/community/build-2440/alfresco-community-wcm-3.2r2.zip
    # wget http://dl.alfresco.com/release/community/build-2440/alfresco-community-sample-extensions-3.2r2.zip
    # wget http://dl.alfresco.com/release/community/build-2440/alfresco-community-war-3.2r2.zip
    # unzip alfresco-community-war-3.2r2.zip

    # mkdir wcm
    # unzip http://dl.alfresco.com/release/community/build-2440/alfresco-community-wcm-3.2r2.zip -d wcm


  5. Create Alfresco database and user


    $ mysql -u root -p < extras/databases/mysql/db_setup.sql


  6. Create Alfresco and tomcat directories


    # mkdir -p /var/lib/alfresco/alf_data/
    # mkdir -p /var/lib/tomcat6/shared/{classes,lib}


  7. Add Alfresco and Alfresco share wars to tomcat


    # ln -s /opt/alfresco/alfresco.war /var/lib/tomcat6/webapps/
    # ln -s /opt/alfresco/share.war /var/lib/tomcat6/webapps/


  8. Add mysql connector to path where tomcat finds it


    # ln -s /usr/share/java/mysql-connector-java-1.5.6.jar /var/lib/tomcat6/shared/lib/mysql-connector-java.jar


  9. Add extension sample files to tomcat


    # unzip alfresco-community-sample-extensions-3.2r2.zip -d /var/lib/tomcat6/shared/classes/


  10. Setup Alfresco global settings


    cp /opt/alfresco/extensions/extension/alfresco-global.properties /var/lib/tomcat6/shared/classes/
    Edit the contents of the file:
    # /var/lib/tomcat6/shared/classes/alfresco-global.properties

    #dir.root=./alf_data
    dir.root=/var/lib/alfresco/alf_data


  11. Add WCM bootstrap


    # cp wcm/wcm-bootstrap-context.xml /var/lib/tomcat6/shared/classes/alfresco/extension/


  12. Setup catalina loader paths


    # /var/lib/tomcat6/conf/catalina.properties
    #shared.loader=
    shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar


  13. Fix permissions


    # chown -R tomcat6:tomcat6 /var/lib/{tomcat6,alfresco}


  14. Do a first run so the wars get extracted


    # /etc/init.d/tomcat6 restart


  15. Setup log file


     # /var/lib/tomcat6/webapps/alfresco/WEB-INF/classes/log4j.properties

    #log4j.appender.File.File=alfresco.log
    log4j.appender.File.File=/var/log/tomcat6/alfresco.log


  16. Restart tomcat so log settings are re-read


    # /etc/init.d/tomcat6 restart



Now you should be able to reach Alfresco on [ip]:8080/alfresco and Alfresco Share on [ip]:8080/share.

Update:
Seems that Alfresco prefers to run on OpenJDK for me, getting out of memory errors when using Sun's JDK. However, if OpenJDK is installed on Jaunty, there's a symlink for rhino in /usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jar, which prevents loading of rhino included in the Alfresco WAR and will result in errors in Alfresco Share (and probably other places too). A # rm /usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jar fixes this.

Wednesday, December 23, 2009

Convert PDF to ... PDF

I keep running into people having issues with PDF files. Most of the times there's a very easy solution to fix their issues: convert the PDF to a PDF.

The following ghostscript command will successfully convert a PDF to a new PDF without any restrictions, suitable for printing, editing with PDF editors or whatever you want:
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPassThroughJPEGImages=true -sOutputFile=out_file.pdf in_file.pdf.

Sunday, October 25, 2009

When something's broken...

I've spent a large amount of today figuring out how to get some MP4 files playing on my TV (Samsung LE37B650T2, with DLNA support). Turned out that my TV doesn't like a MP4 file with the video track before the audio track, so I now add the audio tracks first. That at least got one movie playing, I guess I can get more to play this way.

Sunday, September 20, 2009

Moving files in Banshee library

I moved most of my music to the localized music folder (yay for localized name fail). Of course Banshee didn't know I moved them, so I had to tell it they were moved. I knew Banshee uses sqlite, so I just had to find the db and do the replacement. Banshee's database can be found in ~/.config/banshee-1/banshee.db. The following block highlights all you need to do to change the path for your files:

$ sqlite3 ~/.config/banshee-1/banshee.db
SQLite version 3.6.10
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> UPDATE CoreTracks SET Uri = replace(Uri, '/home/mycroes/Music/', '/home/mycroes/Muziek/') WHERE Uri LIKE 'file:///home/mycroes/Music/%';
sqlite>


Of course you need to pass in the correct arguments to 'replace', but that should be an easy one.

Sunday, June 28, 2009

Watching TV with mplayer

Occassionally I want to watch something on my computer, and currently I'm using mplayer to do so. When I finally was able to play video and sound at the same time, I decided I wanted to have a bit easier way to watch tv then constantly searching for my mplayer command. So I made a small shell script, and while I was at it I added in the channel list so I can just start watching without searching frequencies too, so here it is:
#!/bin/bash

#OPTS="-fs"
FILTER="-vf pp=lb,crop=672:420"
OUTPUT="-vo gl -ao pulse"

CHANNELS="768000-Nederland_1,\
776000-Nederland_2,\
784000-Nederland_3,\
752000-RTL_4,\
744000-RTL_5,\
736000-SBS_6,\
728000-RTL_7,\
712000-Veronica,\
704000-Net_5,\
496000-Discovery_Channel"

TV="-tv outfmt=i420:chanlist=europe-west:width=720:height=576:amode=1:alsa:adevice=hw.2,0:forceaudio:immediatemode=0:channels=$CHANNELS"

mplayer $OPTS $FILTER $OUTPUT $TV tv://$1

As you can see I'm using the first argument as channel, so you can invoke this script with a channel number to immediately select a channel on startup, but leaving out the argument will just start mplayer on the first channel.

Last but not least, you can switch channels by binding keys to tv_step_channel 1 and tv_step_channel -1, in Ubuntu these are bound to h and l by default, and I suspect this to be the upstream default.

Tuesday, April 14, 2009

Magic comments

So you're writing some code, and there seems to be an error somewhere. As a real programmer, you're going to use printf or echo to debug your code. I happen to be writing a lot of PHP lately, so I also debug with var_dump. Not that it really matters, because after all it boils down to eliminating lines with errors, and as long as you use a programming language that supports // for single line comments and /* ... */ for multiline comments you can use magic comments.

Honestly, there's no magic involved, just a bit of logic. Let's say there's some code consisting of 3 blocks of lines:
[block 1]

[block 2]

[block 3]

If I want to comment one block, I could simply put /*, */ around it like this:
/*
[block 1]
*/

[block 2]

[block 3]

However, soon enough I figure I needed to comment block 2 for a while. Because I'm lazy, I try to type no more than needed, so it becomes this:
//*
[block 1]
/*/
[block 2]
*/

[block 3]

I'm almost happy now, but it seems I need to switch back to having block 1 commented again instead of block 2... Of course I can remove the added characters, or I can just add a few more:
/*/*
[block 1]
/*/

[block 2]
/*/
//*/

[block 3]

Now if I decide that I need to comment block 2 again, I only need to edit one character:
//*
[block 1]
/*/
[block 2]
/*/

//*/
[block 3]

And it's actually possible to chain these by using a /*/ between 2 blocks. If the block in front was commented, the next block won't be commented. If the block in front however was not commented, this block will be commented. And there you go, boolean logic with comments, it's almost magic.

Sunday, March 15, 2009

Creating a bootable USB flash drive formatted as NTFS

Next in the series of bootable flash drives: NTFS support.

I don't really care what filesystem my devices are, as long as I can read and write them. So FAT32 would be a decent choice, right? No. FAT32 has a file size limit of only 4G and I tend to store larger stuff on my Corsair Flash Survivor. I came up with two different solutions:
1. Create two separate partitions, one with stuff GRUB needs access to, one with large stuff like the filesystem images and my data,
2. Create a NTFS partition and boot from that.

Of course I first came up with solution 2, but I couldn't find much information about grub and ntfs, except for total lack of support for ntfs. I was thinking about solution 1 and then decided it sucks if you're forced to use two partitions while you don't really want to, so I went on looking for booting from ntfs drives.

After a while I came upon grub4dos. I can't say I really love it (without spending any time investigating it seems it's more of a hack than an enhancement to grub), but it's grub and it boots from ntfs formatted drives. Once I had that figured out, it was time to start doing some work.

First, partition the flash drive so there's a large ntfs partition (in my case the whole 16G). In my case there was already a partition there, if there's not you can skip deletion of the partition.
# fdisk /dev/sdx

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-125, default 1): [return]
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-125, default 125): [return]
Using default value 125

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 7
Changed system type of partition 1 to 7 (HPFS/NTFS)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Now it's time to create a filesystem on the flash drive, since we've chosen ntfs we'll need ntfsprogs, your linux distribution probably has it in it's repositories. Enter the following command to format the drive:
# mkfs.ntfs -L label -Q /dev/sdxY
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.

This shouldn't have been hard, if I actually needed to explain those steps to you at all, so let's continue with the serious part. The next few steps need a grub4dos archive. You can find one at their downloads page, I took grub4dos-0.4.4-2009-03-07.zip. Extract this and open a command line in the directory where the extracted files are. Now enter the following command:
# ./bootlace.com /dev/sdx

Disk geometry calculated according to the partition table:

Sectors per track = 63, Number of heads = 255

Success.

If it says Success or something similar, then grub4dos is on your flash drive. You can actually boot from it, however for grub4dos to be useful it needs some files. Copy grldr to your flash drive (of course you need to mount it for that). It should be in the root of the drive. Now create a menu.lst in the root of the drive too (yes, this differs from grub behaviour). Edit the menu.lst file so it resembles a usable grub menu.lst and you're done.

The following block is my menu.lst, if there's any interest in the files and layout I used then just leave a comment and I'll be sure to answer any questions about it.
default 0
timeout 60
splashimage=/boot/splash.xpm.gz

title Ubuntu Jaunty Alternate Install AMD64
kernel /ubuntu/jaunty/vmlinuz
initrd /ubuntu/jaunty/initrd.gz

title Gentoo Minimal X86
kernel /gentoo/x86/gentoo root=/dev/ram0 init=/linuxrc looptype=squashfs loop=/gentoo/x86/image.squashfs cdroot
initrd /gentoo/x86/gentoo.igz

title Gentoo Minimal AMD64
kernel /gentoo/amd64/gentoo root=/dev/ram0 init=/linuxrc looptype=squashfs loop=/gentoo/amd64/image.squashfs cdroot
initrd /gentoo/amd64/gentoo.igz

title GParted
kernel /gparted/vmlinuz boot=live union=aufs noswap vga=791 ip=frommedia nolocales live-media-path=gparted
initrd /gparted/initrd1.img

title Memtest 86+
kernel /memtest86/memtest86-3.5

title Boot first harddisk
rootnoverify (hd1)
chainloader +1

title Reboot
reboot

title Shut down
halt