Categories
Blogging Code How-To Sys Admin

Running WordPress & PHP Behind ISA Proxy

Some things work well on their own but when mixed make your life hard. Things like Linux and PHP work very well. Microsoft ISA proxy also does a good job in a corporate MS environment. But making the two work together in a controlled environment can be an exercise in frustration.

In this post I’ll pass on the methods I found to get PHP and your Linux boxes talking out through a corporate ISA proxy server. You can then bring in RSS feeds, updates and other things in WordPress and use apt-get to update Ubuntu.

Categories
Interesting Stuff Sys Admin

Using 7zip in Cron Jobs Fails

For those people tearing their hair out trying to use the 7z util in a cron job, have a look in the Ubuntu forums for the solution. Strangely as soon as you start sending the output to a log file, the 7z part of your script will work.

I struck the problem in the Hardy version of Ubuntu Server.

Categories
How-To Sys Admin

MySQL Replication on Ubuntu with DRBD

I’ve been looking around for some easy and open-source ways to handle database replication for a handful of small but important MySQL databases. A few options were viable but usually included too many config changes for things like creating a new database. DRDB on a Linux server seems to be one of the fastest and easiest methods to handle database synchronisation for DR purposes, so this is the subject of this post. The content is a combination of two main sources from Mark Schoonover and the Ubuntu server guide and the gotchas I found along the way.

This post will show you how to create two MySQL servers that automatically replicate all their databases using DRBD. With Heartbeat installed on a third machine you’ll have basic fail over protection as well (we’ll do this in another post). Only one of the database servers will be active at any one time.

Categories
Interesting Stuff Sys Admin

MS Exchange Local vs Hosted vs Google for 10,000 Users

After looking at some comments around Exchange Hosted Services, I thought I might do a quick (and very dirty) comparison between that and Google for 10,000 users. (This is no way reflects on the three options and may not resemble your reality).

MS Exchange Hosted Services would cost US$90k/month for company with 10k email users and selecting roughly half the options available (Communicator and Hosted Archive being two). That sounds really pricey vs local in-house servers and admins? I have no specific Exchange knowledge but say 20 servers across 5 virtual hosts, plus storage and backups is roughly NZ$350-400k as a one-off cost. Plus a team of seven admins to run it @ NZ$80k pa each is a five year cost of around $2.8 million, but lets say $3.2M to round it up to include a few software licenses and some power,cooling and floor space.

Google’s offering that I compared MS against is their Premier Edition of Apps. It’s US$50 per user per year and offers the usual email, calendar, resource booking, etc much like Exchange. I was expecting a few missing features but was surprised to see BlackBerry Enterprise Server (BES) synching and user and group provisioning APIs. It integrates with LDAP and offers Single Sign-On (SSO) so most of your users won’t see too much of a change – especially if they keep on using the Outlook client. The main issue for some businesses may be the 99.9% uptime guarantee – that’s 8h 45m down time per year. I’m sure there are a few features that Exchange holds over Apps but in many situations the cost may outweigh the benefit or it’s just not needed. Using Google Apps also unties you from MS Outlook and possibly MS Office, so this option may open the door to other savings.

So over 5 years for the 10k user company we have the following options:

In-house MS Exchange with 20 VMs, storage and 7 admins = NZ$3.2M

MS Exchange Hosted Services with a mid-tier option seclection @ US$90k/month = NZ$7.4M (at today’s exch rate of 0.72)

Google Apps Premier Edition @ US$50 per user per year = NZ$3.5M

Now one stands out there and not for a particularly good reason. The MS EHS option does include Communicator and Hosted Archiving as an option but I don’t see the extra value over staying with what you have or sending it all to Google. Add to both the off-site options, the project costs of actually implementing this and your own Exchange would have to be in a bad way or have some serious pain to go either way.

What are your thoughts on this one? Are my locally run Exchange costs way off for 10k users and are there any NZ based companies of a similar size (NZ Post’s 2100 users are on the way to Google Apps) that have taken either remote option? Is Google half the service or twice the value of the MS offering?

My last thought would be – just how reliable is that internet connection of yours?

Categories
Sys Admin

Upgrading to VMware Server 2 on Ubuntu 8.04

