msgbartop
A cronological documentation test project, nothing serious, really!
msgbarbottom

13 Jan 2012 Using Lsyncd to perform “live” syncronization of a local directory to a remote directory

This post is a short HOWTO and describes how you can install and run lsyncd to perform a rsync syncronization from local to a remote server using SSH.
Lsyncd is a daemon to continuously synchronize directory trees and relies on inotify. If you need real live syncronization DRBD might be a better alternative since it is a block level syncronization.

Installing Lsyncd 2.0 from source on CentOS 6
Lsyncd is not included as a package in CentOS 6, so you need to download the source file from http://code.google.com/p/lsyncd/downloads/list.
You should have rsync, GCC and lua-devel installed on your system before you continue installing Lsyncd.

# yum install rsync lua-devel

Unpack the lsyncd source file and run the following commands from the unpacked file

# configure 
# make
# make install

make install copies the compiled files and install them to the right directories in your system.

I need to configure a non password SSH communication between the two servers with a shared SSH key.
On the source server run the following command to generate a SSH key, if you have not done this already.
Remember to do this as the user you are going to perform the sync with.

# ssh-keygen

Secure copy the generated SSH key from the source server to your target server

# scp ~/.ssh/id_rsa.pub root@remoteserver:/tmp

On the target server you need to add the copied SSH key to your existing authorized keys file.
Also remember to do this with the user you are going to connect with from the source server.

# cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys

If you do not have this file, just create it using the touch command described below

# touch ~/.ssh/authorized_keys

Test if you can ssh without a password from your source server to the target server.

I have made a config file, /root/scripts/lsyncd.conf that tells Lsyncd where to put the log- and statusfile. That it should be running as a daemon in the background, and a sync should occur after 900 seconds (15 minutes) if there have not been any filesystem changes and there should not be more than 6 parallell Lsyncd processes.

settings = {
   logfile      = "/tmp/lsyncd.log",
   statusFile   = "/tmp/lsyncd.status",
   nodaemon     = false,
   maxDelays    = 900,
   maxProcesses = 6,
}

sync{default.rsyncssh, source="/path/on/source/", host="hostnam.target.server.tld", targetdir="/path/on/target/"}

To start lsyncd you run the command

# lsyncd /root/scripts/lsyncd.conf

You should now see a Lsyncd process running as a daemon on your system. It performs a sync when you start and then waits for any filesystem changes or sync after 900 seconds.

If you would like Lsyncd to start at boot, just add the following line to the bottom of file /etc/rc.local

lsyncd /root/scripts/lsyncd.conf

You do now have a working secure rsync syncronization between two servers.

What directories you are syncing

# tail -f /tmp/lsyncd.status

What is happening now

# tail -f /tmp/lsyncd.log

Tags: , , , , ,

Posted by

28 Nov 2011 Switching to a graphical login on RHEL6

This is a short post on how to install the necessary components to get X Server running on a bare bone RedHat 6 Enterprise Server (CentOS6) installation.
The following commands should be run from a console window as the root user.

Install barebone X support

# yum groupinstall "X Window System"

Install X and the Gnome Environment

# yum groupinstall "X Window System" "GNOME Desktop Environment"

Install X and the KDE Window System

# yum groupinstall "X Window System" KDE

Install the XFCE desktop environment

# yum groupinstall "X Window System" XFCE

When you have chosen your desired desktop environment, make the final change to make the Gnome Display Manager show you a logon screen.
Edit the file /etc/inittab and change the line
from

id:3:initdefault:

to

id:5:initdefault:

You will be greeted with a graphical logon screen the next time you have rebooted your server.

Tags: , , , ,

Posted by

26 Feb 2008 List rpm package content

To list the contents of a package just run the command

# rpm -ql packagename

Example

# rpm -ql nmap

/usr/bin/nmap
/usr/share/doc/nmap-3.70
/usr/share/doc/nmap-3.70/COPYING
/usr/share/doc/nmap-3.70/COPYING.OpenSSL
/usr/share/doc/nmap-3.70/README
/usr/share/doc/nmap-3.70/nmap-fingerprinting-article.txt
/usr/share/doc/nmap-3.70/nmap.deprecated.txt
/usr/share/doc/nmap-3.70/nmap.usage.txt
/usr/share/doc/nmap-3.70/nmap_doc.html
/usr/share/doc/nmap-3.70/nmap_manpage.html
/usr/share/man/man1/nmap.1.gz
/usr/share/nmap
/usr/share/nmap/nmap-mac-prefixes
/usr/share/nmap/nmap-os-fingerprints
/usr/share/nmap/nmap-protocols
/usr/share/nmap/nmap-rpc
/usr/share/nmap/nmap-service-probes
/usr/share/nmap/nmap-services

Tags: , , ,

Posted by

