Linux Colloquy push notifications from Debian Squeeze

To get this working I did the folloing on my Debian Squeeze installation.

Compile the latest znc

$ sudo aptitude install build-essential libssl-dev libperl-dev pkg-config 
$ sudo aptitude build-dep znc 
$ wget http://znc.in/releases/znc-latest.tar.gz 
$ tar -xzvf znc*.*gz $ cd znc* 
$ ./configure 
$ make 
$ sudo make install 

Install Colloquy push add-on

$ curl -LO http://github.com/wired/colloquypush/raw/master/znc/colloquy.cpp 
$ znc-buildmod colloquy.cpp 

Move colloquy.so to ZNC’s modules folder. By default, this is ~/.znc/modules/.

$ mv colloquy.so ~/.znc/modules/ 

Configure ZNC

$ /usr/local/bin/znc --makeconf 

Misc

Load the Push module with ZNC, either through webadmin or by typing /msg *status loadmod colloquy.

For help and options, type /msg *colloquy help or /msg *colloquy status in your IRC client.

Note: if you want to disable push when another client is connected to znc, pass the following argument to the colloquy module (make sure your module is up-to-date):

-attachedpush 0 

or send a message to *colloquy after loading the module:

/msg *colloquy attachedpush 0 

Sources

How to install Google Authenticator under Debian Squeeze

The Two way authentication from Google is very cool! I found a post describing how to install it under sid, but I have modified it to apply to the current version of Debian stable.

  1. Download the libpam-google-authenticator package from http://packages.debian.org/wheezy/libpam-google-authenticator. (It is not available in Squeeze stable, so I downloaded the following manually: http://ftp.se.debian.org/debian/pool/main/g/google-authenticator/libpam-google-authenticator_20110413.68230188bdc7-1.1_amd64.deb)
  2. Run:
    sudo aptitude install libqrencode3
    sudo dpkg -i libpam-google-authenticator_20110413.68230188bdc7-1.1_amd64.deb
  3. Configure google-authenticator by running
    google-authenticator
  4. Scan the barcode from the Google Authenticator app on your mobile device.
  5. Edit /etc/ssh/sshd_config and set :
    ChallengeResponseAuthentication yes
  6. Edit /etc/pam.d/sshd and add at the very beginning of the file :
    auth required pam_google_authenticator.so
  7. Restart the service :
    service ssh restart
  8. Done

 

Sources:

gcc path problem with Debian 6.0.4 on VMware Fusion

I got the following error message while installing VMware Tools on Debian 6.0.4 on VMware Fusion.

The path "/usr/bin/gcc" is not valid path to the gcc binary.

I tried to fix it by installing the linux-header files…without any success.

I solved it by running:

apt-get install kernel-package

apt-get install gcc-4.3 linux-headers-`uname -r` -y

I found the solution here.

Enforce HTTPS with a .htaccess file

Start by enabling mod_rewrite then create an .htaccess file in the directory that you want to force HTTPS.

The content of the .htaccess-file:

RewriteEngine On RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} somefolder 
RewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]

Now if you go to http://www.domain.com/somefolder you will be redirected to https://www.domain.com/somefolder.

Logging my work to a text file and making it readable in VIM

I use VIM to edit text-files on my mac. Or I use VIM to edit a couple of text-files containing my my worklogs. So I can keep track of what I have done on different projects and at what time.

Creating a quick log entry

I have edited my .bash_profile with the following line
alias wl='vim + ~/Dropbox/NV/worklog.txt; clear'

This in combination with quick access to terminal.app using Visor makes appending to my worklog almost instant.

  1. Visor keyboard shortcut, in my case Alt + § (On a Swedish keyboard It makes sense)
  2. I type wl and press enter
  3. VIM opens the last line in my worklog
  4. To enter insert mode and append to the end of the line i type A.
  5. I type enter -> nnow ,which is my TextExpander abbreviation for inserting a date and time stamp, on the new line. (Example: 2011-04-12 20.20 [Tuesday] )
  6. The I write a short log of what I’m doing at the moment.
  7. I save and exit the worklog file by typing Esc (to exit insert mode), then wq -> enter.

