theClimber

To content | To menu | To search

Tag - linux-planet

Entries feed - Comments feed

Thursday, October 1 2009

Open your OpenOffice files in MS Office 2003 and 2007 !!

I love OpenOffice.org, and have been using it for years. One of the benefits is the sheer amount of space that one can save when using OpenOffice Writer - the ODT files are much smaller. In an age where hard drives and other storage doesn't limit the size of files as much, it seems I am a dinosaur for even considering the amount of bytes I can save. Still, the more free space I have, the more I can store. Plus, when it comes to sending and receiving documents, the smaller they are the less impact it is on a network. In the grand scheme of things, I think bloated documents are as bad as low bandwidth in some areas.

This benefit of OpenOffice.org is lost when I have to send someone a Microsoft Office format for a text file. It bugs me, and I often forget to wipe the converted files to save space - maybe I am getting old. Thus, when I came across How to open ODT (openoffice.org text) files in Microsoft Word, I was surprised and happy.

Quoting from the original site:

Office 2007

  1. Install Service Pack 1 for Office 2007.
  2. Install Sun ODF Plugin for Microsoft Office.
  3. Open ODT document via File > Open, or by double-clicking the ODT file and when prompted for the application to open it with, choose Word.

If you have Office 2003, installing the Sun ODF Plugin should just work.

If you don’t have administrator privileges to install software, you can try an online converter such as Zamzar or Media Convert. You can also upload ODT documents to Google Docs or Zoho Writer.

Thank you. Now, when I accidentally send a smaller file and am short on time, I can simply point people to that and allow me to stop converting files because Microsoft itself had never supported ODT - an open standard with open source software that they could easily have allowed for to be intercompatible.

Monday, September 28 2009

Setup i18n gettext in your PHP application

What is gettext and why use it?

i18n.jpg

gettext is the GNU internationalization and localization (i18n) library. It is commonly used for writing multilingual programs. It has an implementation in a lot of different languages and it's also commonly used in PHP applications.

But what does you mean by internationalisation? Actually, when you write computer code you are also going to write into your code some sentences which will be prompted to the used who is running the application. Those sentences are always written in a language of your choice. But what if that person doesn't understand that language.

The first reaction to solve this problem would be to say : "Ok, but I'm gonna make another version of the code in an other language. I'll translate all those sentences so that my application could be used by other people". And we agree, this is indeed the first solution we get. But this is not optimal since you decide to modify your intial app, you'll have to modify all the translated app too and this is not an issue. It's totally broken to work like this because it imply an enormous quantity of duplicated code and a big amount of work !

That's the moment when gettext came and solved all your problems ! Indeed, the gettext solution proposes te replace all those strings with a call to a gettext function with your sentence as parameter. This function check the chosen language and if it knows a translation of the sentence in that language, it returns the translated sentence, otherwise it returns the initial sentence.

Continue reading...

Tuesday, February 17 2009

How to create a SSH tunnel

First of all, this is a small memo for me because I'll need to use this quite often the next weeks. So if it can be usefull for others, I post it here ;)

openssh.gif

  • I want to access to a private port on a remote host. This port will be mapped on a local port with the tunnel.
  • After creating the tunnel, the service will be accessible on the port localhost:LocalPort
  • All the communications will pass trough the SSH connection (so it will be ssl-encrypted)
ssh -f -N -L LocalPort:RemoteHost:RemotePort Login@RemoteHost
  • -f is to hide the session
  • -N and -L are there for the tunnel

Tuesday, January 27 2009

Tutorial : Setup your mail server (courier-imap + postfix + postgresql)

mysza.gif

Purpose

To have a mail server Which is working with sessions organised in a postgresql database structure and not based on the unix user sessions

Version of the used software for this tutorial

- Ubuntu 8.10 Intrepid server edition - Courier-imap 4.3.1 - Postfix 2.5.5 - postgresql 8.3

I started from a new installation of my distribution so all the actions described here are from scratch.

courier-imap.png

Continue reading...

Wednesday, December 24 2008

Nagios Network Monitoring System Setup on Ubuntu

logofullsize.png