After downloading the latest Windows 7 RC I loaded it into VMware Server 1.06 that I installed on Ubuntu Server a while back. All going well until the Windows 7 installer wouldn’t see the disk I had created. It seems that Windows 7 doesn’t like the SCSI virtual disk, so I removed that and created an IDE virtual disk and restarted the install.

Things were much better until it came time to install the VMware Tools and nothing happened. Things weren’t exactly snappy and without the tools installed, they weren’t going to get any better. It was time to make the upgrade from VMware 1.06 to 2.0 and as it turns out, is much easier than previous VMware installs.

Overall I followed the instructions from the LinuxGazette website and things worked flawlessly, but there were a couple of extras due to the upgrade.

Firstly (and fairly obviously), make sure you stop your current VMware daemon/service before starting the install. The VMware installer is pretty good, but I’m sure that your virtual machines would appreciate being offline before things get messed up.

sudo /etc/init.d/vmware stop

If you’re upgrading from VMware Server 1.06 the installer will also complain about the vmnet and vmmon modules being left from a previous version. So we need to get rid of those – using the correct kernel version. You can get that with “uname -r”.

sudo rm /lib/modules/2.6.24-22-server/misc/vmnet.o
sudo rm /lib/modules/2.6.24-22-server/misc/vmnet.ko
sudo rm /lib/modules/2.6.24-22-server/misc/vmmon.o
sudo rm /lib/modules/2.6.24-22-server/misc/vmmon.ko

After that it’s plain sailing. Just follow the instructions to untar your VMware download and run the installer. Assuming you used the default locations in the previous install, your virtual machines will be untouched and start happily under VMware Server 2.0

One of the final things to note in the install is that the new client interface is all browser based. To log into your VMware server requires a password and the Ubuntu root user does not have one by default. So on your server be sure to run,

sudo passwd root

and set a nice secure password for when you head to http://servername:8222. Firefox users will need to give the site security certificate the OK and all browsers will need to install the plugin to use the console to view your machines.

Hooray – Windows 7 now installs the VMware Tools properly and runs pretty well. At the moment I have no sound and the limited graphics under VMware don’t allow Aero fanciness, but I can now test and develop in the Windows world while meeting all license requirements. The Windows 7 RC license is valid until June 2010 although don’t wait that long as it’ll start making life hard for you in March 2010. That’s almost a year of free OS from Microsoft!

Categories
Interesting Stuff Sys Admin

Enable WakeUp from PS2 Keyboard in Ubuntu 8.10

One of the annoying “missing features” I’ve struggled with under Ubuntu is that I was unable to wakeup the PC from suspend or hibernate with my keyboard. Of course, Windows just does it – tap the keyboard and the PC starts up again. I could press the power button on the front of the PC, but its down the side of the desk and not easily accessible.

I found an older post in the Ubuntu forums that had the fix for USB devices and it also works for PS2 with the simplest of changes. So follow these steps and you should be saving power and getting back to work faster.

Open a Terminal and type,

cat /proc/acpi/wakeup

Note the entries that come back and you should see a device called “PS2K” toward the top if you have a PS2 keyboard. For those with USB, it’ll be one of the USB items toward the bottom. The entry will probably also have “Disabled” on the same line, hence your problem.

To enable this entry, switch to a root session by typing,

sudo -s

and enter your password. Now type the following to update the acpi file and toggle “disabled” to “enabled”, (those with USB devices can try USB0, USB1, etc)

echo PS2K > /proc/acpi/wakeup

That should have now enabled your PS2 keyboard to wakeup your PC for this session. Give it a test by putting your machine to sleep and then tapping a key on your keyboard. Probably a good idea to save stuff first, just in case.

If you tried changing a USB device, it may take a few guesses until you find the KB. My mouse was USB0 and clicking any mouse button can also do the wakeup task.

To make this change permanant, you need to add that line to a script and run it when Ubuntu starts. So we create a file called wakeup.sh with the following contents,

#!/bin/bash
echo PS2K > /proc/acpi/wakeup

Save it and from a Terminal make it executable so it runs properly as a script and not just a text file,

chmod +x wakeup.sh

Now to add it to the startup area go back to your Terminal that’s running as root. We need to copy the file to the correct location and add it to the startup processes. You’ll need to run the cp command in the same folder as where you saved your wakeup.sh file.

