Thursday, August 30, 2012

Kate Regex Search and Replace

If you are using the Kate text editor and you are going to use parenthesis to capture parts of your regex that you want to reuse (a submatch), the character you have to prepend is \, the backslash. But it isn't the dollar sign or any other character on Kate for Kubuntu Linux anyway.
So if you are wanting to switch wordsomething to somethingword in Kate, your regex will look like this (word)(something) and your replacement will look like this \2\1 to end up with somethingword when it is all done

wordsomething find (word)(something)

replace with \2\1 finishes with something word

Thursday, August 2, 2012

Best value web hosting

I have become a fan of VPS.net . I have been more than happily running a Debian instance of 2 nodes. I am extremely happy with the breadth of control I have over a portion of a server.

Granted, it is a lot more work than other hosts I have used because it is so much like having a raw machine-- but the response and flexibility of the platform is well worth the ~$20 per node and effort each month.

The successes and happiness with the outcomes of incremental efforts have made it so worth it.

We are using fusemail as our email service provider. They are sufficient at $2 per account each month. I would consider other providers.

Thursday, March 29, 2012

Get Column Names Text from MySQL

So, I was using describe table. But, then I found this which helps me reduce the amount of crap I have to pull out while creating a comma delimited list.

select column_name from information_schema.columns where table_name='tablename';

Thursday, March 15, 2012

Recovering a Text File in Linux

 Did I ever tell you how thankful I am that I do most of my writing in a more or less plain text editor?

grep -a -A800 -B800 'obustness' /dev/sda5 | strings > recovered_file



Everyone loves grep
-a says to process binary as text
-A[number] tells grep to include 800 lines after the matching term is found
-B[number] tells grep to include 800 lines before the matching term is found
then of course you will want to supply a term for grep to match against
and finally where you want grep to look /dev/sda5 happens to be my /home partition




Then pipe all that off to strings to be redirected into a file.
The reason you would do that is because it will clean up some of the gobbledygook the -a option of grep will not.

--I figured that Robustness would be a somewhat rare string to search for. And I could make it case insensitive by just leaving off the 'R' (yes, it can be done with switches).

Interesting thing to note, people besides me use the word Robustness. Not as rare as I was hoping.

Friday, January 27, 2012

Default Select Box "Prefilling" to emulate a Choice of the Existing Data

For editing information in my web applications, I prefill what existing data I have in my forms. For text type input tags, it is easy as pie. But, what to do for a select tag. Yeah, fun stuff. Let's get to it.

//$address is just an integer counter that starts at 0 and increments before a new address is pulled from the database.

//So, having said that, let's build the HTML select element where $address makes this chunk of code able to be specifically referenced later on by creating a unique id="state0", id="state1", id="state2", and so on for each address.


<?php

echo "<div>State:<select id=\"state" . $address . "\" name=\"UTstate\">\n
<optgroup label=\"U.S. States\">\n
<option value=\"IN\">Indiana</option>\n
<option value=\"MI\">Michigan</option>\n
<option value=\"NY\">New York</option>\n
<option value=\"OH\">Ohio</option>\n
<option value=\"PA\">Pennsylvania</option>\n
<option value=\"TN\">Tennessee</option>\n
<option value=\"VA\">Virginia</option>\n
<option value=\"WV\">West Virginia</option>\n
</optgroup>\n
</select>\n";

//There we have it. But now to make things easier for editing let's make the default value the same as what had been in the database using jQuery magic.

echo "<script>$('#state" . $address . " option[value=" . $row2['state'] . "]').attr('selected', 'selected');</script>";

?>

//This short chunk of jQuery JavaScript selects the corresponding state0, state1, or state2 and so on which should be the preceeding address state select block. It searches for the $row2['state'] database information within the option group tags. When it finds a match, it modifies the selected attribute of the tag to be set to selected.



Can we just show the HTML? Please?

Sure, hold on to your biscuits.




//This is what we start off with. All of the PHP code has done it's thing, this has become raw HTML code. Note that database read resulted in OH and we pumped OH into the jQuery JavaScript as you will soon see.

State:<select id="state0" name="UTstate">
<optgroup label="U.S. States">
<option value="IN">Indiana</option>
<option value="MI">Michigan</option>
<option value="NY">New York</option>
<option value="OH">Ohio</option>
<option value="TN">Tennessee</option>
<option value="VA">Virginia</option>
<option value="WV">West Virginia</option>
</optgroup>
</select>

//Then as I said we hit the short chunk of jQuery JavaScript. The OH was read from the database as mentioned earlier telling the browser which option tag identified by it's value to modify contained within the state0 select tag.

<script>$('#state0 option[value=OH]').attr('selected', 'selected');</script>

//The DOM gets modified and now the <otion value="OH">Ohio</option> tag has been modified as far as the user can see and the browser is keeping track of. It now looks and acts as so...

State:<select id="state0" name="UTstate">
<optgroup label="U.S. States">
<option value="IN">Indiana</option>
<option value="MI">Michigan</option>
<option value="NY">New York</option>
<option value="OH" selected="selected">Ohio</option>
<option value="TN">Tennessee</option>
<option value="VA">Virginia</option>
<option value="WV">West Virginia</option>
</optgroup>
</select>

Yaay!

This is for examples where only one selection is expected, for select boxes that allow multiple selections the code will be somewhat different but a similar method can be used.

Friday, January 6, 2012

WinSCP

WinSCP has a sync function in it that allows connection to a SFTP server that mirrors a local directory and/or a remote directory.

I have been using and recommending Filezilla which currently does not have that feature despite being great and free. I have many choices for how I wish to keep my files stored redundantly and Filezilla works with most of the Operating Systems I use, so I will continue to use it.

The thing that WinSCP does for me is that it allows me to not need Samba on my file servers.

Friday, December 23, 2011

A Unicode Post That Is More for Me Than You

I try to use the more world friendly UTF-8 encoding. However, in MySQL a choice generally has to be made between two leading UTF candidate encodings.

