contributers categories 6 6 6 5 5 5
quick links
Continued dbhub development
Posted 12:34:07 AM on Sat, 14th January 2012 by Dj-ZoRt! Image #20

We use dbhub at our LANparty as our direct connect server software of choice. I am the first to admit that it has gone stale upstream, but feature wise its still ahead of the alternatives on Linux or Windows.
The sourceforge project page has sort of fallen to pieces and my attempts to contact anyone involved have failed. So I have taken the latest tarball (which is up to date with CVS on sourceforge) then dumped it in to git on github. From there I have applied some patches from Gentoo, imported a .spec file I found (and disclaim) and I have created some rudimentary debian package control files.
I welcome people forking and improving things, I have been able to compile dbhub on both i386 and amd64, Gentoo claims to be compiling on PPC and others. The dbhub project has provided in the past .ikpg's for openwrt which are mips architecture - so I suspect its portable enough. Check it out at github.com/djzort/dbhub.

Some thoughts on promoting Perl Weekly Newsletter
Posted 7:00:40 PM on Mon, 17th October 2011 by Dj-ZoRt! Image #9

I dont claim to be an expert by any means, but i have read a few books on small business marketing (internet and non-internet) in my endeavours with my LANparty event. So based on that reading plus my own experiences, here are some thoughts, in no particular order, on promoting the Perl Weekly Newsletter and really any other email newsletter. The reader is encouraged not to just use them as is, but to use them as a starting point for further ideas and experiments to find what works for you.

10 Perl Coding Tips
Posted 9:32:04 PM on Mon, 26th September 2011 by Dj-ZoRt! Image #5

1. always 'use strict' and 'use warnings' - its been said a million times, but do it. Optionally remove 'use warnings' when moving code to production. If you can argue for or against this, then this tip isn't for you.

2. Use the 'perltidy' program to tidy up your code. You can apt-get it, yum install, etc etc. It tidies up your perl code in seconds, or perhaps someone elses code. Its configurable if you prefer different layouts. Be warned though, running perltidy then checking in to source repos breaks the 'blame' connection with the original author of each line.

3. Learn about the concept of 'context' as soon as possible. Dont ignore it. Context is at the very heart of perl programming - and related to tip 6.

4. Use Perl::Critic (or perlcritic.com while you are still learning). Its a great way to improve your code and coding. Its like having a crowd of perl experts critique your code and provide detailed feedback.

5. Learn how to use 'perldoc' and get in to the habit early of writing pod yourself. Essentially you just type 'perldoc Some::Module' and you get something that looks like a manpage explaining how the module works.

6. Dont use 'length' to test variables. Perl isnt Java :) in Perl, variables can stand alone in the conditional part of a control statement. Just be awair that '0' also counts as false. Oh, avoid warnings in log files by remembering to test that a variable has content before regexing it or sticking it in strings - use your head about this as you dont need to get carried away.

7. Dont have two modules 'use' each other. Ive seen it, i cant imagine how 'perl' is supposed to make sense of such a scenario.

8. Start learning about how to write tests with Test::More and its friends. Use the 'prove' command to run your tests in bulk, and start getting in to the habit of writing testable code.

9. Read perl books! - Check out the O'Reilly series and various other publishers.

10. Understand that there isnt a 'proper' way of 'throwing exceptions' in Perl. There are few ways, two commone ones are the eval-die method which is somewhat Java-ish or the checking of a return value then inspect a variable approach.

Send email via a pipe to a script with exim
Posted 10:33:11 PM on Wed, 17th August 2011 by Dj-ZoRt! Image #6

Here is a short example of how to have exim4 pipe emails to a script. Basically it uses the 'pipe' transport to feed the email to the script via STDIN. I'm going to assume the reader is familiar with exim enough that i won't explain what transports and routers are, or where they belong in the exim config file. In this example, i will have exim feed all emails for a single domain to the script, you can configure exim to use other criteria such as user names, regular expressions, database lookups etc. The exim4 documenation will explain these options. Anyway.