cp wakeup.sh /etc/init.d/wakeup.sh
update-rc.d wakeup.sh defaults

Now when you reboot, the script will run and enable your PS2 keyboard in ACPI so you can wakeup your PC.

Categories
Sys Admin

Mount USB Drives as Folders in Windows

I’d like to say that I could make a title like “did you know . . .?” into a series of short articles but I’m not that knowledgeable or interesting. But one thing I did discover today was that Windows can mount external USB drives into folders and not just drive letters.

We have a long standing problem in that normal users cannot change the drive letters that Windows XP assigns to memory sticks/thumb drives/external hard drives. Not a biggie but in some cases XP decides to mount the drive using the same letter as a network drive. Your thumb drive is detected and mounted OK but can’t be used. Bugger. It seems that XP ‘user-space’ doesn’t talk with XP ‘storage-space’ about who gets what.

To get around this we remotely use Disk Manager to change the drive letter. Windows ‘remembers’ the drive letter is associated with the USB device’s unique ID and in the future will keep using the same letter. Again, not a biggie and for the odd user in 10,000 a simple fix.

But with the proliferation of USB storage for anything and everything, the fight of the USB device versus the network drive for drive letters may be a problem for some. Enter the mounting of USB storage to NTFS folders! Users can create a folder on their local machine with a suitable name like, ‘My Pimptastic Red USB Stick – 2GB‘ and mount the device in that folder. No drive letters, no XP tripping over itself and a near infinite number of options.

Now who wants to write a tool that allows users to do that? You’d have my vote in any election.

Update – this old problem is resolved in Windows XP SP3. It knows to check your network mappings if you insert a USB drive when logged in.

Categories
Interesting Stuff Sys Admin

Installing VMware Server 1.06 on Linux

Installing the free VMware Server is a common but slightly tricky process on some newer Linux systems. Having had to go through it again recently I thought I’d write some of it down. Of course if you are using Ubuntu 7.10 then the simple option is to enable the Canonical Partner repository and just use Synaptic to select and install VMware Server.

For the others in the audience that are installing on Ubuntu 8.04 or another Linux system that doesn’t have packages, you should have a working VMware Server install with web interface and a client console by the bottom of the page.

Categories
Sys Admin

Creating Windows Server Print Queues From the Cmd Line

I’d been given the task of setting up two Windows print servers with a touch over 300 print queues. The queues would be split between the two servers, with one holding all the even numbered queues (they’re named things like CityA094 or CityB031) and the other the odd names.

Well, it gets rather boring doing this via the GUI. The process of creating the TCP/IP ports, then the queues and entering the location information takes a fair number of clicks and typing. With only the queue name, location and description changing between each, it’s a good task for a script.

You need three VBS files that already exist on a Windows XP system, a target server and a logon to that server. The three VBS files are prncnfg.vbs, prnmngr.vbs and prnport.vbs which should be in your (windows root)system32 folder.

Then use the following in a batch script to call them to do the work. It’ll create the port (using RAW mode), then the queue and then configure the queue.

WordPress really doesn’t like the script syntax and is getting a little confused so here it is in a text file: AddPrinter Script.

Note that I’m only using the Generic/Text driver for all queues, so the
usefulness may vary if you’ve got lots of different models.

Categories
Code Sys Admin

Creating UNIX Time in Windows Script

I recently found myself needing to convert a date/time in a Windows vbs script to UNIX time and struggled to find an example of how to do this. Correct me if I’m wrong, but there doesn’t seem to be any built-in function to change 20070109161723+720 to 1168359443.

After fine-tuning a few Google queries I found using the DateDiff function the easiest way and came up with,

Function WMIDateToUNIX(strDate)
ConvertedDate = CDate(Mid(strDate, 7, 2) & "/" & _
Mid(strDate, 5, 2) & "/" & Left(strDate, 4) _
& " " & Mid (strDate, 9, 2) & ":" & _
Mid(strDate, 11, 2) & ":" & Mid(strDate,13, 2))

WMIDateToUNIX = DateDiff(“s”, “01/01/1970 00:00:00”,ConvertedDate)
End Function

Not the prettiest code I’ll admit, but if someone else can use it that’s all well and good.