From the MySQL Documentation

For any Unicode character set, operations performed using the _general_ci collation are faster than those for the _unicode_ci collation. For example, comparisons for the utf8_general_ci collation are faster, but slightly less correct, than comparisons for utf8_unicode_ci. The reason for this is that utf8_unicode_ci supports mappings such as expansions; that is, when one character compares as equal to combinations of other characters. For example, in German and some other languages “ß” is equal to “ss”. utf8_unicode_ci also supports contractions and ignorable characters. utf8_general_ci is a legacy collation that does not support expansions, contractions, or ignorable characters. It can make only one-to-one comparisons between characters.
 In a nutshell--

UTF-8 General is usually faster because it does not factor into any cases where two glyphs or glyph combinations that are equivalent via the encoding. Either the glyph is what it is or it isn't with a one to one relationship. This is the default UTF-8 encoding.

UTF-8 Unicode does facilitate how language is actually used and operates on more complicated conventions. It is the newer, more correct implementation at the cost of frugal resource usage.

Saturday, December 17, 2011

DOSBox Key Commands I Care About


Just the ones I want to use and need on an infrequent basis.



I am not a fan of old programs. But when it is what needs to be run, that is what is run.

Ctrl+F11 / Ctrl+F12 Reduce / increase the game speed, if it's too fast or too slow.
Alt+Enter Toggle between fullscreen and windowed.
Alt+Pause Pause DOSBox.
Ctrl+F10 Switch mouse control between Windows and DOSBox.

MOUNT [Drive-Letter] [Local-Directory]

Wednesday, October 19, 2011

Firefox Add-ons I Love

Firefox Add-ons I Love

1. LastPass
Used in conjuction with the LastPass on-line password manager service. Free/Premium@$12. Highly recommend them.

2. Firebug
Web development tool.

3. ChatZilla
Feature rich, user friendly in-browser IRC chat client.

4. Lazarus
Lost form data recovery tool. So far very awesome.

5. Down Them All
Works great to pull many files from a web server to a folder on your computer-- initiated directly from the browser.

6. Random Color Tool - Using Rainbow currently
I always install some kind of 'color tool' to help me quickly find out what color that is on the web.

Firefox Add-ons I Would Love to See

A. A Good Torrent Tool
There are two that I know of that are okay. Opera integrates torrenting into it's browser, but I don't really use Opera.

Friday, October 7, 2011

The Problem with TeamViewer (TeamViewer Is Awesome BTW)

The Things I Love About TeamViewer

