One USB Drive, Two Partitions. Much useful.

In a follow up to the Dogecoin client install post, here is steps to create multiple partitons on a single USB drive so one can both boot and store files on the same USB drive.

Partition the USB drive. I made two partitions. One 2GB FAT32, and 28.5GB ext4. I initially did this for Arch Linux, but added/changed to Ubuntu for dogecoin users. A few of the steps below when partitioning are not actually needed when you use unetbootin to write the iso, however there is no harm in doing them.

[jmorgan@arch-dopey ~]$ sudo fdisk /dev/sdc

Welcome to fdisk (util-linux 2.24).  
Changes will remain in memory only, until you decide to write them.  
Be careful before using the write command.

#Current (Empty)  
Command (m for help): p  
Disk /dev/sdc: 30.5 GiB, 32717537280 bytes, 63901440 sectors  
Units: sectors of 1 * 512 = 512 bytes  
Sector size (logical/physical): 512 bytes / 512 bytes  
I/O size (minimum/optimal): 512 bytes / 512 bytes  
Disklabel type: dos  
Disk identifier: 0xc3072e18

#Create 2GB Partition  
Command (m for help): n

Partition type:  
p primary (0 primary, 0 extended, 4 free)  
e extended  
Select (default p): p  
Partition number (1-4, default 1):  
First sector (2048-63901439, default 2048):  
Last sector, +sectors or +size{K,M,G,T,P} (2048-63901439, default
63901439): +2GB

Created a new partition 1 of type 'Linux' and of size 1.9 GiB.  
#Change type  
Command (m for help): t  
Selected partition 1  
Hex code (type L to list all codes): L

0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris  
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-  
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-  
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT-  
4 FAT16 \<32M 40 Venix 80286 85 Linux extended c7 Syrinx  
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data  
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .  
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility  
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt  
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access  
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O  
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor  
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs  
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT  
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/  
10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b  
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor  
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor  
14 Hidden FAT16 \<3 61 SpeedStor ab Darwin boot f2 DOS secondary  
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS  
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE  
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto  
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep  
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT  
1e Hidden W95 FAT1 80 Old Minix  
#b is FAT32  
Hex code (type L to list all codes): b  
If you have created or modified any DOS 6.x partitions, please see the
fdisk documentation for additional information.  
Changed type of partition 'Linux' to 'W95 FAT32'.

#Change bootable flag  
Command (m for help): a  
Selected partition 1  
#Create 28.5GB partition  
Command (m for help): n

Partition type:  
p primary (1 primary, 0 extended, 3 free)  
e extended  
Select (default p):

Using default response p.  
Partition number (2-4, default 2):  
First sector (3907584-63901439, default 3907584):  
Last sector, +sectors or +size{K,M,G,T,P} (3907584-63901439, default
63901439):

Created a new partition 2 of type 'Linux' and of size 28.6 GiB.  
#Write partition table  
Command (m for help): w  
The partition table has been altered.  
Calling ioctl() to re-read partition table.  
Syncing disks.

[jmorgan@arch-dopey ~]$

Create the filesystems, FAT32 and ext4 for me.

#FAT32 -- For Arch bootable iso, this label must match the release
version used -- Not important for Ubuntu/unetbootin  
[jmorgan@arch-dopey ~]$ sudo mkdosfs -F 32 -n ARCH_201401 /dev/sdc1  
mkfs.fat 3.0.24 (2013-11-23)  
#ext4  
[jmorgan@arch-dopey ~]$ sudo mkfs.ext4 /dev/sdc2  
mke2fs 1.42.8 (20-Jun-2013)  
Filesystem label=  
OS type: Linux  
Block size=4096 (log=2)  
Fragment size=4096 (log=2)  
Stride=0 blocks, Stripe width=0 blocks  
1875968 inodes, 7499232 blocks  
374961 blocks (5.00%) reserved for the super user  
First data block=0  
Maximum filesystem blocks=4294967296  
229 block groups  
32768 blocks per group, 32768 fragments per group  
8192 inodes per group  
Superblock backups stored on blocks:  
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632,
2654208,  
4096000

Allocating group tables: done  
Writing inode tables: done  
Creating journal (32768 blocks): done  
Writing superblocks and filesystem accounting information: done

[jmorgan@arch-dopey ~]$

At this point you have a single USB drive with two partitions. One with the intent of being used for bootable image(Ubuntu, Arch, etc) and the other for storing data.

If you are reading this post for Dogecoin I suggest using unetbootin along with Ubuntu 12.04 iso. Select the Ubuntu iso, and specify the smaller(first) partition to write to. You can store the needed files for the client install on the other partition. Here is how.

You can let unetbootin download the iso for you, or in my case use a local iso. I've already downloaded Ubuntu 64-bit 12.04. I've selected this iso, and the first partition on the USB drive(sdc1).

unetbootin

Checking what we've done, and storing needed files onto the second partition.

#mount the partiton unetbootin wrote Ubuntu 12.04 to:  
[jmorgan@arch-dopey ~]$ sudo mount /dev/sdc1 /mnt/os  
#mount the partition used for storage.  
[jmorgan@arch-dopey ~]$ sudo mount /dev/sdc2 /mnt/files  
#contents of what unetbootin created  
[jmorgan@arch-dopey ~]$ ls /mnt/os/  
arch dists ldlinux.c32 menu.c32 README.diskdefines ubninit  
autorun.inf EFI ldlinux.sys pics syslinux ubnkern  
boot install loader pool syslinux.cfg ubnpathl.txt  
casper isolinux md5sum.txt preseed ubnfilel.txt wubi.exe  
[jmorgan@arch-dopey ~]$