17 Oct 2007 Enabling Remote Access to the Installation System

You may access either graphical or text interfaces for the Redhat installation system from any other system. Access to a text mode display requires telnet, which is installed by default on Fedora systems. To remotely access the graphical display of an installation system, use client software that supports the VNC (Virtual Network Computing) display protocol. A number of providers offer VNC clients for Microsoft Windows and Mac OS, as well as UNIX-based systems.

The installation system supports two methods of establishing a VNC connection. You may start the installation, and manually login to the graphical display with a VNC client on another system. Alternatively, you may configure the installation system to automatically connect to a VNC client on the network that is running in listening mode.

Enabling Remote Access with VNC
To enable remote graphical access to the installation system, enter two options at the prompt:

linux vnc vncpassword=astrongpassword

The vnc option enables the VNC service. The vncpassword option sets a password for remote access. The example shown above sets the password as astrongpassword. The VNC password must be at least six characters long.

Specify the language, keyboard layout and network settings for the installation system with the screens that follow. You may then access the graphical interface through a VNC client. The installation system displays the correct connection setting for the VNC client:

Starting VNC...
The VNC server is now running.
Please connect to computer.mydomain.com:1 to begin the install...
Starting graphical installation...
Press <enter> for a shell

You may then login to the installation system with a VNC client. Start the VNC client Enter the server and display number in the VNC Server dialog. For the example above, the VNC Server is computer.mydomain.com:1.

This is possible on RedHat, Fedora and probably other distributions derived on these distributions like CentOS.

Tags: , , , , ,

Posted by

17 May 2007 Courier-IMAP to Dovecot Migration Script

I’ve just migrated a couple of servers from Courier-IMAP to Dovecot, and am very happy with the latter so far. I thought I’d share the courier2dovecot shell script I whipped together (based on the instructions I found in the migration how-to), for converting Courier-IMAP maildirs to Dovecot format.

While the script is rather simple, it can save a fair bit of typing when migrating some hundreds of mail accounts, especially since Courier stores some of its own state files recursively in each folder of the maildir hierarchy, making it a real pain to otherwise manually rename or remove all of them.

Here’s a plain-English summary of what the script currently does, when given a Courier maildir path as an argument:

  • Check that the given path is indeed a valid Courier maildir, and exit if not.
  • Rename the file ‘courierimapsubscribed’ to ‘subscriptions’, and strip the ‘INBOX.’ prefix from its contents.
  • Recursively rename all of files of the name ‘courierimapuiddb’ to ‘dovecot-uidlist’.
  • Recursively delete all of files of the name ‘courierimaphieracl’, ‘courierimapacl’ and ‘courierimapkeywords’.

The script will also verbosely print out each action it performs, handy for redirecting the output to a log file for a large migration.

Hopefully people about to jump ship from Courier to Dovecot find this useful. If anyone comes up with improvements to the script, please send them my way.

#!/bin/sh
#
# courier2dovecot -- Converts a Courier maildir to Dovecot format.
# Copyright (c) 2005 Arto Bendiken. Released under the GNU GPL.
# Newest version available from http://bendiken.net/scripts/
#
# 2005-10-21 initial version for Dovecot 1.0.
#
dir="$1"
if [ -z "$dir" ] || [ "$dir" = "-?" ] || [ "$dir" = "-h" ] || [ "$dir" = "--help" ]; then
  echo "Usage: $0 maildirpath"
  exit 1
fi
if [ ! -d "$dir" ] || [ ! -e "$dir/courierimapsubscribed" ]; then
  echo "$dir is not a path to a Courier maildir"
  exit 1
fi
find $dir -name courierimapsubscribed -print0 | xargs -0r rename -v 's/courierimapsubscribed/subscriptions/'
find $dir -name subscriptions -print0 | xargs -0r sed -i 's/INBOX\.//'
find $dir -name courierimapuiddb -print0 | xargs -0r rename -v 's/courierimapuiddb/dovecot-uidlist/'
find $dir -name courierimaphieracl -print0 | xargs -0r rm -vrf
find $dir -name courierimapacl -print0 | xargs -0r rm -vf
find $dir -name courierimapkeywords -print0 | xargs -0r rm -vrf

Comment to the script:
Hey Arto & everyone using this script:

Be careful when trying to run this on Red Hat Enterprise Linux or CentOS 4 systems. These operating systems ship with a different rename command than the Debian systems. You can also tell them apart based on the output when running ‘rename’ with no arguments.

This is the perl version which works:
Usage: rename [-v] [-n] [-f] perlexpr [filenames]

This is the RHEL/CentOS version that doesn’t:
call: rename.orig from to files…

Hope this helps someone out there, and thanks for the script Arto!

Source: http://bendiken.net/2005/11/03/courier-imap-to-dovecot-migration-script

Tags: , , , , , , , , , ,

Posted by