It is multi-platform. It works on many *nix machines that have an X-Windows GUI. It works on all Windows Machines; Server2008, Win7 Pro, XP Home Edition-- it doesn't care. When other mixed technologies fail, TeamViewer usually works (I have a lot of 'unnecessary' technology in my house.). The same client install serves and acts as a client. You can start a session from your Linux laptop to your wife's Win7 laptop to fix that problem she was having. Later you can use her Win7 laptop to get into your Linux laptop to see if that compile finished. It is the same client. Configuration could be a hair more intuitive, but that is like asking for a revision of the Sistine Chapel. Could it be better, sure. Is it great the way it is, yes. For individual non-commercial use, it is free to use. And do so, it is great. It is the program I use in my home when I don't feel like using CLI. It is the technology I tell my wife and sister to use, their skills are above average-- but that is because most people's technological knowledge is poor. I even think many technologically bereft people could figure out how to use TeamViewer. Tell your friends. (Write about it's awesomeness in a blog maybe.) Nerds, listen up. If you are a Netflix subscriber, you have probably seen the 'You Can't Do That' screen from RDP. TeamViewer works. I regularly control my HTPC connected to my TV with my Android phone-- there is a TeamViewer Android app.

I Thought You Said Something About Problems

I would use the product heavily for SFTP maybe once a month. I would use the product for a few minutes about twice a week to fix some little thing and be done. But, I don't use it for work. I could use it happily instead of RDP, SFTP, CLI over SSH, and remote connection via DDNS like features. If it is so great, why don't you use it? Licensing costs. I want to pay them. I love their product. Licensing is big with me. I want to be legit. I don't want anyone knocking on my door. I am beholden to no-one. Therefore, I use a lot of open source products. Open source is not free. I charge a modest amount of money for each product. Those specific proceeds are donated. I have donated to OpenBSD, the Illumos Foundation, and Debian through SPI. It is important that the projects I like and use get money. Period. They just have so few licensing options, their cheapest option is to pay over $400 per year to rent the software. It is roughly $37 dollars per month. It is harder to give what I feel I can to closed source enterprises, pricing is rigid. What I currently use is free. My other options, (which are sufficient, but not better) are much less expensive. My motivation to use non-free solutions is to simplify my life. Setups and configurations for free solutions take time and effort. I want to do my work, get in and get out. The more time I take, the less money I make on jobs with a fixed cost being billed to the client. Their competitor LogMeIn is good, for the time being that is the product I will use. It is not great like TeamViewer is, but it is less than a third of the price for what I want to do.

Hopes and Dreams

It costs very little for TeamViewer to restructure their product pricing-- or get creative on a case by case basis. I am a raving fan that wants to give them money and I cannot justify giving them what they are asking given my current situation and my infrequent, short lived needs of their product. Their product is an excellent solution to a common problem and most people will like it a lot. If you have room in the budget, I have no qualms with recommending it with all the good I can relay. But, at this time is not at a sufficient price point or with licensing terms that are compatible with the work I do for me to use it.

Had A ZFS Pool with Raw Disk Access Disappear

zpool import POOLNAME


brought it back.

Friday, September 16, 2011

DDNS for OpenIndiana

In this installment, we are going to make up for a short coming in the No-IP service that I otherwise am very happy with.
I am hosting all kinds of machines on a DHCP connection. Shhh....
So I signed up with No-IP which I like very much.
I put a brand new SFTP server in service to replace my somewhat less secure FTP server I only had access to locally.
With all of it's shiny UNIX security, I tried to make it externally accessible-- but was unable with the tools provided by No-IP.
I will be supplementing my primary paid DDNS with No-IP by also using a free DynDNS account.
I plan on keeping No-IP because of their rock solid service that I have noticed 0 issues or problems with in several years.
Depending on how things go, I may also fork some money over to DynDNS.

On to the task at hand.

I chose DynDNS because I have a few friends that use it.

This is important. To avoid getting shut off for abuse while testing solutions, DynDNS has a few dummy accounts that can be used.
http://dyn.com/support/developers/test-account

There is something to be said about the multitude of solutions to a finite set of problems. It took me three tries to get something new to work. Just keep at it, eventually you will get it.

Plan C

Create a heading in your log just for stuff and giggles.

vi /var/log/updatedns.log

DNS Update Log

Write the script that will do the dirty work.

vi /usr/sbin/updatedns.sh


#!/bin/sh

#Get the data that allows for checking that the DNS service has a good IP.
  #I use no-ip for bradchesney.net, which does not facilitate sftp server DDNS services.
  #However, I can us it to see what my current IP is.
  #I leave finding the immediate value of your current external IP to you.
extip=`dig +short bradchesney.net`
  #Then I retrieve what my second DDNS provider thinks my SFTP server's IP is.
sftpserv=`dig +short sftpserv.dyndns.com`
  #Grab the date for simple logging purposes.
thedate=`date`

#Compare the values.
if [ "$extip" = "$sftpserv" ]; then

  #These lines test that the cron service is running the script and the basic logging works.
  #These are debugging lines and should be commented out during normal usage.
  #echo "#######################################################" >> /var/log/updatedns.log
  #echo "$thedate : EXTIP $extip; SFTPSERV $sftpserv -- Debug" >> /var/log/updatedns.log

#If the both IPs match, do nothing.
exit

else

#If they are different, update the IP with cURL and log the update.
  #Create the string to feed to curl
update="https://DYNDNSLOGIN:DYNDNSPASSWORD@members.dyndns.org/nic/update?system=dyndns&hostname=CHOSENDYNDNSHOSTNAME.dyndns.CHOSENDYNDNSTLD&myip=$extip"

  #This is a good debugging test string to avoid getting banned.
  #update="https://test:test@members.dyndns.org/nic/update?system=dyndns&hostname=test.mine.nu&myip=$extip"

#Update via curl and log the output and/or results
echo "#######################################################" >> /var/log/updatedns.log
echo "$thedate : EXTIP $extip; SFTPSERV $sftpserv" >> /var/log/updatedns.log
curl -k $update >> /var/log/updatedns.log > /dev/null
echo -e /r/n

fi


Change the owner, group, and permissions on the script.
chown root:bin /usr/sbin/updatedns.sh
chmod 751 /usr/sbin/updatedns.sh

Setup a cron job for the script.
I have mine set to check that I have a good IP every six minutes.
chrontab -e

Append the following text to run the script every six minutes.

0,6,12,18,24,30,36,42,48,54 * * * * /usr/bin/updatedns.sh

Boom, a somewhat resilient DDNS updater. --I am open to suggestions regarding a better way, but this should work rather well.

(Also, while building the curl command I noticed that I was contacting members.dyndns.org:8245 for ddclient in Plan B. Port 8245 is an unencrypted http port. I have a feeling that if I were to have changed that to port 443 or no port at all, the ddclient script may have worked. Hindsight.)




Plan B -- Failed

ddclient is a perl script that will meet the needs and supports many DDNS service providers.


Download the script.

http://sourceforge.net/projects/ddclient/files/ddclient/ddclient-3.8.1/ddclient-3.8.1.tar.gz/download



Install ddclient.

cp /file/extraction/location/ddclient /usr/sbin
mkdir /etc/ddclient
mkdir /etc/var/cache/ddclient
cp /file/extraction/location/sample-etc_ddclient /etc/ddclient/ddclient.conf


(! I don't know where you extracted the files. You can find / -name ddclient to have your system tell you where you put them.


Configure ddclient

vi /etc/ddclient/ddclient.conf


######################################################################
##
## $Id: sample-etc_ddclient.conf 125 2011-05-19 20:31:20Z wimpunk $
##
## Define default global variables with lines like:
##      var=value [, var=value]*
## These values will be used for each following host unless overridden
## with a local variable definition.
##
## Define local variables for one or more hosts with:
##      var=value [, var=value]* host.and.domain[,host2.and.domain...]
##
## Lines can be continued on the following line by ending the line
## with a \
##
##
## Warning: not all supported routers or dynamic DNS services
##          are mentioned here.
##
######################################################################
daemon=3600
syslog=no
ssl=no
#ssl=yes                                # use ssl-support.
                                        # Works with ssl-library.
fw-login=ROUTERUSERNAME,             fw-password=ROUTERPASSWORD          # FW login and password

## To obtain an IP address from FW status page (using fw-login, fw-password)
use=fw, fw='https://192.168.1.1/Status_Internet.asp', fw-skip='LAN IP' # found after IP Address

## Above is the web address of a page on my router that shows my external IP.
## After that is fw-skip. The visible text immediately after my external IP is LAN IP.
## ddclient must look for that text and then find my external IP relative to it.

login=DYNDNSLOGIN                     # default login
password=DYNDNSPASSWORD               # default password
server=members.dyndns.org:8245  \       # default server (bypassing proxies)

protocol=dyndns2,               \
CHOSENDYNDNSHOSTNAME.dyndns.CHOSENDYNDNSTLD

Install SUNWopenssl, perl510extra, net-ssleay, pmtools, and perl510 from the package manager if not already installed.
They can be easily found by simply searching for perl in the package manager.


Seemingly unavailable from the packages are the IO-Socket-SSL modules for perl.
The following instructions installed the missing files in places ddclient could find them.

The source (that creates the make files via an initial perl script) can be found at:
http://www.cpan.org/modules/by-module/IO/IO-Socket-SSL-1.44.tar.gz

cd /file/extraction/location/
perl Makefile.PL
make
make test
make install

At this point you can begin attempting to update your DDNS information with ddclient.
You can use /usr/sbin/ddclient -daemon=0 -noquiet -debug to get information if things don't go as expected.
Alternatively the truss -a -f /usr/sbin/ddclient -daemon 600 command is very cool at seeing the system calls if needed.


Start the ddclient daemon and keep it started
I am using a cron job in conjunction with a script to monitor whether ddclient is running or not.

vi /usr/bin/ddnsupdate.sh

##########################################
#!/bin/sh

#Check for ddclient.
#If not running, run ddclient.

if ps | grep ddclient > /dev/null
then
    exit
else
    /usr/bin/ddclient
fi
##########################################

Change the owner, group, and permissions on the script.
chown root:bin /usr/sbin/ddnsupdate.sh
chmod 751 /usr/sbin/ddnsupdate.sh

Create the line of code that will make cron run the script.

vi /var/spool/cron/crontabs/root

Append

*/10 * * * * /usr/bin/updateddns.sh

to the end of the file.


Plan A -- Failed

inadyn requires linux files that are not present on an OpenIndiana installation.
inadyn requires linux files that are very difficult to put on an OpenIndiana installation.

Saturday, August 13, 2011

As-Is, Not Everything I Do Works Out As I Had Hoped

So, putting my file server on a VM did not have the outcome I was hoping.

But, I did do a few cool things that may save someone else a few minutes and some hair pulling. So, some of the steps I took access to the raw disks from a VM are provided below as-is. So, my notes are presented unformatted as such below.


My old fileserver with all my most treasured files was highly under utilized. So the plan was to move it to a virtual machine host.
This begged giving a OpenIndiana VM access to raw disks for zpooling (and maybe raid-z when I get better hardware for the house).

I backed up my files and started with empty platters on my spindles.


Step 1 Attach two physical disks to the host machine which become the storage mediums of the upcoming zpool.
no partitions - don't make any or get rid any preexisting

My Debian Host OS recognized the new drives as /dev/sdb & /dev/sdc and we will not mount and/or prevent mounting them.



Everything else will be easiest to accomplish as the root user.

su



brad will be the user VirtualBox will be running under
change the ownership and mode of the device nodes to allow ufettered access by the user running VirtualBox

chown brad /dev/sdb
chown brad /dev/sdc

chmod 775 /dev/sdb
chmod 775 /dev/sdc



Add the user of the VirtualBox process to the disk group

sudo usermod -a -G disk brad



create the .vmdk files

VBoxManage internalcommands createrawvmdk -filename /home/brad/.VirtualBox/a1.vmdk -rawdisk /dev/sdb -relative
VBoxManage internalcommands createrawvmdk -filename /home/brad/.VirtualBox/a2.vmdk -rawdisk /dev/sdc -relative



change the ownership and mode of the pointer files to allow ufettered access by the user running VirtualBox

chown brad /home/brad/.VirtualBox/a1.vmdk
chown brad /home/brad/.VirtualBox/a2.vmdk

chmod 775 /home/brad/.VirtualBox/a1.vmdk
chmod 775 /home/brad/.VirtualBox/a2.vmdk



log out
log in



add the .vmdk files to your virtual machine via the GUI.



Time to boot the VM.

Yeah, that's it. Fire her up. My username within the OpenIndiana VM will also be brad.



Do whatever administrative things you might do with a new machine.

Set the network connection to a fixed IP. Give good users privileges, take privileges away from bad users-- or the other way around if you desire a little more excitement in your life.



Setting up your first zpool is easiest as root. I am choosing to mount my zpool in a non-standard spot with the -m option.

su
mkdir /export/home/zfs/
zpool create -m /export/home/zfs/ memory mirror /dev/dsk/c1t2d0p0 /dev/dsk/c1t3d0p0



Create filesystems on your zpool that is much like a software RAID 1 volume. Except ZFS cares about the integrity of your data and the effects bitrot.

zfs create memory/photos
zfs create memory/iso
zfs create memory/music
zfs create memory/videos
zfs create memory/misc
zfs create memory/work
zfs create memory/holding

groupadd securftp

usermod -G securftp brad

chgrp securftp /var/zfs/holding

chmod 774 /var/zfs/holding

"My Printer Doesn't Work"

Normally "My Printer Doesn't Work" isn't enough information to give a concise clear answer.


Challenge Accepted


I am going to make a few assumptions...

MS Vista OS, MS Office 2007, and a consumer grade USB Inkjet/Laser printer.

Basics before we do anything.

	Hardware level 

		Power cord plugged in at the printer and the wall?
			Give both ends a gentle tug to make sure they are seated tightly.
		Is the USB cable plugged in at the printer and the computer case?
			Gentle tug at both ends again.

First we are going to make sure that the OS recognizes there is a printer attached.

	Click the 'Start Button' (It is the round button in the lower left.)
	RIGHT CLICK 'Computer' in the second column.
	A context menu will pop up, click 'Properties'.
	A Management Console will pop up.
	Click 'Device Manager' in the left hand column.
		You may neet to allow the action to continue.

	You should see a little directory tree of every hardware device your computer has.
		Many will be gobbldygook devices that you've never heard of.
			PCI Bus... WTF?
		Some, like the keyboard, will be plainly visible and familiar.
		Look for either 'Printers' or 'Universal Serial Bus controllers'
			Is your printer in either of those?

			NO, you need to reinstall the printer with the manufacturer's disk
			 or with a downloaded setup program from the manufacturer's website.

			YES, close all the windows and continue.

Next, since the computer knows your printer exists; we need to make sure it knows to use it.

Let's check to make sure the Operating System has your printer set as the 'default' printer.

	Click the 'Start Button' (It is the round button in the lower left.)
	Click 'Control Panel' in the right hand column.
	A management console type window will pop up.
		You may neet to authorize the action.
	Click 'Hardware and Sound'
	Click 'Devices and Printers' if 'Printers' by itself isn't available.
	Look for your printer, it should have a checkmark.
		If not RIGHT CLICK your printer and cick 'Set as default printer'.
		If it does we'll look in MS Office.
	Close all the windows.

	Open MS Office (Word or Excel)
	Click the 'Windows' type image in the upper left corner.  It is actually a menu icon.
		'Print...' is in there.
			If you use the 'Print...' menu item it will give you printing options.

As a last resort, try 'Windows Update'.
	Click the 'Start Button'.
	Click 'Programs'.
		You should see 'Windows Update'.
		Click it and follow the instructions
		Restart your Computer.
			Rinse and repeat until 'Windows Update' reports no more updates for your computer.

If these instructions fail, you can try ###-953-9738 which is my home number.
But, I will expect a small favor in exchange.
	(Nothing difficult, nothing creepy.  If I were in a movie, I would wear a white hat.)

I was able to learn that the printer was not recognized until the drivers were loaded. Once the drivers were loaded she could print. ...Challenge Beaten

Using nLight to Create Your Own Custom Windows Installs

Background


I have the specific opportunity to build a system specific restore disk on a regular basis. For people I will never see more than once, this issue is nonpoint. But, for people such as me, my close friends and family that may require more than one system restore, as well as the piles of identical machines that have rolled through my workspace; a custom disk would be helpful.


Problem


The restore disks that come with the machines usually install crap in addition to the necessary files and settings. Plain Microsoft Retail Disks often don't have all the drivers the systems require to run properly.


Solution


I've decided to try nLite. Before I can install nLite, I need to install the .NET framework, version 2.0 of the .NET framework at the minimum for nLite version 1.4.9.1 .


Once the initial program requirements are met, it is as simple as installing nLite and running it. The program is very intuitive.


I wanted to use my .iso file instead of going through the trouble of burning a disk. Since nLite won't use .iso files directly (to my knowledge) I need to install a virtual optical drive to mount the .iso image in. I am using a trial version of 'Original CD Emulator', but I will probably try something else next time. You can use a real CD to make it more a more simple process.


I keep several images of my OS install disks handy for backup purposes. In addition to being able to burn new disks to avoid scratching up my originals, I can often use the .iso image file in place of the disk. I used my Microsoft Windows XP Pro SP2 image created with ImgBurn for this. ImgBurn is my favorite tool for working with disks and images. It is a freeware app that has a small footprint and is highly configurable and intuitive. I have looked at the ImgBurn configurations, but I have only used the default settings.


One of the first things it will ask you is for is the location of the files. In this case I have a virtual optical disk making my .iso file pretend to be a legitimate CD-ROM, drive E:\ .


Although not necessary, I decided to slipstream SP3 (WindowsXP-KB936929-SP3-x86-ENU) and an IE security patch (WindowsXP-KB932823-v3-x86-ENU).


It also gave me the option to install hotfixes, add-ons, and update packs. But, I don't have any. So on to the next step.


The feature I am most excited about is adding drivers. When I played with it for the netbooks I worked on, I slipstreamed SATA drivers into the install-- which worked beautifully. This time I want to add the XP networking driver pack available at driverpacks.net and see what happens. It seems like a good idea to check the delete after install box.


When adding all the drivers finished; I added another folder for common programs like the IE8, the Intel SMBus Driver, other driver installers, and sometimes anti-virus intallers.

Automating Windows Driver Installs :(

Background


As a result of needing to reload a sizable quantity of machines with Windows, which really isn't a problem once you know to find the VEN_ and DEV_ information. I wanted to automate the whole process and for some reason I thought I should figure out how the .inf, .drv, .vxd, and .sys files worked with one another. This example just happens to be for the embedded 10/100 Broadcom 440x ethernet device.


Problem


I found a compatible driver on the Dell site like I would any other. But, even though it works-- did Dell put things in there that are tell tale signs that it doesn't belong if anybody were looking? These machines were not my own where certain inconsistencies may not be tolerated. The customers paid a fair price and they deserve a good and polished product.


Another question I asked myself was, "If I streamline the process, can I shave a few seconds off the device install?" Once the .inf file is prepared you still aren't off of the hook if there is no installer with options to install via a script. There is a way to script the install but I had to dig a little to find it.


Solution


Starting with the .inf file I did a lot of reading to figure out what each of the section does.


I renamed the section I wanted in the INF file so that I could use DefaultInstall as the section the OS would choose when I ran rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 132 E:\ethernet\bcm4sbxp.inf from the command line. This automates the installation of device driver files.


When I was done, I realized that I could have left the section named as the manufacturer had written it and changed my commandline to rundll32.exe setupapi.dll,InstallHinfSection BCM4401NIC 132 E:\ethernet\bcm4sbxp.inf to achieve the same results.


I removed all references to the Dell Computer Corporation.


Just as unnecessary cleanup, I also removed the ASUStek and MCI lines while I was figuring out what all of the stuff in this INF file was doing since it was an eMachines laptop without ASUS or MCI hardware dependent on those lines. When everything was said and done, because it worked without the alternative sections, I did not revert to the original file to add them back in.


The edited file follows below.

;*******************************************************************************
; Copyright 2002 Broadcom Corporation.
;
; INF for 32 bit Windows XP 
;
; History:
;    06/14/02        Inception.
;*******************************************************************************
[version]
Signature	= "$CHICAGO$"
Class=Net
ClassGUID	= {4d36e972-e325-11ce-bfc1-08002be10318}
Provider	= %V_BCM%
Compatible	= 1
CatalogFile=bcm4sbxp.cat
DriverVer=12/17/2002, 3.51.0.0

[Manufacturer]
%V_BCM% = BROADCOM, NTx86.5.1

[ControlFlags] 
ExcludeFromSelect = *

[BROADCOM.NTx86.5.1]

%BCM4401.DeviceDesc%           = BCM4401, PCI\VEN_14E4&DEV_4401

%BCM4401.DeviceDesc%        = BCM4401_broadcom, PCI\VEN_14E4&DEV_4401&SUBSYS_840114e4

%BCM4401.DeviceDesc%     = BCM4401_broadcom, PCI\VEN_14E4&DEV_4401&SUBSYS_00011179

;-----------------------------------------------------------------
; 32-bit Windows XP Install sections.
;  Broadcom  Catch All
[BCM4401.NTx86]
Characteristics	= 0x84			; NCF_PHYSICAL | NCF_HAS_UI
AddReg		= BCM4401AddRegisters, AdvancedTabReg, 8021pPriorityReg, DriverInfo
CopyFiles	= BCM4401.CopyFileNT
BusType		= 5			; PCI bus

[BCM4401.NTx86.Services]
AddService = bcm4sbxp, 2, BCM4401AddService, CommonEventLog

[BCM4401AddService]
DisplayName	= %BCM4401.Service.DispName%
ServiceType	= 1			; %SERVICE_KERNEL_DRIVER%
StartType	= 3
ErrorControl	= 1			; %SERVICE_ERROR_NORMAL%
ServiceBinary	= %12%\bcm4sbxp.sys
LoadOrderGroup	= NDIS

[BCM4401AddRegisters]
HKR,	Ndi,	Service,		0,	"bcm4sbxp"
HKR,	Ndi\Interfaces,	UpperRange,	,	"ndis5"
HKR,	Ndi\Interfaces,	LowerRange,	,	"ethernet"
HKR,	Ndi,	HelpText,		,	%BCM4401_HELP%



;  Broadcom  NIC
[DefaultInstall]
Characteristics	= 0x84			; NCF_PHYSICAL | NCF_HAS_UI
AddReg		= BCM4401_broadcomAddRegisters, AdvancedTabReg, 8021pPriorityReg, DriverInfo
CopyFiles	= BCM4401.CopyFileNT
BusType		= 5			; PCI bus

[BCM4401_broadcom.NTx86.Services]
AddService = bcm4sbxp, 2, BCM4401_broadcomAddService, CommonEventLog

[BCM4401_broadcomAddService]
DisplayName	= %BCM4401_broadcom.Service.DispName%
ServiceType	= 1			; %SERVICE_KERNEL_DRIVER%
StartType	= 3
ErrorControl	= 1			; %SERVICE_ERROR_NORMAL%
ServiceBinary	= %12%\bcm4sbxp.sys
LoadOrderGroup	= NDIS

[BCM4401_broadcomAddRegisters]
HKR,	Ndi,	Service,		0,	"bcm4sbxp"
HKR,	Ndi\Interfaces,	UpperRange,	,	"ndis5"
HKR,	Ndi\Interfaces,	LowerRange,	,	"ethernet"
HKR,	Ndi,	HelpText,		,	%BCM4401_HELP%




;-----------------------------------------------------------------
;
[CommonEventLog]
AddReg = CommonAddEventLogReg

[CommonAddEventLogReg]
HKR,	,	EventMessageFile,	0x00020000,	"%%SystemRoot%%\System32\netevent.dll;%%SystemRoot%%\System32\drivers\bcm4sbxp.sys"
HKR,	,	TypesSupported,		0x00010001,	7

[8021pPriorityReg]
HKR, Ndi\Params\8021pPriority,         ParamDesc,  0, %8021pPriority%
HKR, Ndi\Params\8021pPriority,         default,    0, "0"
HKR, Ndi\Params\8021pPriority\Enum,    "1",        0, %Enabled%
HKR, Ndi\Params\8021pPriority\Enum,    "0",        0, %Disabled%
HKR, Ndi\Params\8021pPriority,         type,       0, "enum"

[AdvancedTabReg]
HKR, Ndi\params\SpeedAndDuplex,       ParamDesc,  0, %SpeedAndDuplex%
HKR, Ndi\params\SpeedAndDuplex,       default,    0, "0"
HKR, Ndi\params\SpeedAndDuplex,       type,       0, "enum"
HKR, Ndi\params\SpeedAndDuplex\enum,  "0",        0, %AutoDetect%
HKR, Ndi\params\SpeedAndDuplex\enum,  "1",        0, %10MbHalfDuplex%
HKR, Ndi\params\SpeedAndDuplex\enum,  "2",        0, %10MbFullDuplex%
HKR, Ndi\params\SpeedAndDuplex\enum,  "3",        0, %100MbHalfDuplex%
HKR, Ndi\params\SpeedAndDuplex\enum,  "4",        0, %100MbFullDuplex%

HKR, Ndi\Params\WakeUpModeCap,       ParamDesc,   0 , %WakeUpMode%
HKR, Ndi\Params\WakeUpModeCap,       default,  0  , "2"
HKR, Ndi\Params\WakeUpModeCap,       type,      0  , "enum"
HKR, Ndi\Params\WakeUpModeCap\enum,  "0",        0 , %WakeUpMode_None%
HKR, Ndi\Params\WakeUpModeCap\enum,  "1",        0 , %WakeUpMode_Magic%
HKR, Ndi\Params\WakeUpModeCap\enum,  "2",        0 , %WakeUpMode_Pattern%

HKR, Ndi\Params\FlowControlCap,       ParamDesc,   0 , %FlowControlMode%
HKR, Ndi\Params\FlowControlCap,       default,  0  , "2"
HKR, Ndi\Params\FlowControlCap,       type,      0  , "enum"
HKR, Ndi\Params\FlowControlCap\enum,  "0",        0 , %FlowControlMode_None%
;   HKR, Ndi\Params\FlowControlCap\enum,  "1",        0 , %FlowControlMode_Rx%
HKR, Ndi\Params\FlowControlCap\enum,  "2",        0 , %FlowControlMode_Tx%
;  HKR, Ndi\Params\FlowControlCap\enum,  "3",        0 , %FlowControlMode_Both%



[DriverInfo]
HKLM,Software\InstalledOptions\%DriverOEM%\%DriverFamily%\%DriverMfgr%\%DriverProduct%,Description,,%DriverDescription%
HKLM,Software\InstalledOptions\%DriverOEM%\%DriverFamily%\%DriverMfgr%\%DriverProduct%,CurrentVer,,%DriverOEMVersion%
HKLM,Software\InstalledOptions\%DriverOEM%\%DriverFamily%\%DriverMfgr%\%DriverProduct%,Ver_%DriverOEMVersion%,,%DriverVersionID%
HKLM,Software\InstalledOptions\%DriverOEM%\%DriverFamily%\%DriverMfgr%\%DriverProduct%,BaseDriverFileName,,%BaseDriverFileName%
HKLM,Software\InstalledOptions\%DriverOEM%\%DriverFamily%\%DriverMfgr%\%DriverProduct%,BaseDriverFileVersion,,%BaseDriverFileVersion%


[DestinationDirs]
DefaultDestDir = 11		; system32 on Win2k and system on win9x
BCM4401.CopyfileNT = 12
BCM4401.CopyFileW9x = 11

[SourceDisksNames]
1=%BCM4401.DiskName%,,

[SourceDisksFiles]
bcm4sbxp.sys=1

[BCM4401.CopyFileNT]
bcm4sbxp.sys,,,1

;-----------------------------------------------------------------
;
[strings]
; Provider
V_BCM = "Broadcom"

; PNP Devices
BCM4401.DeviceDesc = "Broadcom 440x 10/100 Integrated Controller"

BCM4401_HELP = "Broadcom 440x 10/100 Integrated Controller provides local area networking"

BCM4401.Service.DispName = "Broadcom 440x 10/100 Integrated Controller XP Driver"

BCM4401_broadcom.Service.DispName = "Broadcom 440x 10/100 Integrated Controller XP Driver"


BCM4401.DiskName = "Broadcom 440x 10/100 Integrated Controller Install Disk"

SpeedAndDuplex = "Speed & Duplex"
AutoDetect = "Auto"
10MbHalfDuplex = "10 Mb Half"
10MbFullDuplex = "10 Mb Full"
100MbHalfDuplex = "100 Mb Half"
100MbFullDuplex = "100 Mb Full"

8021pPriority = "802.1p QOS"
Enabled = "Enable"
Disabled = "Disable"

WakeUpMode         = "Wake Up Capabilities"
WakeUpMode_Magic   = "Magic Frame"
WakeUpMode_Pattern = "Wake Up Frame"
WakeUpMode_None    = "None"

FlowControlMode         = "Flow Control"
FlowControlMode_Both    = "Rx/Tx Pause"
FlowControlMode_Rx   = "Rx Pause"
;FlowControlMode_Tx   = "Tx Pause"
FlowControlMode_Tx   = "Enable"
FlowControlMode_None    = "Disable"


; Driver Information Entries
DriverMfgr="Broadcom"                                 ; IHV name
DriverVersionID="3.51"                                ; The IHV driver version
BaseDriverFileVersion="3.51"                          ; version of key file
BaseDriverFileName="bcm4sbxp.sys"                       ; Key file for version

; These items will be set by IHV and updated by OEM
DriverOEM="Dell"                                      ; name of the OEM
DriverFamily="NIC"                                    ; device family (NIC, Storage, Video...)
DriverProduct="BCM440X"                               ; Specific Name of device (chipset, for example)
DriverDescription="Broadcom 440x 10/100 Integrated Controller"  ; Description of device (product name, OS or system supported)
DriverOEMVersion="A00"                                ; OEM-specified version

As a note to myself about deleting the output of the find command

find / -name (insert filename parts, wildcards, and/or filename here) -print0 | xargs -0 rm

Thursday, August 11, 2011

Great Private File Server for Medium to Small Environments

Use Open Indiana with ZFS to Create a Somewhat Locked Down File Server


Install OpenIndiana v148 with SSH


You will need a system with at least four(4) disks for this example

  • The system disk
    • This disk is to put the operating system on.
    • I recommend at least 30GB
    • The faster the better
  • The first data disk
    • This the first disk of a pair.
    • Reliablilty is paramount
    • Buy as big as you can afford
  • The second data disk
    • This the second disk of a pair.
    • Reliablilty, again, is paramount
    • And buy as big as you can afford
  • AT LEAST ONE BACKUP DISK
    • RAID, ZFS, OTHER... their purpose is to help with uptime
    • ZFS also assists in somewhat painlessly growing your storage capacity
    • Backup is backup, redundant disk strategies are for use and failure
    • Buy as big as you can afford

Follow the prompts, turn on SSH, use the whole system disk.


Update the system via CLI


pkg image-update --require-new-be

The GUI tools are not working in release 148 upon installation.


Find the disk names


format

Use [CTRL + C] to exit the format command


Create the mirrored zpool


zpool create newpool mirror c2t2d0 c2t3d0

Check out your handiwork


zpool status
df -h

Create a base directory structure


newpool|-business
       |-hobby
       |-books
       |-users|-admin01
       |      |-asmith|-shared
       |      |-lsmith|-shared
       |-misc

mkdir /newpool/business/
mkdir /newpool/hobby/
mkdir /newpool/books/
mkdir /newpool/users/
mkdir /newpool/users/admin01/
mkdir /newpool/users/asmith/
mkdir /newpool/users/asmith/shared/
mkdir /newpool/users/lsmith/
mkdir /newpool/users/lsmith/shared/
mkdir /newpool/misc/

Create any groups if necessary


groupadd admin01
groupadd internal
groupadd external
groupadd common


Add any non-existing initial users


Please note that I am creating two users with two commands, they are long so the text is wrapping.


useradd -d /newpool/users/asmith/ -c "Adam Smith" -G internal,common -s /usr/lib/rsh asmith
useradd -d /newpool/users/lsmith/ -c "Luanne Smith" -G external,common -s /usr/lib/rsh lsmith

The options are as follows:

  • -d is the home directory /newpool/users/username/ in this example.
  • -c is the real name, it can really be anything. But it you want it to contain a space then enclose the value in double quotes.
  • -G list all the groups of the directories you want the people to have access to separated by commas.
    • At the very least I give membership to the common group -G common .
    • But maybe I want to give access to the external directory as well -G external,common .
  • -s /usr/lib/rsh is the 'restricted shell' to prevent a lot of funny business.

Set passwords for any non-existing initial users


passwd lsmith
passwd asmith

passwd username

(Enter password twice-- tada!)

(passwd: password successfully changed for username)


Modify existing users


usermod -G admin01,internal,common admin01

(UX: usermod: admin01 is currently logged in, some changes may not take effect until next login.)


You can verify user information in the plaintext /etc/passwd file

You can verify group creation in the plaintext /etc/group file


Apply proper owner:group properties


chown admin01:admin01 /newpool/business/
chown admin01:peers /newpool/hobby/
chown admin01:peers /newpool/books/
chown admin01:admin01 /newpool/users/
chown admin01:admin01 /newpool/users/admin01/
chown asmith:admin01 /newpool/users/asmith/
chown asmith:admin01 /newpool/users/asmith/shared/
chown lsmith:admin01 /newpool/users/lsmith/
chown lsmith:admin01 /newpool/users/lsmith/shared/
chown admin01:common /newpool/misc/

Apply proper permissions

(4 read 2 write 1 execute)

(! execute required for non-owner:group on directory to traverse file system)


chmod 700 /newpool/business/
chmod 750 /newpool/hobby/
chmod 750 /newpool/books/
chmod 711 /newpool/users/
chmod 770 /newpool/users/admin01/
chmod 770 /newpool/users/asmith/
chmod 770 /newpool/users/asmith/shared/
chmod 770 /newpool/users/lsmith/
chmod 770 /newpool/users/lsmith/shared/
chmod 750 /newpool/misc/

770 gives writability, readability, traversing to owners and group members, and nothing to others - for regular user directories

750 gives writing to the owner, reading and traversing to the owner and group members, and nothing to others - for read only access to regular users

711 gives all access to the owner, and being able to traverse the directory to everyone - allows regular users to descend deeper into the directory tree where they may have access

700 gives no access to anyone but the owner, can't even open the directory - revoke access to regular users entirely


NFS & Samba


Currently, I don't have any NFS or Samba shares set up for this server.

I will update the instructions should that change.


Set quotas


On my file server I don't plan on having many users and even fewer user groups. So far I have no plans for any quotas.


If I did set a quota, I would likely do it on a user by user basis.


zfs set userquota@username=100G newpool/users/username

However, with version 15 of ZFS user group quotas are available as well.


zfs set groupquota@common=250GB newpool/misc

More users?


Add new directories


mkdir in users /newpool/users/username/ and /newpool/users/username/shared/

Add new users


useradd -d /newpool/users/username/ -c "Fname Lname" -G [comma separated list,]common -s /usr/lib/rsh username

Change owner:group properties to new users directories


Same as above


Apply proper permissions to new directories


Same as above


Set new user password


Same as above

Wednesday, August 3, 2011

Hacking bit.ly and goo.gl

bit.ly & goo.gl users: you can add another query string pair at the end of your link. Any unused pairs are usually ignored-- which will give you not only different shortened links to share but also label one from the other.


Both shortening services are weird about shortening any URL more than once for you. This is a workaround for that by essentially making them different via adding data that will be unused and/or ignored.

Also, neither service provides you a meaningful title for your links beyond the title of the page.

http://rustbeltrebellion.com/?link=facebook
http://rustbeltrebellion.com/?link=googleplus
http://rustbeltrebellion.com/?link=twitter

Guess where I used what.

Here is an example:


Test 1
http://www.google.com/?test=1/  >>  http://bit.ly/oJdAlV || http://goo.gl/9pX4h


Test 2
http://www.google.com/?test=2/  >>  http://bit.ly/qxp4Y5 || http://goo.gl/Ob2oP

Everything above points at the same page of the same site. When your browser arrives at "http://google.com", "?test=#" is completely ignored.

(I can picture sites depending on sequential data in the query string or sites that test for query string shenanigans giving less than satisfactory outcomes-- but by and large you will be successful.)

As cool as this is for bit.ly and goo.gl users who have wanted multiple shortened urls for a single destination for tracking user interest, it is nowhere as cool as what Vitreo has going on with their QR and shortening tools.

DD-WRT control panel, no-ip, and port 80

 I'm a satisfied no-ip DDNS subscriber happily using DD-WRT.
In the no-ip settings, I have an A Name record (hostname.com) that no-ip kindly shoots straight to my house.
I also have a www C Name record (www.hostname.com) which gets some magic applied then is sent to hostname.com:webServerPort (hostname.com:8080 in my case).

www.hostname.net goes to my web server. The port 8080 traffic is handled magnificently. That is awesome.
When I type in hostname.com that is translated to my ever changing IP by my DDNS service, it takes me to the control panel of my router which listens for web browser traffic on none other than port 80--
Not so awesome. Sadness actually.
I had everything working again otherwise.

BACK UP YOUR SETTINGS.
You're going to be in there anyway, jeez man it only takes a few seconds.

I checked HTTPS and unchecked HTTP in Administration > Management > Web Access > Protocol

What this does for us is that it sets the router to listen for requests of the web GUI, the control panel, on port 443 and not port 80 anymore.

Save, Apply Settings, Reboot.
I do it whether I really need to or not, this is my house-- not a Data Center of a Fortune 500.

Now the router needs accessed with https://192.168.1.1 , heads up a certificate warning will probably pop up. The router is self certifying itself for encrypted web traffic and it is not on the preferred list of SSL certificate providers, so click whatever you need in order to continue.

After that I rerouted port 80 (since that is where the naked hostname.com from a web browser goes) via the NAT via TCP only to my webserver IP on port 80 in NAT / QoS > Port Forwarding > Port Forward > Forwards

Save, Apply Settings, Reboot.
BACK UP YOUR NEW SETTINGS.
Pure awesomeness. Enjoy.

Followers