Done.

Making the text file readable in VIM

To make this logfile more readable I use a customized color formatting.

Edit the ~/.vimrc file

This is the content of my .vimrc file.

colorscheme desert
syntax on

au BufRead,BufNewFile *.txt set filetype=txt
au! Syntax newlang source ~/.vim/syntax/txt.vim

Create the ~/.vim/syntax/txt.vim

Source

I downloaded Tomasz Kalkosinski’s universal syntax script for all txt docs. But I added a couple of changes of my own:

syn match logDate /^\d\{4}-\d\{2}-\d\{2}/
syn match logTime /\d\{2}:\d\{2}:\d\{2},\d\{3}/

And later in the file:

HiLink  logDate Comment
HiLink  logTime Todo

You can download my vim.txt file here.

Linked: Bash reference

Found this awesome bash reference here and thought I’d share it.

Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W Delete the word before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor
Alt + F Move cursor forward one word on the current line
Alt + B Move cursor backward one word on the current line
Tab Auto-complete files and folder names

Linked: GParted 0.8 can recover data from lost partitions

GParted is an extremely handy LiveCD to keep in your technician’s toolbox, and its new version features one very major addition: GParted 0.8 can now help you recover data from lost partitions. After analyzing your drive and doing its best to resurrect missing information from the partition table, GParted will now let you mount partitions it finds in read-only mode so you can copy your data to another drive.

via GParted 0.8 can recover data from lost partitions.

How I built a Apache front-end for a Windows Share with SSL and LDAP Authentication

When my company migrated from Exchange 2003 to Exchange 2007 public folder became a big issue. Public folders where used to share documents to our road-warriors. So to fix this we installed a sharepoint server

The problem is that the sharepoint install was like using a rocket propelled grenade to kill a fly. It became more of a problem than a nice way to distribute documents to the people on the road.

So I decided to set up a web-based front-end running apache that points to the windows share that everyone in our office uses.

1. Setting up the virtual machine in our VMware vSphere cluster

OS and SSH

I started by installing a basic Debian 5 server without the GUI stuff. I also installed SSH for remote access..

VMware Tools

I installed VMware tools on the newly created VM.

# apt-get install build-essential
# mount /cdrom
# cp /cdrom/VMware* /tmp
# umount /cdrom
# cd /tmp
# tar xvfz VMware*.gz
# cd vmware-tools-distrib/
# ./vmware-install.pl

2. Webserver

Apache 2.2

I installed apache2.2 by running the following command.

# aptitude install apache2

PHP5

PHP is not actually a part of this setup but I figured that I would install it for future use..

# aptitude install php5 libapache2-mod-php5
# /etc/init.d/apache2 restart

Add support for MySQL in PHP

# aptitude install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json
# /etc/init.d/apache2 restart

3. Mount the Windows Share as part of the filesystem.

I mounted the share to the /var/www (to make it simple)..

# apt-get install smbfs 
# update-rc.d -f umountnfs.sh remove
# update-rc.d umountnfs.sh stop 15 0 6 .

I added the following to the fstab: (I have substituted the actual paths and share names with < … >)

//<Windows fileserver>/<Windows share> /var/www/<Windows share> smbfs iocharset=utf8,file_mode=0777,dir_mode=0777,user=<domain>/<username>,password=<password>,gid=33 0 0

To mount the share:

mount -a

4. Security settings

Block access to http://<serverURL>/<Windows share> over port 80 (unencrypted)

I added the following to the /etc/apache2/sites-enabled/000-default

<Directory /var/www/<Windows share> >
Deny from All
</Directory>

Activate support for LDAP authentication in Apache