#copying dogecoin-qt tar with deps, and script to build dogecoin-qt
after booting Ubuntu 12.04.  
[jmorgan@arch-dopey ~]$ sudo cp
dogecoin-qt-1.5-ubuntu-12.04-Live-Install.tar /mnt/files/  
[jmorgan@arch-dopey ~]$ ls
/mnt/files/dogecoin-qt-1.5-ubuntu-12.04-Live-Install.tar  
/mnt/files/dogecoin-qt-1.5-ubuntu-12.04-Live-Install.tar  
[jmorgan@arch-dopey ~]$

At this point you can follow the previous post, Dogecoin Ubuntu Live CD Installer. I personally carry a USB bottle opener my sister gave me which has a bootable linux distro on one partition, and storage on the other. At any time I can open a beer, and boot linux!In that order ofcourse. :)

Doge: D8kWKgF2x6gsiZzRyXgonogPQuRMxf6qtp

more ...

Dogecoin Ubuntu Live CD Installer

I spent a little time today trying to come up with a single tar file and script to install dogecoin-qt on an Ubuntu live CD. This will let fellow shibes make offline wallets for better security!

You can get the code and instructions from my github here.

This version is created for 64-bit Ubuntu 12.04 Live CD. I likely have too many deps in the tar file as it is quite huge(~80MB), but it works! I'll work on shaving it down soon.

Here is what it looks like in action:

[shibe@ubuntu mnt]$ sudo tar -xvf
dogecoin-qt-1.5-ubuntu-12.04-Live-Install.tar  
dogecoin-qt-1.5-ubuntu-12.04-Live-Install/

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-xml_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libx11-6_2%3a1.4.99.1-0ubuntu2.2_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libssl1.0.0_1.0.1-4ubuntu5.11_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-system1.48.0_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libdrm-dev_2.4.46-1ubuntu0.0.0.1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-system1.48-dev_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqtwebkit-dev_2.2.1-1ubuntu4_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-scripttools_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/x11proto-input-dev_2.3-1~precise1_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/gcc-4.4_4.4.7-1ubuntu2_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/qt4-linguist-tools_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libstdc++6-4.6-dev_4.6.3-1ubuntu5_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libdrm-intel1_2.4.46-1ubuntu0.0.0.1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libalgorithm-merge-perl_0.08-2_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libdrm2_2.4.46-1ubuntu0.0.0.1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libdb++-dev_5.1.4ubuntu1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libdb5.1++-dev_5.1.25-11build1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libglu1-mesa_8.0.4-0ubuntu0.7_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/x11proto-kb-dev_1.0.5-2_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libxcb1-dev_1.8.1-1ubuntu0.2_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/g++-4.6_4.6.3-1ubuntu5_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-qt3support_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqtcore4_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-filesystem1.48-dev_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/x11proto-xext-dev_7.2.0-3_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-date-time1.48-dev_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/g++-4.4_4.4.7-1ubuntu2_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-sql_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/qt4-qmake_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/zlib1g-dev_1%3a1.2.3.4.dfsg-3ubuntu4_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libtimedate-perl_1.2000-1_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libkms1_2.4.46-1ubuntu0.0.0.1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-script_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/cpp-4.4_4.4.7-1ubuntu2_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libx11-doc_2%3a1.4.99.1-0ubuntu2.2_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libgl1-mesa-dev_8.0.4-0ubuntu0.7_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/x11proto-core-dev_7.0.22-1ubuntu0.1_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-svg_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libxext-dev_2%3a1.3.0-3ubuntu0.1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-designer_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libpthread-stubs0_0.3-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libxau-dev_1%3a1.0.6-4_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-serialization1.48.0_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqtgui4_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/mesa-common-dev_8.0.4-0ubuntu0.7_amd64.deb  
dogecoin-qt-1.5-ubuntu-12.04-Live-Install/xtrans-dev_1.2.6-2_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libdrm-radeon1_2.4.46-1ubuntu0.0.0.1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-date-time1.48.0_1.48.0-3_amd64.deb  
dogecoin-qt-1.5-ubuntu-12.04-Live-Install/dogecoin-master-1.5.zip

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libx11-dev_2%3a1.4.99.1-0ubuntu2.2_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-dev_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-opengl-dev_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libdrm-nouveau2_2.4.46-1ubuntu0.0.0.1_amd64.deb  
dogecoin-qt-1.5-ubuntu-12.04-Live-Install/j

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libpthread-stubs0-dev_0.3-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libglu1-mesa-dev_8.0.4-0ubuntu0.7_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libdrm-nouveau1a_2.4.46-1ubuntu0.0.0.1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libstdc++6-4.4-dev_4.4.7-1ubuntu2_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/dpkg-dev_1.16.1.2ubuntu7.2_all.deb  
dogecoin-qt-1.5-ubuntu-12.04-Live-Install/install.sh

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libdb5.1++_5.1.25-11build1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqtwebkit4_2.2.1-1ubuntu4_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-network_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libalgorithm-diff-xs-perl_0.04-2build2_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-help_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-thread1.48-dev_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/build-essential_11.5ubuntu2.1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-test_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-sql-sqlite_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libssl-doc_1.0.1-4ubuntu5.11_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/qdbus_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-chrono1.48.0_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libxdmcp-dev_1%3a1.1.0-4_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/g++_4%3a4.6.3-1ubuntu5_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-serialization1.48-dev_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-filesystem1.48.0_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost1.48-dev_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-chrono1.48-dev_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-program-options1.48.0_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libdpkg-perl_1.16.1.2ubuntu7.2_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libminiupnpc-dev_1.6-3ubuntu1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-xmlpatterns_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libssl-dev_1.0.1-4ubuntu5.11_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-dbus_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-thread1.48.0_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-declarative_4%3a4.8.1-0ubuntu4.6_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libalgorithm-diff-perl_1.19.02-2_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/gcc-4.4-base_4.4.7-1ubuntu2_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/xorg-sgml-doctools_1%3a1.10-1_all.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libdb5.1-dev_5.1.25-11build1_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libboost-program-options1.48-dev_1.48.0-3_amd64.deb