You should begin by creating a domain list such as

domainlist cmd_domains = cmd.your-domain.com

Then either add cmd_domains to local_domains, or look for the dnslookup driver and add the domain next to the list next to local_domains.

Add the below to the router section

# command router
cmd_router:
driver = accept
domains = +cmd_domains
transport = cmd_transport

Add this to the transports section

cmd_transport:
debug_print = "T: using cmd_transport"
driver = pipe
command = /tmp/test.pl
delivery_date_add
envelope_to_add

There are lots of options as to whats send to the script, you will likely want to review them. Two such options above are 'delivery_date_add' and 'envelope_to_add', which add the date of delivery and the envelope 'to' field to the data send to the script.

The 'command' option is where you list you command. You can add exim config variables to that command string and when exim runs the command it will place those values in the args of the command.

As for the script, here is a sample. The message data is pipe'd to the script via STDIN. This script is not very usefull, but demonstrates how to read STDIN in perl.

#!/usr/bin/perl

use strict;
use warnings;

open my $fh, '>>', '/tmp/output.txt';
print $fh <STDIN>;
close $fh;

And thats it! Now its up to you to do something with the email. You can use some other language than perl or even compile a program, just read STDIN and examine the program arguments

using perl in %pre in Anaconda
Posted 10:36:00 AM on Tue, 9th August 2011 by Dj-ZoRt! Image #9

Here is how to make a perl image for anaconda (the installer for fedora, redhat, centos etc), which will allow you to use perl in the %pre stage. I've used staticperl from http://software.schmorp.de/pkg/App-Staticperl.html. There is a small and a big staticperl version, which includes just a few or quite a lot of perl modules respectively.

# make an ext2 image of 50 megs and format it ext2, and mount
dd if=/dev/zero of=perl5.img bs=512 count=100000
losetup /dev/loop0 ./perl5.img
mkfs -t ext2 /dev/loop0
mount -t ext2 /dev/loop0 /mnt

# copy the files and unmount
cd /mnt
wget http://staticperl.schmorp.de/bigperl.bin
cd ~
umount /dev/loop0
losetup -d /dev/loop0

# thats it!

Now just put that somewhere accessible via http and specify it as an update image when you boot to anaconda.
linux updates=http://some.website.com/path/to/perl5.img
Then use it in %pre with...
%pre --interpreter /tmp/updates/bigperl.bin

Icons for DIA
Posted 9:22:23 AM on Thu, 2nd December 2010 by Dj-ZoRt! Image #1

Its hard to find icon sets for Dia. Overwhelmingly, searching for them finds links to forums and mail archives where people are asking for them.

Here are some links i have found.

Some Rack Server Icons
http://jez.choralone.org/dia.html

Some icons converted from Gnome
http://gnomediaicons.sourceforge.net/

Expanding RAID using Areca
Posted 3:16:03 PM on Thu, 23rd September 2010 by Dj-ZoRt! Image #20

Its extremely easy to expand a RAID set on Areca RAID cards. I have an ARC-1261 - however all the Areca cards have the same interface and use the same management software. Good stuff! Its just a pity there isnt a standard for hard RAID management in linux/freebsd like there is in OpenBSD. Areca is possibly the best raid card for OpenBSD but regardless, a note of warning... these steps may help you on Linux, FreeBSD and Windows but not in OpenBSD.

So yes this is how I have expanded my RAID 5 array in FreeBSD using the areca-cli command line management tool.

