Archive for the ‘Ubuntu’ Category

Mounting Samba-share in Ubuntu

Posted: May 8, 2013 in Ubuntu

My DVD-reader gave up on me some time ago. I have two laptops with Ubuntu and wanted to use the DVD-reader from the other laptop on the first one. You can easily share the DVD-drive on one laptop using the properties from the file explorer. On the other side, you can see your laptop and the shared drive. But but but, you can’t access the drive from some applications because they do not support Samba directly (which is rather evident). So, you need to mount the drive on a local directory. Just type:

sudo mount -t cifs -o username=yourname,password=yourpassword //your-ip-here/sharename mymount

The mymount directory must exist. Just create one with mkdir. I had trouble using the hostname instead of the IP. With the direct IP address, everything worked as planned. When you look into your mymount-directory you will see the content of your share. You can use this directory in every application.

Advertisement

I recently updated to 12.10 and made the jump to 13.04 shortly after that. Unfortunately, Handbrake refused scanning DVD due to an error in libdvdnav. Apparently something went wrong during the dsitribution upgrade. To get libdvdnav and Handbrake working again, just run:

sudo /usr/share/doc/libdvdread4/install-css.sh

Restart Handbrake and your DVDs can be read again….

Startup script for Ubuntu

Posted: April 15, 2013 in EC2, Play, Ubuntu

When you need to start a service (like Glassfish or Play) in Ubuntu, you can take this script as a template:

#! /bin/sh
case "$1" in
    start)
        ... execute a shell script here ...
        ;;
    stop)
        ... execute a shell script here ...
        ;;
    restart)
        ... execute a shell script here ...
        ;;
esac
exit 0

Make sure to make your scripts executable. In order to get it running during startup, add a link to the init.d directory and register the service-script to make it run as first service (depends on your system which priority you assign, take care here, I just took 01 as an example) 

cd /etc/init.d
sudo ln -sf  ~/your-script.sh your-script.sh
sudo update-rc.d your-script.sh defaults 01 01

Reboot and you’ll see that your services get started.

Recently I had to roll out a REST-Webservice on Glassfish which used jMagick as a library. Now, ImageMagick is a C++ library and is available in Java through JNI. The installation on a standard EC2-Ubuntu AMI is pretty straightforward once you know the tricks. I executed the following steps to get things up and running:
  1. Make an EC2-Instance, attach an EBS and install JDK7 and GFv3.2.1 (these are the version which I installed)
     
  2. Install ImageMagick using sudo yum install ImageMagick. You can’t use apt-get or aptitude since Amazon prefers yum.
     
  3. Next thing is to install jMagick. You can download the latest from ftp://ftp.imagemagick.org/pub/ImageMagick/java/. Use wget to get the RPM (32 or 64 bit – I used the 64bit version).
    wget ftp://ftp.imagemagick.org/pub/ImageMagick/java/jmagick-6.4.0-3.x86_64.rpm
  4. Install the RPM using sudo yum  jmagick-6.4.0-3.x86_64.rpm
     
  5. When all goes well, you should be able to see a handful of Magick-files using ls /usr/lib64/libM* (which were installed in step 2) and of course the Java library ls /usr/lib64/libJMagick.so
  6. There should also be an accompagning JAR file for the library. Check if /usr/lib64/jmagick-6.4.0.jar is there.
     
  7. Now we get to the Glassfish part. Suppose your domain is called “domain1”. Copy the JAR into the /lib directory of your domain so it will get loaded during the startup of Glassfish.
     
  8. Point your browser to the admin-console or open the domain.xml. You need to add a JVM-parameter to get this running. In the console go to the configurations / server-config / JVM-settings and then the JVM-options tab and add the following line:

    -Djmagick.systemclassloader=no

    or add in the domain.xml the line

    -Djmagick.systemclassloader=no
    This line prevents jMagick of using the system-class-loader as you might have expected. Not adding this line leads to errors.
     

  9. Restart your domain and deploy the application. The System.loadLibrary(“JMagick”); in Magick.java runs as planned. (http://jmagick.svn.sourceforge.net/viewvc/jmagick/trunk/src/magick/Magick.java?revision=91&view=markup
We can now redeploy our application in Glassfish at will because the class is loaded by Glassfish during the startup. When not, you can expect exception when redeployen when your jMagick.JAR is in your project. The classloader will tell you that the classes are already loaded when you deploy a second time.
PS: when running Maven tests outside the container, do not forget to specifiy the -Djava.library.path=/your-path-to/libJMagick.so. 
PS2: if you install JMagick using a repository, then the JMagick.so files are stored in the /usr/lib64/jni directory. Copy the libJMagick.so file to /usr/lib64 and restart your domain. There is no need to add java.library.path to the JVM parameters in the domain.xml (something which apparently doesn’t function well).