dogecoin-qt-1.5-ubuntu-12.04-Live-Install/libqt4-opengl_4%3a4.8.1-0ubuntu4.6_amd64.deb  
[shibe@ubuntu mnt]$ cd dogecoin-qt-1.5-ubuntu-12.04-Live-Install  
[shibe@ubuntu dogecoin-qt-1.5-ubuntu-12.04-Live-Install]$
./install.sh  
First step to the moon in(much time needed)  
3  
2  
1  
##Lots of stuff.. This will take a while.

Here is the install.sh script to install the deps, extract and compile the source code for dogecoin-qt.

[shibe@ubuntu dogecoin-qt-1.5-ubuntu-12.04-Live-Install]$ cat
install.sh

#!/bin/sh

#Check jpyth.com or github.com/jpyth for any updates should dogecoin-qt
have a newer version! To the moon!

echo "First step to the moon in(much time needed)"  
echo "3"  
sleep 1  
echo "2"  
sleep 1  
echo "1"  
sleep 1  
dpkg -i *deb && {  
echo "Files need"  
unzip dogecoin-master-1.5.zip && {  
cd dogecoin-master-1.5 && {  
echo "funny make"  
ls  
qmake && {  
echo "make time"  
ls  
make && {  
echo "Much Finish, 'cd dogecoin-master-1.5; ./dogecoin-qt' to run
dogecoin! To the moon!"  
} || {  
echo "Fail much make, much sad. Report logs above."  
}  
} || {  
echo "Fail much qmake, much sad. Report. "  
}  
} || {  
echo "Moving too hard"  
}  
} || {  
echo "Much weird, dogecoin-master-1.5.zip much sad"  
}  
} || {  
echo "dpkg no like, find a shibe to help with errors above!"  
}  
[shibe@ubuntu dogecoin-qt-1.5-ubuntu-12.04-Live-Install]$

Nothing special, just going through each step and checking return code on the prior step. Hopefully most of those error messages are never seen by anyone.

If you find any deps that are missing, or know of ones I can remove please let me know. I'll write up information about creating the live CD, other steps, and dogecoin in general...but wanted to share this as I promised it on reddit.

To the moon!

Doge: D8kWKgF2x6gsiZzRyXgonogPQuRMxf6qtp

more ...

NS2 Dedicated Server - Linux

Natural Selection 2 released both client and server version for Linux this week. Up till now you've had to use wine to host NS2 on Linux, now you can use Linux. This assumes you are already familiar with steamcmd, and have it working. Using Fedora below.

You have to use appId ~~4920 instead o~~f 4940. -- 4940 appId is now working.

#Had an issue with finding 32 bit libspeex libraries. I ended up
installing the below two rpms which resolved the dep issue. I also had
to install gtk2.  
[jpyth@jpyth ns2]$ ls *rpm  
libspeex1-32bit-1.1.999_1.2rc1-9.1.x86_64.rpm  
libspeexdsp1-32bit-1.1.999_1.2rc1-35.7.x86_64.rpm  
[jpyth@jpyth ns2]$

[jpyth@jpyth steamcmd]$ ./steamcmd.sh +login LOGIN PASSWORD
+force_install_dir PATH +app_update 4940 validate  
#example -- Installs Natural Selection 2, into a directory 'ns2' one
directory up from my current path.  
[jpyth@jpyth steamcmd]$ ./steamcmd.sh +login myrealemail@hotmail.com
noway01 +force_install_dir ../ns2/ +app_update 4940 validate  
#Start the game:  
[jpyth@jpyth steamcmd]$ cd ../ns2  
#start server  
[jpyth@jpyth ns2]$ ./server_linux32 -ip 198.27.65.132 -port 27035
-map ns2_tram -name "jpyth.com|NS2|#1" -limit 24 -console
-config_path ./config

#I launch mine with screen, using this script:  
[jpyth@jpyth bin]$ cat ns2  
#!/bin/sh  
name="$1"  
port=$2  
cd /home/jpyth/ns2  
screen -d -m -S ns2 ./server_linux32 -ip 198.27.65.132 -port $port
-map ns2_tram -name "$name" -limit 24 -console -config_path ./config  
#example  
[jpyth@jpyth bin]$ ns2 "jpyth.com|NS2|#1" 27030  
[jpyth@jpyth bin]$

Currently hosting two NS2 servers. Can find them below:
One
Two

more ...

Wireshark Fun

Quick and dirty way to configure a wireless router(Airport Express), to use your linux pc as a network gateway. I needed to sniff the network of some wireless devices, which can be quite handy.

You'll need to do a few things:
1.) Enable IP Forwarding
2.) Configure iptables to nat/forward traffic from in one interface and out another
3.) Bridge the device, and use dhcpd to handle dhcp for the devices(Much easier to track)

Enable IP Forwarding:

echo 1 > /proc/sys/net/ipv4/ip_forward

Configure iptables(as root):

#Interface you are sending traffic out(eth0)  
#Going out usb-ethernet  
iptables --table nat --append POSTROUTING --out-interface eth0 -j
MASQUERADE  
#Going out my wireless  
iptables --table nat --append POSTROUTING --out-interface wlp8s0 -j
MASQUERADE