There are four steps. Three of which are in the Raid card, the third is OS level

  1. Plug in a new drive. Ideally it should be the same as the other drives in the candidate RAID set. Turn on your computer, assuming it boots to your OS successfully. Go to the command line and run areca-cli then go it your admin password with set password=0000. Now type rsf info and check that your raid array is healthy, that is that the State is Normal. Then check that the new disk is present with disk info. If your raid array isnt optimal and the new disk isnt present... well go fix it :) The new disk should have a Usage of Free
  2. From the two info commands in step 1 you will know the raid set number (left most column of the info output) and the disk number (again, the number in the left most column of the info output). We can now expand the raid set with the following command rsf expand raid=1 drv=13. Noting that raid=1 refers to the raid set not the raid level! So where i have raid=1 you should use the raid set number on your local machine that we found in step 1, and similarly where i have drv=13 you should use your disk number. If you run rsf info again, you will see that the State is now Migrating. This will take some time and you can see the progress as a percentage with vsf info. You can speed it along by increasing the background task priority with sys changept p=3, remember to set that back to 1 (Low) when you're done.
  3. Expand the volume set (more details here)
  4. Expand the partition and filesystem. This is specific to your operating system. I wont provide details here except to say that in freebsd one uses the <em>growfs</em> command, and if you formatted the drive raw rather than slicing/partitioning it (yes you can do that in FreeBSD) then there is no need to worry about enlarging the slice/partition.

It does take some time, but it can continue if you shut down the computer and you can continue to use the file-system while its expanding (albeit more slowly)

Using microdc2 for headless DC++ servage
Posted 11:41:54 PM on Tue, 18th May 2010 by Dj-ZoRt! Image #2

microdc2 is an Free CLI based Direct Connect client for unix like operating systems. Perhaps its most attractive feature is that it has minimal external dependencies and is incredibly fast.

Its an excellent choice for running a linux/bsd DC++ server.

Firstly you will need to install it. You should be able to work that out yourself. Use yum or apt-get depending on your Linux, or the ports tree in your BSD. If this is beyond your knowledge - stop now and look at another option.

Secondly, you need to install screen. This will allow you to run the microdc2 program in a console and detach from it, then re-attach later. Install screen then read its man page :)

Third, you should run microdc2 as a non-root user, who has only read access to your files.  Now run microdc2 as that user for the first time. su'ing to that user is an ok idea, sudo may not set the HOME environment correctly.
This is important as microdc2 looks for its config in ~/.microdc2

Fourth, set some  shares with the share command, i.e. share /storage/vol1. Just repeat the command with other locations, and microdc2 will add them to its list and start hashing them.

Fifth, quit microdc2 with the exit command. And edit the ~/.microdc2/config file with your favourite editor. The format of this this file is just commands from the microdc2 command line, one command per line. These are run when the program starts, thus configuring the program. Its worth noting that nothing you do on the command line other than adding shares is preserved when you exit. So everything goes in the config file manually. Oh well.

Here is a sample config file...

set listenport 10101
set nick myservernick
set email you@yourdomain.com
set description "dont ask for slots"
set downloaddir /storage/downloads
set speed LAN
set active 1
set auto_reconnect on
set slots 15
connect 172.29.0.1



What does each line mean? Before i tell you, remember that there is a README in the microdc2 tarball, which is likely installed in /usr/share/doc/microdc2 or /usr/local/share/doc/microdc2

set listenport 10101


The port microdc2 will listen on. For a non-root user this has to be a high port i.e. > 1024, other than that just pick something at random like i have. Then open it on the local firewall, iptables for linux, ipfw or a number of others in BSD.

set nick myservernick

The nickname of the server.

set email you@yourdomain.com

Your contact email.

set description "dont ask for slots"

The description as shown in the user listing. Set it to whatever you like

set downloaddir /storage/downloads

This where files that you download will be saved to. If you miss it out, it will default to the current directory when you started microdc2. Even if you are just sharing, its not a bad idea to just set it to something.

set speed LAN

The speed value is just meta-data, just set it to LAN.

set active 1

This tells microdc2 to actually do something. Other than just accepting configuration.

set auto_reconnect on

With this on, microdc2 will continue to try to connect when disconnected or when it fails to connect.

