Adventures in Ubuntu systems administration

Uncategorized

CSS3 imageless gradient buttons

Jay posted some great looking buttons over at Anomaly:  http://blog.anomalyinnovations.com/2010/03/creating-a-realistic-looking-button-with-css3/

To follow on from there I have updated (hacked) the example to use CSS3 gradients instead of images. Unsupported browsers fallback to solid colour backgrounds.

I am not using these examples in the wild. They need a lot more polish before being released. Image fallback could be added back in for example. It was just to show examples of how the CSS3 gradient buttons look and function in Firefox and Chrome.

Button code:

<a class='button'><b class='o'><b class='m'><b>Button</b></b></b></a>

Results in various browsers:

Check out the example code at: http://dl.dropbox.com/u/173699/css3-buttons.html

- Karl


nginx + mongrel + redmine – quick setup notes

My quick setup notes for nginx as a frontend to a mongrel redmine server.

This is intended for situations where redmine needs to be served in a subdirectory via a nginx that is also used for other serving needs.

Some basic prerequisite knowledge of nginx and redmine will likely be needed.

Instructions are tested on redmine-svn and Ubuntu-9.10.

  • Install dependencies
    • sudo apt-get install subversion libmysql-ruby rake rubygems mongrel nginx
  • Setup directory structure
    • sudo adduser --system --group redmine
      sudo mkdir /opt/redmine
      sudo chown redmine:redmine /opt/redmine
      sudo -Hu redmine svn checkout http://redmine.rubyforge.org/svn/trunk /opt/redmine
  • Create the MySQL database for redmine
    • Example for mysql-server on localhost:

      sudo apt-get install mysql-server
      mysql -u root -p
      create user 'redmine'@'localhost' identified by 'password';
      grant all privileges on  `redmine\_%` . * to  'redmine'@'localhost';
      create database redmine_production character set utf8;
      quit;
    • (or use phpmyadmin)
  • Copy config/database.yml.example to config/database.yml and edit the database configuration
    • sudo -Hu redmine cp /opt/redmine/config/database.yml.example /opt/redmine/config/database.yml
      sudo -Hu redmine vim /opt/redmine/config/database.yml
    • Example database spec:
      • production:
          adapter: mysql
          database: redmine_production
          host: localhost
          username: redmine
          password: password
          encoding: utf8
  • Generate redmine session store secret
    • cd /opt/redmine
      sudo -Hu redmine gem install -v=2.3.5 rails
      sudo -Hu redmine rake generate_session_store
  • Create the database structure and insert the default data
    • sudo -Hu redmine RAILS_ENV=production rake db:migrate
      sudo -Hu redmine RAILS_ENV=production rake redmine:load_default_data
  • Setup redmine to be served from /redmine/
    • cd /opt/redmine/config
      sudo -Hu redmine cp additional_environment.rb.example additional_environment.rb
      echo 'config.action_controller.relative_url_root = "/redmine"' | sudo -Hu redmine tee -a additional_environment.rb
  • Setup email delivery as desired
    • cd /opt/redmine/config
      sudo -Hu redmine cp email.yml.example email.yml
      • Example smtp spec
        • sudo -Hu redmine vim email.yml
          production:
            delivery_method: :smtp
            smtp_settings:
              address: smtp.example.com
              port: 25
              domain: example.com
  • Start the mongrel server
    • cd /opt/redmine; sudo -Hu redmine mongrel_rails start -e production -p 9001 -d
  • Edit /etc/nginx/sites-enabled/default
    • sudo vim /etc/nginx/sites-enabled/default
    • Add to the active server section:
      •         location /redmine {
                        alias /opt/redmine/public/;
                        try_files  $uri/index.html $uri.html $uri @mongrel;
                }
                location @mongrel {
                        proxy_set_header  X-Real-IP        $remote_addr;
                        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
                        proxy_set_header  Host             $http_host;
                        proxy_redirect    off;
                        proxy_pass        http://127.0.0.1:9001;
                }
  • Restart nginx:

    sudo service nginx restart
  • Test the website. eg: http://localhost/redmine/
  • If successful, set mongrel to start on boot
    • sudo vim /etc/rc.local
      • cd /opt/redmine; sudo -Hu redmine mongrel_rails start -e production -p 9001 -d
  • Retest site after a reboot

Iptables packet flow diagram

Here is the diagram I keep stuck to my wall for reference when dealing with iptables.

I cannot remember what site I used as a reference when creating the diagram. The original was an ascii chart though. This is created in dia and exported to pdf too. Both attached for convenience. CC licensed as long as the original chart I copied allows it.

