Display vpnc connection status

To display the connection status of your vpnc connection, use this command line:
pgrep vpnc > /dev/null && echo Connected || echo Disconnected; echo $(ps -p $(pgrep vpnc)

I placed this as a function in my .bashrc files so it is evaluated on every invocation. If this is added as a simple alias, the alias in only evaluated on this creation of the shell and will not get dynamically updated.

vpnc-status() {
  pgrep vpnc > /dev/null && echo Connected || echo Disconnected;
  if [ $(pgrep -c vpnc) -gt 0 ]
    then echo $(ps -p $(pgrep vpnc) -o etime=)
  fi
}

If you add it to your .bashrc file, don’t forget to source the file in order to activate the function:
. ~/.bashrc

Once this function has been activated, invoking it as vpnc-status will output ‘Connected’ or ‘Disconnected’.  If it is connected, it will also display the time it has been running in the [[dd-]hh:]mm:ss format.

Create tar ball from within a Git repo without .git files

Assuming we are sitting in the package development git repo, this command will create a tarball one directory up. Replace branch with the name of the branch you wish to archive.

git archive --format=tar --prefix=package-6.2.0/ <branch> | bzip2 > ../package-6.2.0.tar.bz2

This works great for me as I use .tar.bz2 files in my rpm spec files to build final rpm packages to deploy.

If you need gzip instead of bzip2, pipe the git archive command into gzip instead. And, of course, update the output filename accordingly.

Setting Up a Custom DNS for Testing Purposes

These are the files I used to configure a test DNS to reply to all DNS requests for ANY .com to my test server.

Once this is up and running just configure each server’s /etc/resolv.conf file to point to this server.

[root@ats-check ~]# cat /etc/named.conf
options {
# listen-on port 53 { 127.0.0.1; };
# listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
# memstatistics-file "/var/named/data/named_mem_stats.txt";
# allow-query { any; };
# allow-transfer { localhost; 2.2.2.2; };
recursion no;

dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;

/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";

managed-keys-directory "/var/named/dynamic";
};

zone "com" IN {
type master;
file "all.com.zone";
allow-update { none; };
};

zone "test000000.com" IN {
type master;
file "test000000.com.zone";
allow-update { none; };
};

# 10.22.190.90
zone "190.22.10.in-addr.arpa" IN {
type master;
file "/var/named/190.22.10.rev";
allow-update { none; };
};

logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};

zone "." IN {
type hint;
file "named.ca";
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

include "/etc/rndc.key";

[root@ats-check ~]# cat /var/named/all.com.zone
$TTL 816400
@ IN SOA com. root.test000001.com. (
100 ; serial
1H ; refresh
1M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS ns1.test000001.com.
@ IN A 172.19.107.164
ns1 IN A 172.19.107.164
@ IN MX 10 mail.test000001.com.
mail IN A 172.19.107.164
WWW IN A 172.19.107.164
* IN A 172.19.107.164

[root@ats-check ~]# cat /var/named/190.22.10.rev
$TTL 86400
@ IN SOA test000000.com. root.test000000.com. (
100 ; serial
1H ; refresh
1M ; retry
1W ; expiry
1D) ; minimum
@ IN NS ns1.test000000.com.
1 IN PTR binggo.test000000.com.

[root@ats-check ~]# cat /etc/resolv.conf

#nameserver 10.255.250.11
#nameserver 10.255.251.11
#search dc1.corp.gd jomax.paholdings.com hosting.corp.gd gdhosting.gdg int.godaddy.com
nameserver 127.0.0.1

[root@ats-check ~]# cat /var/named/test000000.com.zone
$TTL 86400
@ IN SOA test000000.com. root.test000000.com. (
100 ; serial
1H ; refresh
1M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS ns1.test000000.com.
@ IN A 10.22.190.90
ns1 IN A 10.22.190.90
@ IN MX 10 mail.test000000.com.
mail IN A 10.22.190.90
WWW IN A 10.22.190.90

vimdiff – updated diff view after changes

After invoking a vimdiff of two files, I will often sync changes from one file into the other. (I, personally, like using ‘dp’ to ‘diff push’ a change from one window into the other. After making changes, it is sometimes necessary to update the view of the diff in the two files. You can either exit and return (inefficient and slow), or simply ‘:diffupdate’.

Move mutiple files to a subdirectory

Sometimes I need to move an multiple file or an entire directory tree down one subdirectory level.

mv !(subdir) sudir

uses Bash’s extended pattern matching option – extglob.

To see it extglob is enabled:

shopt extglob

extglob on

To enable extended pattern matching:

shopt -s extglob

Linux history without line numbers

I use my history to track what commands I have executed for a given project.  As often as I try to keep my project notes up to date, I often fall behind in the heat of the moment.  I will often refer back to my history to remind me what commands, and in what order I ran them.  Using this command, I can dump my history without line numbers so I can copy/paste into my notes:

history | cut -c 8-

Linux – Bash – Perl – Colorize tail -f output

I tail out a lot of Linux log files, and sometimes I want to highlight when certain messages scroll on the screen. This one-liner will tail a log file and highlight the entire line when certain keywords or phrases (based on the regex).

tail -f | perl -pe 's/.*example1.*/\e[31m$&\e[0m/g; s/.*example2.*/\e[32m$&\e[0m/g'

Essentially, this uses Perl’s substitute to replace the line which matches the regex with an Escape sequence to colorize the output \e[31m$ then the line itself followed by an Escape sequence to turn off all text attributes \e[0m.

In the example above, ‘example1’ will be output with the text attribute of 31 which sets the foreground (text color) of red. Whereas ‘example2’ will be output with the text attribute of 32 which will set the text color to green. To see a table of color codes and other ANSI text attributes (like bold, background color, blink, etc) see  ANSI escape code on Wikipedia.

Planar ELT 320-P1 – For Sale

Here are the images of the Planar ELT 320-P1 terminal:

Back of the unit
Back of the unit
Wall mount tray in closed position
Wall mount tray in closed position
Wall mount tray open
Wall mount tray open
Wall mount tray mounting hardware
Wall mount tray mounting hardware

 

Wall mount assembly and mounting instructions - front
Wall mount assembly and mounting instructions – front
Wall mount assembly and mounting instructions - back
Wall mount assembly and mounting instructions – back
Wall mount tray in the original packaging
Wall mount tray in the original packaging
Unit in original anti-static bag
Unit in original anti-static bag