• Dell OpenManage Server Administrator on ESX

    This is how I installed Dell OpenManage Server Administrator on our VMware ESX 4.1 box

    tar -xzf OM-SrvAdmin-Dell-Web-LX-6.4.0-1266_A00.4.tar.gz
    cd linux/supportscripts/
    ./srvadmin-install.sh -x
    esxcfg-firewall -o 1311,tcp,in,OpenManageRequest
    ./srvadmin-services.sh restart

    Mostly a reminder for me, but maybe a search engine will bring someone here, and it would be helpful.


  • My “Copy WordPress site to local” script

    I wanted to write a script that would copy a WordPress site to the local machine from a remote server (securely over ssh). This would allow me to set up a test environment or backup. First I need to make sure the site exists on the source server. Then I want to get the current wp-config settings, like the database name:

    echo "Checking $SRCSERVER for a site named $SRCSITENAME"
    CHECKCMD="ls /PATH/TO/$SRCSITENAME/wp-config.php | grep wp-config.php > /dev/null; echo \$?"
    CHECKFILE=$(ssh $SRCSERVER $CHECKCMD)
    if [ $CHECKFILE -eq 0 ]; then
            echo "Source Site $SRCSITENAME on $SRCSERVER exists"
            SRCMYSQLSITEUSER=$(ssh $SRCSERVER grep "DB_USER" /PATH/TO/$SRCSITENAME/wp-config.php | cut -f 2 -d " " | cut -f 2 -d "'")
            SRCMYSQLSITEPASS=$(ssh $SRCSERVER grep "DB_PASSWORD" /PATH/TO/$SRCSITENAME/wp-config.php | cut -f 2 -d " " | cut -f 2 -d "'")
            SRCMYSQLSITEDB=$(ssh $SRCSERVER grep "DB_NAME" /PATH/TO/$SRCSITENAME/wp-config.php | cut -f 2 -d " " | cut -f 2 -d "'")
            echo "Source mySQL Site Database:"$SRCMYSQLSITEDB
            echo "Source mySQL Site Username:"$SRCMYSQLSITEUSER
            echo "Source mySQL Site Password:"$SRCMYSQLSITEPASS
    else
            echo "Source Site $SRCSITENAME on $SRCSERVER does not exist"
            exit;
    fi
    

    Next I provision a new site with a new virtual host, and I copy over the files:

    echo "Copying site from $SRCSERVER:/PATH/TO/$SRCSITENAME/ to /PATH/TO/$DESTSITENAME"
    rsync --archive $SRCSERVER:/PATH/TO/$SRCSITENAME/ /PATH/TO/$DESTSITENAME
    

    Next I provision a new blank MySQL database with the name, username, and password received in the first part for code, then I copy over the db data via ssh:

    echo "Copying mysql data from $SRCSERVER to local database name $DESTSITENAME"
    ssh $SRCSERVER "mysqldump -u root $SRCMYSQLSITEDB" | mysql -u root $DESTSITENAME
    

    Finally I run a couple of SQL queries to change the URL that WordPress has inside the DB.

    
    echo "What is going to be the WordPress URL"
    read NEWURL
    
    OLDSITENAME=$(mysql --batch --skip-column-names -e "use $DESTSITENAME;select guid from wp_posts LIMIT 1;" | cut -d"/" -f3)
    echo "Changing the wp_posts guids from $OLDSITENAME to $NewURL
    
    mysql --batch --skip-column-names -e "use $DESTSITENAME;UPDATE wp_posts SET guid = REPLACE (guid, '"http://$OLDSITENAME"','"http://$NEWURL"');"
    
    echo "Changing the home and siterurl to $NewURL"
    
    mysql --batch --skip-column-names -e "use $DESTSITENAME;UPDATE wp_options SET option_value = replace(option_value, '"http://$OLDSITENAME"', '"http://$NEWURL"') WHERE option_name = 'home' OR option_name = 'siteurl';"
    

  • And we’re back – Chrome 12.0.725.0 dev restores notifications

    Phew.


  • My PowerShell PowerCLI VMware guest provisioning script

    This script will provision a 4GB Ram, 40 GB HD Server 2008 R2 VM, set the CD to an OSD iso, set the BootDelay to 5 seconds, and start the machine

    
    $vmhost = Get-VMHost "server.name.local"
    $ds = Get-Datastore "server:storage1"
    $rp = get-resourcepool -id "ResourcePool-resgroup-22"
    $nn = "NetworkName"
    $gi = "windows7Server64Guest"
    $iso = "[server:ISOs] Folder/OSD.iso"
    
    ####
    $vmname = "VMGeust01"
    New-VM -name $vmname -VMHost $vmhost -numcpu 1 -DiskMB 40960 -memoryMB 4096 -datastore $ds -guestID $gi -resourcepool $rp -cd -NetworkName $nn
    Get-VM $vmname | Get-CDDrive | Set-CDDrive -IsoPath $iso -StartConnected $true -Confirm:$false
    
    $value = "5000"
    $vm = Get-VM $vmname | Get-View
    $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
    $vmConfigSpec.BootOptions = New-Object VMware.Vim.VirtualMachineBootOptions
    $vmConfigSpec.BootOptions.BootDelay = $value
    $vm.ReconfigVM_Task($vmConfigSpec)
    
    Start-VM -VM $vmname
    

  • OS X: Move files based on creation date

    I wanted to organize my flip videos – I wanted them moved into a folder named after their creation date.

    One of the scripts that I found uses ls’s “–time-style” parameter. BSD’s ls does not have this value. MacPorts’ coreutils port contains gls (GNU’s ls) that does support the parameter. So here is my script to move movies into a sub folder based on the movies creation date.

    for filename in *.MP4; do
        datepath="$(gls -l --time-style=+%Y-%m-%d $filename | awk '{print $6}')"
        echo "$datepath"
        if ! test -e "$datepath"; then
            mkdir -pv "$datepath"
        fi
        mv -v $filename $datepath
    done
    

  • New to my PowerShell Profile: VMware PowerCLI

    & {
    $ErrorActionPreference = "silentlycontinue"
    $vmwareSnap = get-pssnapin -name "VMware.VimAutomation.Core"
    if (! $?) { add-pssnapin "VMware.VimAutomation.Core" }
    }
    

    This will add the PowerShell CLI tools if they exist.

    Thanks to this thread


  • RSAT on Slipstreamed SP1 Install – #FAIL

    Driving me nuts that I can’t install RSAT on a machine with SP1 already installed!!!!!!!!


  • Mailbox moves and error no. c1034ad6

    We have been moving mailboxes to a new Equallogic iSCSI SAN volume. The old information store is almost empty, except for one mailbox that did not get removed at the end of the move. It was sitting there with a red “X”. When we tried to delete it we received the error:

    The Operation cannot be performed because this mailbox was already reconnected to an existing user.
    ID no. c1034ad6
    Exchange System Manager

    I found this article, that suggested the it should be automatically removed once the “Exchange maintenance” runs. Since our maintenance runs over the weekend, and our “Keep deleted mailboxes for (days)” is set to 1 days, two weeks later, the mailbox should have been removed. But it wasn’t.

    The problem ended up being that we had the check box “Do not permanently delete mailboxes and items until the store has been backed up” checked. This is great, but since there weren’t any mailboxes left in the information store, we had stopped backing it up!!!!

    If you get the error above, and

    • the lat mailbox has been moved
    • you have stopped backing up your information store
    • The check box “Do not permanently delete mailboxes and items until the store has been backed up” is checked

    Then your last mailbox will never be permanently deleted!!!

    Obvious, but maybe someone will run across this and it will save them a couple of minutes scratching their head!