My Personal Blog

Just a spot for my random thoughts.

I've had to play with this every time I reinstall Ubuntu and want to setup a VNC web client which is really handy when I'm work and need to access my PC at home for whatever reason. 

First, make sure you have remote desktop enabled by going to Menu -> System -> Preferences -> Remote Desktop.  Click "Allow other users to view your desktop" and "Allow other users to control your desktop."  For my use, since I VNC into my desktop from remote locations and thus will not be at my desk to accept my own connection, I uncheck "You must confirm each access to this machine" and check "Require the user to enter this password."  Make sure you use a strong password.  Of course, you may need to configure your router to forward incoming communication for ports 5800 and 5900 to your desktop you're wanting to connect into. 

Second, if you do not already have apache installed, install it:

sudo apt-get install apache2

Third, download the tightvnc-java package. I use the latest version at Tightvnc's website rather than the one in Ubuntu's repositories. Download and extract the java Binary *.class and JAR files in Zip archive (or Tar+Gzip) and extract the contents wherever you want.

Finally, open Nautilus as root by hitting Ctrl-F2 and typing gksu nautilus (or if you're a Linux pro, you can use a terminal to copy the contents to /var/www/vnc).  Browse to /var/www and create a folder named vnc.  Copy the contents of the java vnc viewer to /var/www/vnc. Open index.html and replace all the contents with this:

<HTML>
<TITLE>
TightVNC desktop
</TITLE>
<APPLET CODE="VncViewer.class" CODEBASE=classes/ ARCHIVE="VncViewer.jar"
        WIDTH="800" HEIGHT="632">
<PARAM NAME="PORT" VALUE="5900">
<param name="Open New Window" value="yes">
</APPLET>
<BR>
<A href="http://www.tightvnc.com/">TightVNC site</A>
</HTML>

And that should do it.  You can now access it via http://ip.address/vnc or use a dynamic DNS service such s DnsExit to create a domain name that points to your home IP. 

 

 


Tagged in: Untagged 

I found that Joomla's caching feature can cause my server to run out of space quickly unless the admin consistently purges expired cache.  Since Joomla only has a manual mechanism in place to be able to do this, I decided to create a script that can be run by a cron job to handle this for me.

Its quite simple.  First, I load Joomla's framework then simply call the function to purge the cache.

$mainframe = startJoomla();

jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');

$cache =& JFactory::getCache('');
$result = $cache->gc();

if ($result) {
    echo 'Expired cache purged.';
} else {
    echo 'Failed to purge expired cache.';
}

function startJoomla()
{
    define('_JEXEC', true);
    define( 'DS', DIRECTORY_SEPARATOR );
    define('JPATH_BASE', dirname(__FILE__) );
    // load joomla libraries
    require_once JPATH_BASE . DS . 'includes' . DS . 'defines.php';
    require_once JPATH_LIBRARIES . DS . 'loader.php';
    jimport('joomla.base.object');
    jimport('joomla.factory');
    jimport('joomla.filter.filterinput');
    jimport('joomla.error.error');
    jimport('joomla.event.dispatcher');
    jimport('joomla.event.plugin');
    jimport('joomla.plugin.helper');
    jimport('joomla.utilities.arrayhelper');
    jimport('joomla.environment.uri');
    jimport('joomla.environment.request');
    jimport('joomla.user.user');
    // JText cannot be loaded with jimport since it's not in a file called text.php but in methods
    JLoader::register('JText', JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'methods.php');
    JLoader::register('JRoute', JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'methods.php');

    $mainframe = & JFactory::getApplication('site');
    $GLOBALS['mainframe'] = & $mainframe;
    return $mainframe;
}

I put this code in a file in Joomla's root directory. Then I created a cronjob to have this script ran by PHP every night.  My cronjob looks something like this:

/usr/bin/php /home/username/public_html/purgecache.php

And that's it! Automatic purging.


Tagged in: Untagged 

Well, it never fails that when I upgrade Ubuntu, I run into a few issues.  Gotta love open source. :-)

The issue was with my ATI drivers.  I had initially installed them using ATI's script for the catalyst 10.4 driver which is suppose to have support for Ubuntu 10.04.  But after installing it, every little movement was super choppy and jerky.  So I decided to remove it.  Usually easy enough right?  Just a sudo apt-get remove fglrx and success?  Nope.

Removing fglrx ...
dpkg-divert: mismatch on package
  when removing `diversion of /usr/lib/libGL.so.1.2 to /usr/lib/fglrx/libGL.so.1.2.xlibmesa by fglrx'
  found `diversion of /usr/lib/libGL.so.1.2 to /usr/lib/fglrx/libGL.so.1.2.xlibmesa by xorg-driver-fglrx'
dpkg: error processing fglrx (--purge):
 subprocess installed post-removal script returned error exit status 2
Processing triggers for ureadahead ...
Errors were encountered while processing:
 fglrx

It failed.  After searching for a long time, I finally came across a discreet page that gave me what I needed to make it happen.

sudo dpkg-divert --rename --remove /usr/lib/libGL.so.1.2
sudo dpkg-divert --rename --remove /usr/lib32/libGL.so.1.2 sudo dpkg --force-all --purge fglrx

Success! Afterward, just make sure you reinstall either xorg's open source ATI driver or Ubuntu's fglrx package as you might find yourself in low graphics mode otherwise :-)  You may also need to do

sudo dpkg-reconfigure xserver-xorg

Later...I found this post which helped tremendously as well.


Tagged in: Untagged