#Interface you are forwarding traffic from(Airport hooked to this
interface)  
iptables --append FORWARD --in-interface enp7s0 -j ACCEPT

Configure dhcpd4 to hand out dhcpcd on enp7s0

#Replace xxx IP with valid dns servers.  
[jmorgan@arch-dopey ~]$ cat /etc/dhcpd.conf  
option domain-name "arch-dopey.com";  
option domain-name-servers xxx.xxx.xxx, xxx.xxx.xxx;  
default-lease-time 14440;  
ddns-update-style none;  
deny bootp; shared-network airport {  
subnet 10.0.0.0 netmask 255.255.255.0 {  
option routers 10.0.0.1;  
option subnet-mask 255.255.255.0;  
pool { range 10.0.0.10 10.0.0.20; }  
}  
}  
#start dhcpd4  
[jmorgan@arch-dopey ~]$ sudo systemctl start dhcpd4

Launch wireshark, and watch traffic from the interface you are forwarding from(enp7s0 for me).

Enjoy

more ...

Client/Server Python Scripts

I started this site with the intent to do a weekly post, however I've found myself in Sweden for the past 8+ weeks for work.(There are worse places to spend your summer;). Sorry for lack of updates;x

There are 1000 different ways to triage network issues, here is one tool. A simple python server listening on a particular port, and printing out the details of what the client sent and a client to send said datas.

Server:

[jmorgan@arch-dopey ~]$ cat server.py  
#!/usr/bin/python2

import socket  
from datetime import datetime

s = socket.socket()  
host = socket.gethostname()  
port = 1337  
s.bind((host, port))

s.listen(5)  
while True:  
c, addr = s.accept()  
sockS= c.recv(3000).strip('\n')  
if sockS:  
logF = open('rLog', 'a')  
dt= str(datetime.now())  
wee="%s %s \n" % (sockS, dt)  
logF.write(wee)  
logF.close()  
sockS=None  
c.close()

Client:

[jmorgan@arch-dopey ~]$ cat tcpSend.py  
#!/usr/bin/python2  
import sys  
import socket  
from datetime import datetime  
ip = sys.argv[1]  
port = int(sys.argv[2])  
mCount = int(sys.argv[3])  
print "%s:%s %s packets" % (ip, port,mCount)  
count=0  
while count \<= mCount:  
logF = open('sLog', 'a')  
dt= str(datetime.now())  
msg="%s %s" % (str(count), dt)  
try:  
sock = socket.socket(socket.AF_INET, # Internet  
socket.SOCK_STREAM)  
sock.connect((ip, port))  
sock.sendto(msg, (ip, port))  
logF.write("Success: %s\n" % (msg))  
sock.close()  
except:  
dtE= str(datetime.now())  
logF.write("Fail:%s Start: %s End: %s\n" % (str(count), dt, dtE))  
count +=1  
logF.close()  
[jmorgan@arch-dopey ~]$

Usage:

#One terminal  
[jmorgan@arch-dopey ~]$ sudo ./server.py  
#Another terminal  
[jmorgan@arch-dopey ~]$ ./tcpSend.py localhost 1337 3  
localhost:1337 3 packets  
[jmorgan@arch-dopey ~]$ cat sLog  
Success: 0 2013-07-22 21:17:12.124353  
Success: 1 2013-07-22 21:17:12.124862  
Success: 2 2013-07-22 21:17:12.125124  
Success: 3 2013-07-22 21:17:12.125321  
[jmorgan@arch-dopey ~]$ cat rLog  
0 2013-07-22 21:17:12.124353 2013-07-22 21:17:12.124854  
1 2013-07-22 21:17:12.124862 2013-07-22 21:17:12.125148  
2 2013-07-22 21:17:12.125124 2013-07-22 21:17:12.125335  
3 2013-07-22 21:17:12.125321 2013-07-22 21:17:12.125485  
[jmorgan@arch-dopey ~]$

The client sends the timestamp when it sends the packet, and the server prints that along with when it received the packet. Works well to compare latency, dropped packets, etc over a network. Nothing fancy, just a quick and dirty script written under fire to triage an issue. In my situation, I would have the VIP quit responding at times so the Fail line let me know how often that happened for say 10,000 or 100,000 packets, as well the amount of time it took to send that number of packets between zones.

more ...

Raspberry Pi Project

I saw this reddit post. I've wanted to try to do some type of project with my Raspberry Pi, and the idea of tech+home/stuff has always intrigued me.

The current plan is a standing desk, or perhaps a coffee table.. but for now, I've ordered the following bits to let me work on the tech bit. If I master control of the LEDs, i'll figure out something to put it in.

Parts so far(Already had a Pi/SD Card, just never used it):
LED Lights
USB WiFi
Case
Wires
More Wires

I think these bits should let me get the wires going. Still deciding on a power supply solution long-term, but I have things I can use interim for testing.

Code wise, The current plan is run Arch-ARM(Already installed) with python to control the LEDs, and tie into my onConnect project for changing the lights depending on state changes monitored by onConnect.

Should be fun:D

more ...

Spell Check

Simple, but I'm sure many people go around running Arch(and other distros) without spell check when using firefox/webmail/etc. Simple to fix, if you know.

I use hunspell, so I installed the English dictionary to go along with it.

[jmorgan@arch-jm ~]$ sudo pacman -S hunspell-en  
resolving dependencies...  
looking for inter-conflicts...

Packages (1): hunspell-en-7.1-2

Total Download Size: 0.36 MiB  
Total Installed Size: 1.65 MiB

