Sunday, August 5, 2012

Home NAS

I figured I would give you an extremely important, life altering, and mind blowing opinion, on setting up a NAS for your home network. And it is...blehhh!

I setup a NAS box using FreeNAS 8.0.2 something or other about a month ago using some spare hardware I had laying around the house. The initial installation wasn't too bad. The real pain didn't kick in until I started implementing features that I wanted. And, in all honesty, it's probably user error. My background is Windows which puts me at a real disadvantage when using Linux\FreeBSD based applications. But we're not going to allow that to stop me from my rant! Here we go...

Creating shares in CIFS that I could show\hide based on the account used to log in took some googling skills and a dash of experimentation.

RSYNCing to an external usb drive formatted with NTFS bumped up my blood pressure. I managed to figure out how to do it from the command line but couldn't figure out how to put it on a schedule. (See CRON complaint below.) Thanks go to this fellow for pointing me in the right direction. The killer issue I ran into was that my external drive was giving me GPT errors when plugged into the FreeNAS box. Apparently my drive was formatted with MBR. I had to re-format with GPT using Windows Disk Management.

I couldn't get the CRON process working. It seems it's writing informational\debug messages to /dev/null? (Windows folks, /dev/null seems to be Linux's versions of a black hole.) So, there was no way for me to debug the issue.

ACPI seems to be broken in my version of FreeNAS. Apparently, this is a FreeNAS configuration issue that is fixed in a later version. I know, I know, why not upgrade to the latest version? Well, excuse me for living but it's not my job to be chasing the dream. All I want is something that works. Is that too much to ask?

These are just some FreeNAS complaints so let's talk about my real issues with a home NAS.

  1. I have three(3) 1.5 TB drives running in ZFS raid and it's very depressing to see that all the digital stuff that I have gathered over my life span, worth keeping, takes up less than 5% of the available space. 
  2. What is the value added? Wouldn't I get the same effect just dumping to an external usb drive. (If I were paranoid I could dump to two external usb drives.)
  3. The cloud is coming. Do we really need to have a home NAS when we could just dump everything into the cloud? (No snarks about Amazon.)

Friday, August 3, 2012

Signing PowerShell Scripts

As part of my series on how to automate publishing Metastorm maps we will now talk about signing the PowerShell script.

Hey, I don't know about you but security where I work keeps us on a tight leash. We can't just run anything in production. At the very least we should be digitally signing our files.

Now, I could sit here and write a book on how to digitally sign your PowerShell scripts but what do I get out of it? How about I just point you in the right direction?

'Signing PowerShell Scripts' will get you 90% of the way there. The issue I ran into was that my script was encoded incorrectly. (Damn you, Notepad!) 'UnknownError when using Powershell ISE to Set-AuthenticodeSignature' should get you the rest of the way.

RSA Tokens

It it me?

I swear I can see a pattern in the "randomly" generated numbers on my SecurId token.

Maybe it's just My Beautiful Mind?

Publishing Metastorm Procedures

As part of implementing Continuous Integration in our environment I ran into an issue of how to automate deploying a Metastorm procedure.

Now, Metastorm has a KnowledgeBase article showing how you can use VBScript to deploy a procedure but it doesn't cover all of our use cases. Specifically, when deploying a procedure that references a library, Metastorm has a nasty habit of popping up a dialog box requiring you to click a button.

Did I also mention their example uses VBScript?

Well, your intrepid blogger decided to see if he could come up with a better\different solution.

Here's a PowerShell script that should work for you:

#This PowerShellscript is to be run to publish a Metastorm procedure 
#in unattended mode.
Param( 
    [String] $dsn = "dsn",
    [String] $userId = "userid",
    [String] $password = "password",
    [String] $procedure = "C:\procedure.xep",
    [Int] $secondsToWait = 20
)

#When publishing Metastorm procedures sometimes a dialog box pops up
#giving a status message and requiring user interaction. This script 
#checks to see if the dialog box exists and closes it so that 
#publishing can finish.
$closeMetastormDialogBox =
{
    Param( [Int] $secondsToWait )

    Add-Type -AssemblyName Microsoft.VisualBasic
    Add-Type -AssemblyName System.Windows.Forms

    Start-Sleep -s $secondsToWait

    #Is the Metastorm Designer running?
    $processExists = Get-Process | Where {$_.mainWindowTitle -eq "Metastorm Designer"} -ErrorAction SilentlyContinue
    If( $processExists -ne $null )
    {
        #Bring the Metastorm dialog box titled "Library Loading Status" 
        #into focus
        [Microsoft.VisualBasic.Interaction]::AppActivate("Library Loading Status")
        
        #Send the close command to the "Library Loading Status" dialog
        [System.Windows.Forms.SendKeys]::SendWait("%{F4}")
    }    
}

#Start the Metastorm designer
$eDesigner = New-Object -ComObject "eDesigner.eDesigner6"

#Publish the Metastorm procedure
$eDesigner.ConnectToEworkDB( $dsn, $userId, $password )

#When opening a procedure sometimes you'll get a pop up dialog 
#requiring user interaction. So, start a background task that 
#looks for the dialog and closes it.
Start-Job -ScriptBlock $closeMetastormDialogBox -ArgumentList $secondsToWait
$eDesigner.OpenProcedure( $procedure )
Remove-Job -State Completed

$eDesigner.PublishProcedure( "", $false )
$eDesigner.CloseProcedure()
$eDesigner.DisconnectFromEworkDB()

#Close the Metastorm designer
[System.Runtime.Interopservices.Marshal]::ReleaseComObject( $eDesigner )

Start of a beautiful friendship

Hello world!

Interesting start for a new blog. If I remember correctly "Hello World!" was the start of the Kernighan and Ritchie C book.

My forte is software development and I intend to share my views, lessons learned, and coding tidbits that I have managed to pick up along the way. I'll also throw in a dash of life stories to keep you entertained.