I created the following symlinks for mod_ldap and mod_authnz_ldap from /etc/apache2/mods-available to mods-enabled

SSL and LDAP authentication

I started by activating SSL by creating a symlink from ssl configuration file (/etc/apache2/sites-available/default-ssl) to the /etc/apache2/sites-enabled directory.

The I made the following changes to the configuration file.

<Directory /var/www/<Windows share> >
    Order deny,allow
    Deny from All
    AuthType Basic
    AuthName "<Name of the share>"
    AuthBasicProvider ldap
    AuthzLDAPAuthoritative on
    AuthLDAPURL ldap://<Windows domaincontroller>:389/dc=<domain>,dc=<local>?sAMAccountName?sub     
    AuthLDAPBindDN "cn=<Bind user that checks the AD>,ou=<some ou with the user>,dc=<domain>,dc=local"
    AuthLDAPBindPassword <password for the binduser>
    Satisfy any
    require valid-user
</Directory>

5. Creating the redirect from http to https

Pretty much every user will open http://<serverURL>/<Windows share> instead of https://<serverURL>/<Windows share>. So I have to create an automatic redirect.

I created the following /var/www/index.php file.

<?php
header( 'Location: https://<serverURL>/<Windows share>');
phpinfo();
?>

6. Nicer looking icons on my index page

I didn’t like the standard Apache index look so I did the following.

# cd /tmp
# apt-get install bzr
# bzr get http://code.ecchi.ca/apache-tango-icons
# ./install.sh

I have also changed the /etc/apache2/mods-enabled/autoindex.conf

IndexIgnore .??* ~* Thumbs.db *.lnk SyncToy_*
IndexStyleSheet "/icons/style.css"

I created/changed the /usr/share/apache2/icons/style.css with the following content.

body {
        font: 85% Arial,Helvetica,Sans-serif;
        color: #444;
        line-height: 2.2em;
        background: #f9f7f5;
}
a:link, a:visited { color: #4265a7; }
.entry a:link, .entry a:visited { font-weight: bold; }
a:hover { color: #993333; }

address {display: none}
table {
border-collapse: collapse;
width: 80%;

}
td, th {
  padding: 2px;
}

References

  1. Debian install ISOs
  2. How to install Apache, mysql etc.
  3. Apache authentication, LDAP etc.
  4. Better lookling icons for the index listing

Linked: Delete Files Older Than x Days on Linux – How-To Geek

Great post on how to delete files older than x days on linux. The How-To Geek is awesome, as usual!

Command Syntax

find /path/to/files* -mtime +5 -exec rm {} \;

Note that there are spaces between rm, {}, and \;

Explanation

  • The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. I would recommend using the full path, and make sure that you run the command without the exec rm to make sure you are getting the right results.
  • The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days.
  • The third argument, -exec, allows you to pass in a command such as rm. The {} \; at the end is required to end the command.

This should work on Ubuntu, Suse, Redhat, or pretty much any version of linux.

Delete Files Older Than x Days on Linux – How-To Geek.

A Guide to Efficiently Using Irssi and Screen | quadpoint.org

Irssi is a text-only IRC client. It does not get in your way and its commands are intuitive and useful. Non-standard features are implemented with perl scripts, rather than in the core. Irssi can range from a functional, no-frills client to a highly-customized and automated client.

Irssi is not the only focus of this guide. The ingenious program screen will also be discussed. Screen is a highly useful tool that allows a user to manipulate multiple windows inside of a single session. Each window operates independently of the others and acts like another terminal. For example, a user can create a screen session with Irssi running in the first window, an instant messenger program open in the second window, and a general purpose shell prompt in the third window. The beauty of the screen is that users can “detach” from their screens, logout, and then at a later time, login again “reattach” to find their programs still running just as they left them. The steps to do this will be explained in this guide.

Great post!

A Guide to Efficiently Using Irssi and Screen | quadpoint.org.