:: Proceed with installation? [Y/n] y  
:: Retrieving packages ...  
hunspell-en-7.1-2-any 364.8 KiB 443K/s 00:01
[######################] 100%  
(1/1) checking keys in keyring
[######################] 100%  
(1/1) checking package integrity
[######################] 100%  
(1/1) loading package files
[######################] 100%  
(1/1) checking for file conflicts
[######################] 100%  
(1/1) checking available disk space
[######################] 100%  
(1/1) installing hunspell-en
[######################] 100%  
Optional dependencies for hunspell-en  
hunspell: the spell checking libraries and apps [installed]  
[jmorgan@arch-jm ~]$
more ...

onConnect updated to handle additional trigger.

I expanded onConnect, you can check out the current version here. I plan to add more triggers, but for now I've added a File trigger.

The configuration file now supports a 'File:$name' section, that you then define a fine to monitor, expected contents of the file, and whether you want to run a command when that file does or does not match the expected value. Only acting when the value changes, though.

But why you might ask? Well, after reading Bumblebee on Arch Wiki I wanted to toggle Nvidia vs Intel on my XPS 15 whenever I moved to/from battery or A/C power. I was initially going to hardcode onConnect to handle this, but that seemed limiting.

Instead I have a framework for other triggers, and simply had to point onConnect to monitor /sys/class/power_supply/ACAD/online file which will change depending on my power source.

Here it is changing from AC power to battery, you can also see the increase in battery time using acpi.

#Unplugging the power cable  
DEBUG:root:State changed for File:onACPower  
DEBUG:root:New state matches configuration File:onACPower, running
actionFalse Cmd echo OFF > /proc/acpi/bbswitch  
DEBUG:root:Found File:onBatteryPower  
DEBUG:root:Loading Configuration for File:onBatteryPower  
DEBUG:root:Looking up prior state for File:onBatteryPower  
DEBUG:root:Prior state for File:onBatteryPower is 1  
DEBUG:root:State changed for File:onBatteryPower  
DEBUG:root:New state matches configuration File:onBatteryPower, running
actionTrue Cmd echo OFF > /proc/acpi/bbswitch  
#watching acpi/bbswitch status in another window. Before/After the
configuration change above  
#plugged in AC power with bbswitch 'ON'  
[jpyth@arch-jpyth jpyth]# cat /proc/acpi/bbswitch ; acpi  
0000:01:00.0 ON  
Battery 0: Unknown, 99%  
#unplugged, before the next run occured(13 second window).  
[jpyth@arch-jpyth jpyth]# cat /proc/acpi/bbswitch ; acpi  
0000:01:00.0 ON  
Battery 0: Discharging, 96%, 02:19:09 remaining  
#after the above run competes. bbswitch is 'OFF', and battery time
increased.  
[jpyth@arch-jpyth jpyth]# cat /proc/acpi/bbswitch ; acpi  
0000:01:00.0 OFF  
Battery 0: Discharging, 96%, 03:37:31 remaining  
#behaves exactly as expected when plugging power back in. The above is
a set of redundant configs, only to show the True/False case possible
with the configuration. I'd normally only have one.

I can now tie in the g13 daemon quite easily, and monitor the log file for error to stop the daemon upon disconnect and also start the daemon when the device is connected automatically.

more ...

Logitech g13 on Linux (Arch)

I've gamed on Linux for a few years, and about a year ago I picked up a Logitech G13. I've used the g13-git package from AUR without issue.

I remember information about g13 on Linux being a bit sparse/out-of-date when I first did it on my desktop, now that I'm doing it on my laptop I thought i'd share the steps/issues I encounter.

If you aren't running Arch, here is a link to the github g13 on Linux github project. The rest of this doc will assume you are running Arch Linux, but should help any Linux user.

Obtaining g13-git from AUR, building, and installing:

#get the .tar.gz from AUR && extract && cd $tar  
[jpyth@arch-jpyth aur]$ wget
https://aur.archlinux.org/packages/g1/g13-git/g13-git.tar.gz  
--2013-04-01 05:06:04--
https://aur.archlinux.org/packages/g1/g13-git/g13-git.tar.gz  
Resolving aur.archlinux.org (aur.archlinux.org)... 78.46.78.247,
2a01:4f8:120:34c2::2  
Connecting to aur.archlinux.org
(aur.archlinux.org)|78.46.78.247|:443... connected.  
HTTP request sent, awaiting response... 200 OK  
Length: 694 [application/x-gzip]  
Saving to: ‘g13-git.tar.gz’

100%[=========================================================================================================================================================================>]
694 --.-K/s in 0s

2013-04-01 05:06:05 (99.8 MB/s) - ‘g13-git.tar.gz’ saved [694/694]

[jpyth@arch-jpyth aur]$ tar -xvf g13-git.tar.gz  
g13-git/  
g13-git/PKGBUILD  
[jpyth@arch-jpyth aur]$ cd g13-git  
#makepkg  
[jpyth@arch-jpyth g13-git]$ makepkg  
==> Determining latest git revision...  
-> Version found: 20130401  
==> Making package: g13-git 20130401-1 (Mon Apr 1 05:06:13 PDT 2013)  
==> Checking runtime dependencies...  
==> Checking buildtime dependencies...  
==> Retrieving Sources...  
==> Extracting Sources...  
==> Starting build()...  
==> Connecting to GIT server....  
Cloning into 'g13'...  
remote: Counting objects: 61, done.  
remote: Compressing objects: 100% (58/58), done.  
remote: Total 61 (delta 26), reused 28 (delta 2)  
Unpacking objects: 100% (61/61), done.  
==> GIT checkout done or server timeout  
==> Starting make...  
Cloning into '/home/jpyth/aur/g13-git/src/g13-build'...  
done.  
g++ -o g13 -std=c++0x g13.cc -lusb-1.0  
g13.cc:4:34: fatal error: boost/lexical_cast.hpp: No such file or
directory  
compilation terminated.  
#This looks bad  
make: *** [g13] Error 1  
==> ERROR: A failure occurred in build().  
Aborting...  
[jpyth@arch-jpyth g13-git]$  
#Install boost to fix error -- The AUR package needs to be updated for
the dependency.  
[jpyth@arch-jpyth ~]$ pacman -S boost boost-libs  
#Much better /cheer  
[jpyth@arch-jpyth g13-git]$ makepkg  
==> Determining latest git revision...  
-> Version found: 20130401  
==> Making package: g13-git 20130401-1 (Mon Apr 1 05:11:45 PDT 2013)  
==> Checking runtime dependencies...  
==> Checking buildtime dependencies...  
==> Retrieving Sources...  
==> Extracting Sources...  
==> Starting build()...  
==> Connecting to GIT server....  
Cloning into 'g13'...  
remote: Counting objects: 61, done.  
remote: Compressing objects: 100% (58/58), done.  
remote: Total 61 (delta 26), reused 28 (delta 2)  
Unpacking objects: 100% (61/61), done.  
==> GIT checkout done or server timeout  
==> Starting make...  
Cloning into '/home/jpyth/aur/g13-git/src/g13-build'...  
done.  
g++ -o g13 -std=c++0x g13.cc -lusb-1.0  
g++ -o pbm2lpbm pbm2lpbm.c  
==> Entering fakeroot environment...  
==> Starting package()...  
==> Tidying install...  
-> Purging unwanted files...  
-> Compressing man and info pages...  
-> Stripping unneeded symbols from binaries and libraries...  
==> Creating package...  
-> Generating .PKGINFO file...  
-> Compressing package...  
==> Leaving fakeroot environment.  
==> Finished making: g13-git 20130401-1 (Mon Apr 1 05:11:51 PDT 2013)  
#Install your shiny new package:D  
[jpyth@arch-jpyth g13-git]$ sudo pacman -U
g13-git-20130401-1-x86_64.pkg.tar.xz

The configuration is detailed on the github project page here.In short to get working, you need a file with mappings from G13 to 'known' keys that you dump into a pipe(/tmp/g13-0) one way or another, the daemon will read from when started. When you start the daemon the available g13 keys and available system keys to map to are printed to stdout. An easy way to do this is a file with the binds that you simply cat into the pipe.

#start g13 daemon without a g13 connected - notice the known G13 keys,
and available keys to map.  
[jpyth@arch-jpyth jmorgan]# /usr/bin/g13  
Known keys on G13:  
BD DOWN G1 G10 G11 G12 G13 G14 G15 G16 G17 G18 G19 G2 G20 G21 G22 G3 G4
G5 G6 G7 G8 G9 L1 L2 L3 L4 LEFT LIGHT LIGHT_STATE M1 M2 M3 MR TOP
STICK_LEFT STICK_RIGHT STICK_UP STICK_DOWN  
Known keys to map to:  
KEY_0 KEY_1 KEY_2 KEY_3 KEY_4 KEY_5 KEY_6 KEY_7 KEY_8 KEY_9
KEY_A KEY_APOSTROPHE KEY_B KEY_BACKSLASH KEY_BACKSPACE KEY_C
KEY_CAPSLOCK KEY_COMMA KEY_D KEY_DELETE KEY_DOT KEY_DOWN KEY_E
KEY_END KEY_ENTER KEY_EQUAL KEY_ESC KEY_F KEY_F1 KEY_F10 KEY_F2
KEY_F3 KEY_F4 KEY_F5 KEY_F6 KEY_F7 KEY_F8 KEY_F9 KEY_G
KEY_GRAVE KEY_H KEY_HOME KEY_I KEY_INSERT KEY_J KEY_K KEY_KP0
KEY_KP1 KEY_KP2 KEY_KP3 KEY_KP4 KEY_KP5 KEY_KP6 KEY_KP7 KEY_KP8
KEY_KP9 KEY_KPASTERISK KEY_KPDOT KEY_KPMINUS KEY_KPPLUS KEY_L
KEY_LEFT KEY_LEFTALT KEY_LEFTBRACE KEY_LEFTCTRL KEY_LEFTSHIFT
KEY_M KEY_MINUS KEY_N KEY_NUMLOCK KEY_O KEY_P KEY_PAGEDOWN
KEY_PAGEUP KEY_Q KEY_R KEY_RIGHT KEY_RIGHTALT KEY_RIGHTBRACE
KEY_RIGHTCTRL KEY_RIGHTSHIFT KEY_S KEY_SCROLLLOCK KEY_SEMICOLON
KEY_SLASH KEY_SPACE KEY_T KEY_TAB KEY_U KEY_UP KEY_V KEY_W
KEY_X KEY_Y KEY_Z  
Found 0 G13s

I use one mapping for all games, but you could have different binds per game. Here is mine:
:::bash

bind $g13Key $mappedKey

[jpyth@arch-jpyth ~]$ cat wowBinds
bind G1 KEY_7
bind G2 KEY_8
bind G3 KEY_9
bind G4 KEY_0
bind G5 KEY_KPMINUS
bind G6 KEY_Q
bind G7 KEY_E
bind G8 KEY_TAB
bind G9 KEY_1
bind G10 KEY_2
bind G11 KEY_3
bind G12 KEY_4
bind G13 KEY_5
bind G14 KEY_6
bind G15 KEY_LEFTSHIFT
bind G16 KEY_R
bind G17 KEY_T
bind G18 KEY_Y
bind G19 KEY_F
bind G20 KEY_LEFTALT
bind G21 KEY_C
bind G22 KEY_V
bind L4 KEY_B
bind L3 KEY_M
bind MR KEY_F6
bind M3 KEY_F5
bind M2 KEY_F4
bind M1 KEY_F3
bind LEFT KEY_RIGHTBRACE
bind DOWN KEY_SPACE
bind STICK_LEFT KEY_A
bind STICK_RIGHT KEY_D
bind STICK_UP KEY_W
bind STICK_DOWN KEY_S
[jpyth@arch-jpyth ~]$

Confirming it works with a g13 attached

#cat bind file into g13-0 pipe, which will be loaded when the g13
daemon start.  
[jpyth@arch-jpyth jmorgan]# cat wowBinds > /tmp/g13-0  
#start with g13 connected  
[jpyth@arch-jpythg jpyth]# /usr/bin/g13  
Known keys on G13:  
BD DOWN G1 G10 G11 G12 G13 G14 G15 G16 G17 G18 G19 G2 G20 G21 G22 G3 G4
G5 G6 G7 G8 G9 L1 L2 L3 L4 LEFT LIGHT LIGHT_STATE M1 M2 M3 MR TOP
STICK_LEFT STICK_RIGHT STICK_UP STICK_DOWN  
Known keys to map to:  
KEY_0 KEY_1 KEY_2 KEY_3 KEY_4 KEY_5 KEY_6 KEY_7 KEY_8 KEY_9
KEY_A KEY_APOSTROPHE KEY_B KEY_BACKSLASH KEY_BACKSPACE KEY_C
KEY_CAPSLOCK KEY_COMMA KEY_D KEY_DELETE KEY_DOT KEY_DOWN KEY_E
KEY_END KEY_ENTER KEY_EQUAL KEY_ESC KEY_F KEY_F1 KEY_F10 KEY_F2
KEY_F3 KEY_F4 KEY_F5 KEY_F6 KEY_F7 KEY_F8 KEY_F9 KEY_G
KEY_GRAVE KEY_H KEY_HOME KEY_I KEY_INSERT KEY_J KEY_K KEY_KP0
KEY_KP1 KEY_KP2 KEY_KP3 KEY_KP4 KEY_KP5 KEY_KP6 KEY_KP7 KEY_KP8
KEY_KP9 KEY_KPASTERISK KEY_KPDOT KEY_KPMINUS KEY_KPPLUS KEY_L
KEY_LEFT KEY_LEFTALT KEY_LEFTBRACE KEY_LEFTCTRL KEY_LEFTSHIFT
KEY_M KEY_MINUS KEY_N KEY_NUMLOCK KEY_O KEY_P KEY_PAGEDOWN
KEY_PAGEUP KEY_Q KEY_R KEY_RIGHT KEY_RIGHTALT KEY_RIGHTBRACE
KEY_RIGHTCTRL KEY_RIGHTSHIFT KEY_S KEY_SCROLLLOCK KEY_SEMICOLON
KEY_SLASH KEY_SPACE KEY_T KEY_TAB KEY_U KEY_UP KEY_V KEY_W
KEY_X KEY_Y KEY_Z  
Kernel driver detached  
Found 1 G13s  
command: bind G1 KEY_7  
command: bind G2 KEY_8  
command: bind G3 KEY_9  
command: bind G4 KEY_0  
command: bind G5 KEY_KPMINUS  
command: bind G6 KEY_Q  
command: bind G7 KEY_E  
command: bind G8 KEY_TAB  
command: bind G9 KEY_1  
command: bind G10 KEY_2  
command: bind G11 KEY_3  
command: bind G12 KEY_4  
command: bind G13 KEY_5  
command: bind G14 KEY_6  
command: bind G15 KEY_LEFTSHIFT  
command: bind G16 KEY_R  
command: bind G17 KEY_T  
command: bind G18 KEY_Y  
command: bind G19 KEY_F  
command: bind G20 KEY_LEFTALT  
command: bind G21 KEY_C  
command: bind G22 KEY_V  
command: bind L4 KEY_B  
command: bind L3 KEY_M  
command: bind MR KEY_F6  
command: bind M3 KEY_F5  
command: bind M2 KEY_F4  
command: bind M1 KEY_F3  
command: bind LEFT KEY_RIGHTBRACE  
command: bind DOWN KEY_SPACE  
command: bind STICK_LEFT KEY_A  
command: bind STICK_RIGHT KEY_D  
command: bind STICK_UP KEY_W  
command: bind STICK_DOWN KEY_S

At this point, you should have a working gamepad. If you do not map any keys by default all keys are mapped to 'a', I noticed the daemon would crash if left this way after a period of time. My assumption at the time(year+ ago) was due to having too many(or just >1) key mapped to the same. I never investigated/tested though, instead I started dumping my binds into the pipe before starting the daemon and the issue went away entirely. I haven't had an issue since(over a year). The only time the gamepad does not function is if I forget to start the daemon after a power cycle, or disconnect/reconnect the device.

Here is the current script I run after each time I restart my computer:

[jpyth@arch-jm ~]$ cat startG13.sh  
#!/bin/bash

ps aux | grep g13 | grep -v grep &>/dev/null && echo "Already running-
Exiting"|| {  
cat /home/jpyth/g13/wowBinds > /tmp/g13-0  
nohup /usr/bin/g13 &  
rm nohup.out  
}

Pretty crude, I know. I started to add it as a systemd process, but there is currently a bug in the daemon. If you disconnect the g13 the daemon goes into a tight loop failing to find the device. This will consume process, and will have to be restarted once the device is reconnected anyway. I didn't want to write a wrapper to babysit the daemon....I have another plan for it by adding a bit more to onConnect, when I get that working i'll share;).

more ...

onConnect Monitor/Adjust System Configuration Based on Network

I initially just wanted to adjust my sound depending on whether I was at work, or at home on my laptop. I decided to try and write something I could plug additional things into over time, to automate any task I normally do when moving between known networks.

This is also the first time I've shared something I wrote on github. I'm sure I broke every rule in the book on best practices, as I am self taught/not a developer. Feel free to check it out though, OnConnect GitHub. I welcome any feedback.:)

I'm not sure I like using the MAC for this, I debated using ESSID and may very well go back to that. I don't like the case of finding more than one MAC that might have a config found(work), but I also wanted to read/parse from a file though not a command+stdout parsing. I couldn't find a reliable method for obtaining the ESSID from a file, yet.

Some example of it working, for me atleast:)
:::bash
#no network, no macs found, default config
[jpyth@arch-jpyth ~]$ ip addr | grep -A1 wlp8s0
3: wlp8s0: \ mtu 1500 qdisc mq state DOWN qlen 1000
link/ether c4:85:08:fc:91:85 brd ff:ff:ff:ff:ff:ff
[jpyth@arch-jpyth ~]$
[jpyth@arch-jpyth ~]$ sudo systemctl status onConnect
onConnect.service - onConnect
Loaded: loaded (/usr/lib/systemd/system/onConnect.service; enabled)
Active: active (running) since Fri 2013-03-29 10:29:42 PDT; 2s ago
Process: 7886 ExecStop=/usr/lib/systemd/scripts/onConnectStop (code=killed, signal=TERM)
Process: 7898 ExecStart=/usr/lib/systemd/scripts/onConnectStart (code=exited, status=0/SUCCESS)
Main PID: 7905 (onConnect)
CGroup: name=systemd:/system/onConnect.service
└─7905 /usr/bin/python2 /usr/bin/onConnect

Mar 29 10:29:42 arch-jpyth systemd[1]: Starting onConnect...  
Mar 29 10:29:42 arch-jpyth systemd[1]: Started onConnect.  
[jpyth@arch-jpyth ~]$ tail /var/log/onConnect/onConnect.log  
INFO:root:Config found for Default  
DEBUG:root:\<function doVolume at 0x7fd4c1dd30c8>  
INFO:root:command amixer cset iface=MIXER,name='Master Playback Volume'
60% for Default  
DEBUG:root:\<function doVpn at 0x7fd4c1dd3140>  
INFO:root:command systemctl stop vpn for Default  
[jpyth@arch-jpyth ~]$  
#vpn being stopped:  
[jpyth@arch-jpyth ~]$ sudo systemctl status vpn  
vpn.service - OpenVpn For Work  
Loaded: loaded (/usr/lib/systemd/system/vpn.service; disabled)  
Active: inactive (dead)

Mar 29 10:29:42 arch-jpyth systemd[1]: Stopping OpenVpn For Work...  
Mar 29 10:29:43 arch-jpyth systemd[1]: Stopped OpenVpn For Work.  
[jpyth@arch-jpyth ~]$

#Now starting/joining wireless network  
[jpyth@arch-jpyth ~]$ sudo systemctl start wireless  
[jpyth@arch-jpyth ~]$ systemctl status wireless  
wireless.service - Wireless  
Loaded: loaded (/usr/lib/systemd/system/wireless.service; enabled)  
Active: active (running) since Fri 2013-03-29 10:34:37 PDT; 5s ago  
Process: 7692 ExecStop=/usr/lib/systemd/scripts/wirelessStop
(code=exited, status=0/SUCCESS)  
Process: 7942 ExecStart=/usr/lib/systemd/scripts/wirelessStart
(code=exited, status=0/SUCCESS)  
Main PID: 7948 (wpa_supplicant)  
CGroup: name=systemd:/system/wireless.service  
└─7948 /usr/sbin/wpa_supplicant -f
/var/log/wpa_supplicant/wpa_supplicant.log -B -i wlp8s0
-P/var/run/wireless.pid -c /etc/wpa_supplicant.conf -d  
[jpyth@arch-jpyth ~]$

#onConnect log file  
INFO:root:['FF:FF:FF:FF:FF:FF', 'Default']  
INFO:root:Config found for FF:FF:FF:FF:FF:FF  
['description', 'location', 'volume', 'vpn']  
DEBUG:root:\<function doVolume at 0x7fd4c1dd30c8>  
INFO:root:command amixer cset iface=MIXER,name='Master Playback Volume'
85% for FF:FF:FF:FF:FF:FF  
DEBUG:root:\<function doVpn at 0x7fd4c1dd3140>  
INFO:root:command systemctl start vpn for FF:FF:FF:FF:FF:FF

#vpn started automatically when joined:  
[jpyth@arch-jpyth ~]$ sudo systemctl status vpn  
vpn.service - OpenVpn For Work  
Loaded: loaded (/usr/lib/systemd/system/vpn.service; disabled)  
Active: active (running) since Fri 2013-03-29 10:34:57 PDT; 1min 22s
ago  
Process: 7978 ExecStart=/usr/lib/systemd/scripts/vpnStart (code=exited,
status=0/SUCCESS)  
Main PID: 7986 (screen)  
CGroup: name=systemd:/system/vpn.service

Mar 29 10:34:57 arch-jpyth systemd[1]: Starting OpenVpn For Work...  
Mar 29 10:34:57 arch-jpyth systemd[1]: Started OpenVpn For Work.  
[jpyth@arch-jpyth ~]$

I think it'll do what I need=D

more ...