Nagios is a free, open-source tool that can be used to monitor network components and services. When it detects a problem, it can send alert messages by either e-mail or pager. It can also be configured so that only designated personnel can view status information for particular services or equipment. This tutorial will show you how to install Nagios 3 on an Ubuntu 8.10 server.

Nagios3 is in the repository for Ubuntu 8.10.

Continue reading...

Tuesday, December 9 2008

Python shell : extract the local IP from interface

This is a small python script which can be used to extract the local IP address of a host in function of his interface. You can modify this script to adapt it to your purposes. ;)

GiddyUp_and_Bickham_Script_by_vladstudio.jpg

#!/usr/bin/python
# Shell script scripts to read ip address
# -------------------------------------------------------------------------
# Copyright (c) 2008 Greg theClimber <http://www.theclimber.be/>
# This script is licensed under GNU GPL version 3.0
# -------------------------------------------------------------------------
from commands import *
import getopt
import sys

def usage():
	print "Usage : python getip.py [(-i | --interface) name]"

try:
	opts, args = getopt.getopt(sys.argv[1:], "hi:", ["help", "interface="])
except getopt.GetoptError, err:
	# print help information and exit:
	print str(err) # will print something like "option -a not recognized"
	usage()
	sys.exit(2)
intf = None
for o, a in opts:
	if o in ("-h", "--help"):
		usage()
		sys.exit()
	elif o in ("-i", "--interface"):
		intf = a
	else:
		assert False, "unhandled option"

os=getoutput('uname')
ifs=getoutput('ifconfig | grep "Ethernet" | grep -v "vnet" | cut --delimiter=L -f1').splitlines()
interfaces=[]

linux="ifconfig %s | grep 'inet '| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'"
freebsd="ifconfig %s | grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk '{ print $2}'"
sunos="ifconfig -a %s | grep inet | grep -v '127.0.0.1' | awk '{ print $2}'"

if not intf:
	print "Please select the interface to use :"
	for n, i in enumerate(ifs):
		i = i.rstrip(' ')
		interfaces.append(i)
		print "%s) %s" % (n, i)
	print "default = 0"
	try:
		num = input()
		num = int(num)
		i = interfaces[num]
	except: num=0
else:
	i = intf

if i:
	if os == 'Linux':
		ip = getoutput(linux % i)
	elif os =='FreeBSD':
		ip = getoutput(freebsd % i)
	elif os == 'SunOS':
		ip = getoutput(sunos % i)
	else:
		ip = "Unknown"
#	print "%r:%r" % (i, ip)

print ip

Wednesday, December 3 2008

DJBdns : How to configure and use DJBdns as DNS server (part II)

The first part of this tutorial explains how to setup the DJBdns server :

Here you will find the tutorial concerning the basis configuration of a DJBdns server based on the setup did before.

Continue reading...

DJBdns : How to setup DJBdns as DNS server (part I)

Overview

djbdns is a DNS server which want to propose an alternative solution for BIND which is the warlord concerning DNS servers and which is widely used. The thing is that even if BIND is a very complete implementation of the DNS functionalities, it has a very heavy footprint which means that it’s not very flexible and usable on low-performance servers. On the other hand, DJBdns is optimized to have a very light footprint and very secure (instead of bind which is a lot less).

DJBdns developed by D.J. Bernstein, is oriented light and secure before its completeness. Moreover, the developer propose $1000 to the person who officially publish a security hole into his software. This is a good way to improve his software by motivating people to find bugs.

In this tutorial we will see how to install and use this lightweight DNS server. This tutorial was made on and works fine on Ubuntu 8.10 and 8.04. Because it’s not se easy to install, every step is detailed separately.

Your djbdns installation can be easy or hard. If you want it easy, it’s important to do it in the correct order:

  1. Download source tarballs for daemontools, ucspi-tcp and djbdns
  2. Install daemontools
  3. Install ucspi-tcp
  4. Install djbdns
  5. Configure dnscache on an alias to the network card
  6. Configure tinydns on the external IP
  7. Link dnscache to tinydns

