Using Pipe Viewer for File Progress in Linux

There are numbers of ways of producing a file copy, compression, deletion, decompression dialog progress in Linux.
I was looking for a new way of doing it (yes, I know about tar’s checkpoint) and other similar methods. I came across a utility called ‘pv’ or Pipe Viewer.

pv – monitor the progress of data through a pipe

pv allows a user to see the progress of data through a pipeline, by giving information such as time elapsed, percentage completed (with progress bar), current throughput rate, total data transferred, and ETA.
To use it, insert it in a pipeline between two processes, with the appropriate options. Its standard input will be passed through to its standard output and progress will be shown on standard error.
pv will copy each supplied FILE in turn to standard output (- means standard input), or if no FILEs are specified just standard input is copied. This is the same behaviour as cat(1).

root@nitrous:/mnt/oldlinux/var/vhost/gallery/var# tar -cf - albums/ | pv -s $( du -sb albums | awk '{print $1}') | gzip > /backups/gallery_albums.tgz
 311MB 0:00:21 [15.2MB/s] [>                                   ]  2% ETA 0:11:50
root@nitrous:/mnt/oldlinux/var/vhost/gallery/var# tar -cf - albums/ | pv -s $( du -sb albums | awk '{print $1}') | gzip > /backups/gallery_albums.tgz
 3.9GB 0:04:36 [14.9MB/s] [===========>                        ] 36% ETA 0:07:52

Check your distribution repos for the ‘pv’ package. Happy hacking =)

Bind9 Wildcard DNS

Decided instead of managing all the DNS records for techish.net. that I would just setup wildcard entry for techish.net.
In my zone master file, I added the following:

*.techish.net. IN A 74.219.241.252

Then I reloaded bind9

/etc/init.d/bind9 reload

Voila, wildcard DNS.  Make sure you put the entry after all your static definitions and if you add more static definitions, put them above that wildcard entry.

My .screenrc

I’m bored, so here’s what my current .screenrc is (screenshot included).

backtick 1 60 60 /usr/local/bin/checkmail.pl
hardstatus alwayslastline
hardstatus string '%{= kW}%-Lw%{= KW}%50>%n%f* %t%{= kW}%+Lw%< %{= kG}%-=[Mail: %1`] %D %d %M %Y %c:%s%{-}'
vbell off
startup_message off

This is my .fetchmailrc

poll mail.techish.net with proto IMAP
user me@example.com there with password xxxxxxxxx
folder 'INBOX'

This is /usr/local/bin/checkmail.pl

#!/usr/bin/perl
open FETCHMAIL, /usr/bin/fetchmail -t 10 -c -f ~/.fetchmailrc  2>/dev/null |
 or die Can't run fetchmail: $!n;
while(<FETCHMAIL>){
   if(/^(d+) messages ((d+) seen.*?folder (.*?))/){
      $m+=$1; $s+=$2; $f=$3;
# you might have to change this regex depending on
# how your IMAP server displays subfolders
      $f =~ s/INBOX.//;
   }
   if($1 > $2){
      $fs{$f} = $1 - $2;
   }
}
close FETCHMAIL;
$t = $m - $s;
if($t > 0){
   foreach $folder (sort { $fs{$a}<=>$fs{$b} } keys %fs){
      push @folders, $folder:$fs{$folder};
   }
}
print join  , @folders;

Debian Wheezy Bind9 Failing to Start

After installing Bind9 chrooted to /var/lib/named in accordance to this guide (link), Bind9 is failing to start due to the following error noted in /var/log/daemon.log
To resolve this, I found some search results hinting around the fact that OpenSSL libraries for 1.0.0 were the cause since chroot didn’t have access to them.  So to correct this, on my system, I used the following commands.

mkdir -p /var/lib/named/usr/lib/x86_64-linux-gnu
cd /var/lib/named/usr/lib/x86_64-linux-gnu
cp -R /usr/lib/x86_64-linux-gnu/openssl-1.0.0 .

After making those modifications, I then start Bind9.

/etc/init.d/bind9 start

Everything is working now.