set slots 15

This is the number of slots available. If your not familiar with what slots are in Direct Connect, why are you reading this?

connect 172.29.0.1

Has microdc2 immediately attempt to connect to a hub. I like to set this as the LAN i run has its hub at 172.29.0.1. When im at other lans I can stop it with disconnect on the command line, then type connect <hub>
For reference <hub> can be either an ip or a hostname. Most lans will set up a dns alias for the dc hub as 'dchub', making connect dchub a potential good general case.



For a full list of options, run microdc2 and type set.

Keep in mind that you can try any setting on the command line, then save it to the config file.

Some ideas for additional configuration:-
You can have microdc2 log to a file using set log <options> and set logfile /some/log/file.txt
Reduce the amount of noise from event notifications by using set display <options>. In both cases the options are the same, and the full list of options is provided when you type set

Six and finally, run screen to make a detachable session, then run microdc2. It will then start up with all the options you have configured. You can detach with <ctrl>+<shift>+A+D list detached screens with screen -ls and resume with screen -r


Tips:
Always put your files on disks separate to your OS!!!
Mount the archive filesystem with the 'noatime' flag. This will turn off updating the 'Access Time' flag, something you almost certainly dont care about, in exchange for a small increase in performance (I've read numbers saying 5-7% increase)

Torrus on FreeBSD
Posted 9:28:17 PM on Fri, 23rd October 2009 by Dj-ZoRt! Image #2

There isnt a lot of instructions for how to install Torrus on FreeBSD. Fortunately there is a port, which is how i found Torrus in the first place.

Torrus is a monitoring framework in the spirit of Cricket - but unlike Cricket, people are actually maintaining it. It supports a large number of devices and works with either modperl1 or modperl2.

I will quickly step through whats needed to get things going. Everything else is available in Torrus' documentation...

1. Install & update ports,
2. Install apache2+modperl2 (ill assume that you can work that out)
3. Make Torrus with mod perl 2 support (unfortunately this port doesnt do make config)

cd /usr/ports/net-mgmt/torrus
WITH_MOD_PERL=2 make
WITH_MOD_PERL=2 make install


for reference, the files installed can easily be listed with

pkg_info -L 'torrus*'

4. Edit sample configs

cd /usr/local/etc/torrus/conf
cp torrus-siteconfig.pl.sample torrus-siteconfig.pl



Turn off ACLs and auth access (turn on later if you want)

vi torrus-siteconfig.pl

add this line

$Torrus::ApacheHandler::authorizeUsers = 0;

5. Copy more sample configs to proper configs

cd /usr/local/etc/torrus/xmlconfig
cp site-global.xml.sample site-global.xml  


6. Apache config, this is the lines youll need. Look elsewhere for apache details if you arent familiar with apache configuration. I set up a new vhost and included the following...

vi /usr/local/etc/apache22/Includes/torrus.conf

Alias /torrus/plain "/usr/local/share/torrus/sup/webplain"
      PerlRequire "/usr/local/share/torrus/conf_defaults/webmux2.pl"
     
        SetHandler modperl
        PerlResponseHandler Torrus::Apache2Handler
     

     
        SetHandler default-handler
        Options None
     


7. Restart apache...

/usr/local/etc/rc.d/apache22 restart

8. Add cleanup to crontab

echo "5    3    *    *     *       root    /usr/local/libexec/torrus/cleanup" | crontab -


9. Add some devices...

/usr/local/libexec/torrus/genddx --host=172.29.0.253:switchy --subtree="/main" --out=switch.ddx --version=2c --community=public --holtwinters 

Docsis
Posted 11:38:33 PM on Thu, 16th July 2009 by Dj-ZoRt! Image #1

(Note to self really) Page 384 describes the meanings of the tuples, page 421 also has useful info. Now to implement it in perl...

http://www.cablemodem.com/downloads/specs/CM-SP-RFI2.0-I11-060602.pdf