Packet flow examples:

All packets to or from localhost travel down the left side of the chart.

From external destination localhost: PREROUTING -> INPUT -> [Local Process] -> OUTPUT -> POSTROUTING.

From localhost destination external: OUTPUT -> POSTROUTING -> [External Host] -> PREROUTING -> INPUT.

All forwarded packets travel the right side of the chart and travel all three tables coming in and then again going out.

From external dest internal: PREROUTING -> FORWARD -> POSTROUTING.

Internal response to external: PREROUTING -> FORWARD -> POSTROUTING.

and so forth.

This is what caught me for a while. Forwarded packet travel the right side route and get out of (or in to) the network. The response then gets generated and does not start from FORWARD or POSTROUTING, but from PREROUTING again. So all NEW forwarded packets need to be marked in PREROUTING and the mark saved. Not new packets need that mark restored in PREROUTING, and all packets need that mark restored in POSTROUTING. (As demonstrated by my previous post).

Locally generated traffic only sees OUTPUT and POSTROUTING before hitting the network and needs to be marked before hitting POSTROUTING, hence the OUTPUT chain rules in my previous post.

I will accept changes to the chart too if anybody wants modifications made.

iptables routing.dia

iptables routing.pdf


Installing Debian Lenny on my DNS-323

I finished upgrading my Dlink DNS-323 to Debian Lenny today. I followed the instruction at:

http://www.cyrius.com/debian/orion/d-link/dns-323/install.html

The install took quite a while, I selected the standard package list. Then because it gets quit hot here in Griffith I really wanted to have fan control back, so instruction here were also followed.

As I wanted to install to an 8GB Flash drive I had handy I first uploaded the netboot.img firmware, turned off the DNS-323, removed the hard drives and left only the flash drive inserted, then powered up and followed the installation instructions.

I like keeping root on the flash drive as the hard drives can be stopped all day when not in use to save temp and power.

Fans are also controlled by lm-sensors and the unit seems to run about 47degC most of the day.

I use the unit mostly for irc (screen/weechat), rsync backup target and samba media server. It handles all that pretty well but I do notice it bog a fair bit with only 64mb ram and hard drive transfer rates are not as good as I am used to, but on the whole a great little unit (now that it runs debian).


Review: Liferay Portal 5.2 Systems Development

Liferay Portal 5.2 Systems Development

Life Portal 5.2 Systems Development

  • Author: Jonas X. Yuan
  • Pages: 552
  • Publisher: Packt Publishing
  • Rating: 9/10
  • ISBN: 1847194702
  • Summary: A Java developer’s guide to developing custom intranet systems, based on Liferay’s platform

As one of only a few books on advanced Liferay Portal development Jonas had a LOT of material to cover. My two weeks of experience with Liferay up to this point had only involved deployment, configuration and theme development. After been impressed with the results so far my next three aims were customising the WYSIWYG editor with styles more specific to the site, adding layout templates to support quick deployment of content and some custom portals for integrating our other information management systems. A week later with the book and I have the first two knocked over and am on my way with the portals. (more…)


Liferay theme release – WinterSky

And now announcing the release of my first Liferay theme. Details about the wordpress theme it is based on is available in my previous post (Liferay Inroads).

Requisite Screenshot

Requisite Screenshot

It has made a perfect intranet theme for our uses. Most appreciated is the simplified interface look.

I have finished most visual touchups. Things left on my to do list are submenu indicators, tools menu rearrangement and rethemeing the chat portal.

If anybody has ideas on integrating the chat portal visuals closer I’d be happy to listen.

DOWNLOAD and INSTALL: The theme should now be available from the theme installer in liferay-5.2.2 installs and the WinterSky theme page on Liferay is here.

Now to work on some new portals. Till next time.


Liferay inroads

After installing Alfresco and admittedly suffering a few hiccups with it I seem to be making enough progress that I also decided to investigate Liferay as an alternative to Plone as our intranet portal and internal information site.

There are some areas that Plone really does well such as the content type handling and content workflow. But lack of documentation in other areas has left me pulling my hair out at times, such as ldap user and group integration with openldap and active directory, debugging modules and some new gotcha each time something is updated in a buildout.

Liferay has also had a steep learning curve, but I found it no where as bad as Plone. No messing in the ZMI for setting up ldap auth, changing database backends or setting portal defaults. Just one config file. I have found the speed surprising compared to Plone on the same hardware too. With java webapps I have tried in the past I have been left with the impression of them being bloated, memory hungry and slow. But I am slowly coming around thanks to Alfresco and Liferay. (more…)