Archive for the ‘programming’ Category

Mounting a remote ssh filesystem using sshfs on Ubuntu

Saturday, February 2nd, 2008

I am working on a Linux computer at the University with a RedHat Entreprise distribution. There I have all my work that:

  1. I wish to have as backuped as possible;
  2. I wish to have easily accessible from my laptop, to upload and download.

I looked for ways to do it and I found sshfs. In this way, as I will show you, whenever I log in to my laptop, with an internet connection available, I have a virtual folder where I have a seamless access to all the files on my pc at the University. This is how I did it:

  1. Enabled the Multiverse on the Synaptics software sources. Went to System–> Administration –> Software sources, then on the Ubuntu software tab, checked the fourth option (Multiverse).
  2. Installed sshfs:
    sudo apt-get install sshfs
  3. Once installed, changed the permissions so that I could mount it as normal user:
    sudo chmod +x /usr/bin/fusermount
  4. Made a mount point directory on my laptop that points to the directory I am mounting on the other machine. In this case I created a directory named lraero19 (which is the name of my computer at the university) on the /media directory:
    sudo mkdir /media/lraero19
  5. Then changed the owner to me:
    sudo chown gorkiana /media/lraero19
  6. Afterwards I had to add my user to the group “fuse” so that I could use it. For that I typed:
    sudo adduser gorkiana fuse

    Then I had to logout and login back again so that the change took effect.

  7. Mounted the remote drive with sshfs. For this I typed in:

    sshfs my_user_name@ip_at_university:/the_directory_to_mount /media/lraero19

  8. To unmount I just type:
    fusermount -u /media/lraero19

Since I have to do this every time I logged in, I decided to automate the process. For that I needed first to get rid of the password prompt. Hence I did this:

  1. I had to create a public key on my laptop and copy it to the university computer so that I did not need to type in the password every time. Typed:
    ssh-keygen -t rsa

    (typed enter to the both question since I do not want a password).

  2. Made a directory named .ssh at my home directory at the university computer:
    mkdir /media/lraero19/.ssh

    (now I can do it as if it was a local directory :-) ).

  3. Then chmoded it:
    chmod 700 /media/lraero19/.ssh
  4. Copied the public key to there:
    cat .ssh/id_rsa.pub >> /media/lraero19/.ssh/authorized_keys
  5. Chmoded it:
    chmod 600 /media/lraero19/.ssh/authorized_keys

Then I wanted it to run everytime I logged in to GNOME, for that I just went to Sytem –> Preferences –> Sessions, then at the startup programs tab just added one more, with the command:

sshfs my_user_name@ip_at_university:/the_directory_to_mount /media/lraero19

Finally I had to get a way of unmounting the drive when I logged out. After many hours googling I found a solution! Edited the file: /etc/gdm/PostSession/Default and added the following line before the exit 0 line:

fusermount -u /media/lraero19

del.icio.us Slashdot Digg Technorati Google StumbleUpon

LaTeX on mediawiki on a shared host

Wednesday, January 30th, 2008

For a couple of weeks I have been trying hard to put my NereidesWiki to work on my website hosted at ixwebhosting, which is a shared host.

The idea behind this wiki was that it could be a place to start collecting ideas and things that I learn during my phd, so that, in the end, it would be easier to write down the thesis. Since it is a scientific related wiki it is mandatory that it is able to show mathematical expressions. MediaWiki is able to do that making use of texvc, LaTeX, dvips and convert from the ImageMagick software suit, the problem lies in configuring it.

Of course, at the first attempt it did not work and I sent a ticket to the host and they replyed with a kind: “we don’t support 3rd party software”. I was on my own. After googling alot I found that I had to start by putting texvc to work, that ment compiling it for the OS of the host. After too many tickets sent to them and too many live chats with them and with a help of a friend of mine, I managed to compile it. It did not work either. Later they told me they did not hat LaTeX nor dvips installed on the server.

I was about to give up, thinking “why isn’t there a service that one could use instead of going through all this trouble?”. Instead of running it locally on our own server, run LaTeX and dvips remotely on another server. Hopefully I found it: mimeTeX! Very simple to use. Here I show you how to do it, or you can follow the original link here:

  1. Install MediaWiki
  2. Take a backup of your MediaWiki installation.
  3. Find a LaTeX engine:
    1. If you have CGI support on your host install mimeTeX, which can be found at: http://www.forkosh.com/mimetex.html
    2. If you don’t have CGI support, use a public mimeTeX server: http://www.forkosh.dreamhost.com/mimetex.cgi or http://www.forkosh.dreamhost.com/mathtex.cgi (for prettier rendering using mathTeX)
  4. Open Math.php in $WikiPath/includes/Math.php and find this function:

1
2
3
4
5
6
function renderMath( $tex ) {
   global $wgUser;
   $math = new MathRenderer( $tex );
   $math->setOutputMode( $wgUser->getOption('math'));
   return $math->render();
}

Replace it with:

1
2
3
4
5
6
7
8
function renderMath( $tex ) {
   ###Hacking Math.php
   #global $wgUser;
   #$math = new MathRenderer( $tex );
   #$math->setOutputMode( $wgUser->getOption('math'));
   #return $math->render();
   return "<img src="http://blog.palha.org/wp-admin/%5C%22http://your_host/cgi-bin/mimetex.cgi?$tex%5C%22" class="tex" alt="\"LaTex:" />";
}

Where http://your_host/cgi-bin/mimetex.cgi is the URL of your mimeTeX installation or the public one. I used a public one, and it works, at least with MediaWiki v1.11.1. Note that you must have texvc compiled, but that is not very difficult to solve.

del.icio.us Slashdot Digg Technorati Google StumbleUpon