Daemontools and ucspi-tcp are systems that launch most DJB software, including djbdns. Daemontools is a system for launching daemons, very similar to the scripts in the /etc/rc.d tree. ucspi-tcp is a system for running background software, very similar to the inetd and xinetd systems on a normal Linux system. Daemontools and ucspi-tcp coexist with /etc/rc.d, inetd and xinetd perfectly.

Continue reading...

Virtual server : mail server configuration

Installation of the IMAP server

Let’s begin with :

apt-get install courier-imap

Now courier-imap will be configurable into the /etc/courier/imapd file. There you can specify the port to use or the name of the path you want to use for the mail. By default the mail directory is called “Maildir” (you can modify it with the parameter MAILPATH=~/Maildir or MAILDIRPATH). To configure it for an user, go into the directory with the same privilege than the user :

cd /home/user
sudo -s -u user
maildirmake Maildir

Installation of the SMTP server

For postfix it’s quite simple, there is a user-friendly interface helping us to configure it :

sudo dpkg-reconfigure postfix

Choose the internet server :

postfix1.png

Add the domain-name of your network (the same than for the DNS server)

postfix2.png

In our case, don’t use procmail, we don’t need to have an anti-spam engine or so, so just reply no to the question.

postfix3.png

For a local network is IPv4 more than enough.

postfix4.png

Now we just need to add one line into the postfix configuration file /etc/postfix/main.cf to specify the user mail directory :

home_mailbox = ~/Maildir/

Test the mail server

First reload the server to enable the last modification of the configuration.

sudo /etc/init.d/postfix restart && sudo /etc/init.d/courier-imap restart && sudo /etc/init.d/courier-authdaemon restart

Install the tools we’ll need :

sudo apt-get install mailutils

Let’s send a mail to an existing user :

# mail user@knowledgeplaza.lan
Subject: this is a test message
hello foo bar
.
Cc: 

To quit the body of the mail you can do “CTRL+d” or add a “.” in an empty line.

Let’s check if the mail was correctly recieved :

ls /home/user/Maildir/new/

It should work.

Configure your favorite mail client

First we need to startup qemu with the right ports open. Otherwise it’ll be impossible to reach the virtual server. So add to que qemo command -redir tcp:5525::25 and -redir tcp:5514::143. Once done, go into your favorite mail client and create a new account with the following parameters :

  • Email address : user@knowledgeplaza.lan (with your own hostname of course)
  • IMAP server : 127.0.0.1
  • IMAP port : 5514
  • SMTP server : 127.0.0.1
  • SMTP port : 5525
  • Login : user
  • Password : user unix password

Now it should work for the configured user.

More references:

Monday, December 1 2008

Virtual server : Install a proxy server

Let’s begin by installing squid:

sudo apt-get install squid

To use squid, we just need to configure our web browser with the good proxy. By default squid listen on port 3128 and works without any modification in the configuration needed.

Moreover, we can add some optimizations to adapt the server to our needs. The configuration file is in /etc/squid/squid.conf.

The important parameters are the followings :

  • http_port 3128 (it’s the default working port of a proxy server, you can change it here)
  • cache_effective_user nobody nobody (user to assign a user or a groud to the proxy server)
  • visible_hostname cache.knowledgeplaza.lan (it’s the name returned by the proxy when it’s reached from outside)
  • cache_mem 20 MB (this is the allocated memory to the server).
  • cache_dir /cache 3200 16 256 (here you can indicate the folder you want to use to save the cache)
  • cache_access_log /var/log/squid/access.log (save the requests log)
  • cache_log /var/log/squid/cache.log (save the cache log)
  • cache_store_log none (save the events that happened on the server)

You can also specify the access control on the proxy : http_access allow all (to allow everyone to use this server)

To test the proxy, set the environment http_proxy to the good value :

export http_proxy=http://127.0.0.1:6681

After that, just try to download a big image on the internet :

wget http://image_url

Try it a second time, with the same request. Normally it will be a lot faster than the first time.

Finalize

To activate the proxy server on each startup of the server, add into the bash preferences /etc/bash.bashrc the next line :

export http_proxy=http://127.0.0.1:8081

More references :

- page 1 of 2