Category Archives: Tech_Friday

Rebootolator: Execute a Remote Linux Shell Script from Windows

Ok,  so, your mission, should you decide to accept it, is to restart mySQL and Apache on a remote server. This restarts a balky web site hosted by Apache, and also restarts a mySQL server which is used for a back-end for Drupal.

You want to execute this from your Windows computer.

The target computer runs CentOS 5.6 This is an (ancient) Red Hat Linux derivative, running (ancient) mySQL and Apache.

I ended up using PLink called from a Windows .CMD file to execute a bash shell script.  The shell script looks like this:


#!/bin/bash -p
# Rebootolator – Reboots Apache and mySQL on a target Server
# LK Microdesign June 25, 2014
export TERM
echo ‘Rebooting Apache and mySQL on myServer’
echo ‘———————————–‘
echo ‘Restarting mySQL’
/etc/init.d/httpd restart
echo ”
echo ‘Restarting the Apache web server.’
/etc/init.d/mysqld restart
echo ‘Reboot procedure completed’

Note this script is not stored on the target server, but simply put in the same folder as the windows cmd file on my windows box.  

Now for the Windows command file: 


:: Batch file to restart services on myServer
:: Restarts mySQL and httpd 
:: Uses the Rebootolator shell script
:: LK/Microdesign August 12, 2014  
@echo off
plink -ssh -m -pw mypass

pause >nul | echo Press any key to exit. 

So, lets deconstruct the Windows Reboot.CMD file.
The first four lines are comment lines. Turns out, you can use two colons to preface a comment in Windows, (who knew?) instead of REM.
Line 5 turns off output to the screen.
Line 6 clears the screen.
Line 7 and 8 put in blank lines.
All the work happens on line 9, using the PLINK command. PLINK is the command line version of PUTTY, a free open source terminal program for Windows workstations. Both PLINK and PUTTY are pretty wonderful and highly recommended if you need to access Linux machines from Windows.
-ssh means “use the secure socket layer protocol to log into this machine” is a administrator’s account on the target machine,  probably the root account.
-m is the name of the shell script (above) that needs to run on the target machine.
-pw mypass is the password for the account used to log into the machine.

Deconstructing the script:
#!/bin/bash -p  just means this is a BASH script
The two commands that actually restart the mySQL server, and the Apache server are: 
/etc/init.d/httpd restart
/etc/init.d/mysqld restart

The rest, (the echo commands) write out what  is happening at the command line. The Term command is my attempt to avoid a harmless error message that occurs when the script starts to execute.

Since I didn’t realize I could host the script in my Windows folder, I originally though I’d have to log into one Linux box, and then execute the script on the target box.  Turned out the whole thing was simpler using PLINK, which is the equivalent of SSH and SSHPASS programs used to access remote machines from the Linux command line.

ClearOS: A Linux-based Windows SBS Replacement

In my ongoing project of trying to clone a Redhat Linux server, I ran across a help file that was written for an operating system called ClearOS. I assumed that this was another Linux distribution, and ignored it at first but then, while waiting for another installation, I spent some time reading the web pages.

ClearOS is a combination of a core Linux distribution based on Red Hat and CentOS. It includes a complete set of applications to provision an entire office. Perhaps the main advantage is that it takes what are usually a number of several different disparate Linux-based programs, and it puts a slick web-based management front-end them. ClearOS is very modular; you can make things as sophisticated or simple as you want.

To get a closer look, I downloaded and installed the ClearOS Virtualbox demo. (The only glitch was a problem with the 64-bit demo; I re-downloaded the 32-bit version and that installed perfectly on Virtualbox on my iMac.)

Setup is accomplished by a wizard that walks you through a sequence of steps to install the software, connect to the internet, configure the firewall and configure additional services.

If you want to see how ClearOS looks without worrying about the installation, you can “manage” a virtual server with a Live-Demo.

The screenshot shows options for backing up local workstations.

ClearOS offers a number of different versions and support levels. You can download and run the community edition for free, a choice that I might consider to replace a Windows SBS 2011 server if there are no processes on the server that are dependent on Windows. You can install it and run it on your own dedicated hardware. (They don’t recommend running the whole thing in a single virtual machine).

Or you can run it on a ClearOS hybrid appliance. These require the ClearOS Professional version which is a subscription-based support plan. The supported version can also be run on your own hardware. It includes certified and tested versions of all of the applications so that they are guaranteed to work together.

Years ago there was the Cobalt Qube, a single box which provided eMail, file and print services in a single cute box. (You can still find them on eBay). It was a great way to get an “instant network”, and I was sorry to see it discontinued. The ClearOS options provide a similar instant network, and would be suitable anywhere a Windows Small Business Server might be considered.

It has been awhile since I had a Tech Friday… a day almost exclusively devoted to tech stuff as opposed to accounting, finance, marketing, whatever.

I spent the day installing Filemaker Server Advanced version 12, on a repurposed Dell workstation running Windows 7 and the Windows IIS web server.

Although the FileMaker Server web page claims you can install it in eight minutes, I was actually at it for much of the day, troubleshooting the installation and then trying out as many of the features as I could.

Just what is FileMaker Server? 

FileMaker Server is host software for FileMaker databases, that facilitates running one or more shared databases from a single dedicated server machine.

It includes a backup program to safely back up FM databases even when they are open, a major source of corruption when attempted by standard backup software.

Databases can be accessed in several ways:

  • You can use a Mac or PC desktop workstation running a standard copy of FileMaker Pro. 
  • You can access using PHP, or XML. 
  • You can access through a web browser using “instant web publishing”, which provides a similar interface  to a standard Filemaker Pro interface in a web browser.  This is available only with FileMaker Pro Advanced. 
  • You can access using Filemaker Go, on an iPhone, iPad, or iPod Touch over a wireless or 3G connection. 

I opened a sample database on the server showing with a couple records, and instantly had it open on an iPad, a Mac and Windows PC via the web browser interface.

The sample file displayed  on the iMac. Click to see full-sized.

Here is the same file displayed on the iPad.
The iPad display does away with the project index to the left, but easily displays the full project and task information for a single project. To choose which project you want to see, you can either tap the little index icon in the upper right, (next to the “Tasks” button), or you can scroll through the projects by using the arrow buttons at the bottom of the screen.

Click to see full-sized.

Here is the same file as displayed in Firefox on a Windows XP workstation.

Click to see full-sized.

The web browser version displays the same controls for adding, searching and deleting records that the native Filemaker client displays (top image). In fact the native Windows and Mac clients are virtually identical from the user’s perspective.

Filemaker is perhaps one of the most elegant cross-platform database development systems available.

Microsoft Small Business Server 2011 — Install Quirks

Well, maybe not quirks exactly, but, there do seem to be a few points of interest.

To review, Microsoft Small Business Server 2011 is a bundled combination of the following:

Windows Server 2008
Microsoft Exchange 2010
Microsoft SharePoint 2010
Microsoft SQL Server 2008

In its usual confusing way, Microsoft can’t offer a single version of this but rather, they have three editions. There is Windows Small Business Server Standard (with the software described above), Windows Small Business Server Essentials (which substitutes cloud versions of SharePoint and Exchange for the bundled server versions that come with Standard). There is also an supplementary Small Business Server Premium Add-On which adds another SQL-Server box for running back-end database applications or web sites. I’ve been working with Standard. This can serve a maximum of 75 users, which I’m sort of assuming means 75 currently connected users, and that you could configure more than that number.

On installation, the SBS server wants to be a DNS server as well as a DHCP server. It is helpful to have the server connected on the LAN, with a working internet connection. If, as in my case, you run a separate DHCP server (the box which doles out IP addresses for workstations as they come online), then you need to disable it temporarily while setting up the SBS machine. Otherwise, SBS will complain and fail to configure its connections to the internet.

Another quirk is that when you first install the operating system everything is installed on drive C: including users shares, Sharepoint folders and Exchange mailboxes. Presumably you’ll want these to reside on a separate set of disks, or partition from the O/S partition, and there is a series of “wizards” that allow you to accomplish this without pain. Once the folders are moved to the data drive or partition, the default new user folders are created in the correct location.

The SBS server must be the top level domain controller in a Windows network. Other Windows servers can be secondary domain controllers but not primary. There is an elaborate multi-page migration methodology which is supposed to allow you to migrate users for SBS 2003 to SBS 2011, however much of the discussion on the technical boards suggests that the migration is a nightmare. So, in the two instances that I’ve been upgrading, I’m starting from scratch. I don’t went to be caught in the middle where the old installation isn’t working and the new one isn’t ready for some unknown or odd reason.

I’m still on the fence as to whether SBS is a good idea. If you’ve already got a POP eMail server going, which has Spam filtering and all the standard features provided by an ISP, managing Exchange on a local server just seems to me to provide an opportunity for additional work and maintenance. It also places all critical applications on a single piece of hardware. On the other hand, Exchange has evolved as a pretty nice calendaring and eMail server, and SharePoint, for those who can use it, works well as an internal knowledge base. SBS includes other tricks, like VPN capability, OutLook web access for accessing your OutLook mailbox from the web, and lots of management wizards which tend to ease some of the burden of maintaining things.

As a practical matter, servers are pretty reliable these days… and you have to go out of your way to practice and rehearse a disaster-recovery scenarios because they just don’t happen that often.

Spicy Server Pix

Shocking! Server Interior Revealed!

Click on the images to see them full size.

Here’s a picture of my new Dell T110 server, with the cover off.

Here’s a little more detail. You can see the two drives mounted on the left hand side, with two conveniently vacant drive bays for a couple additional SATA drives. Upper middle are the four memory slots, each filled with a 2 megabyte chip for a total of eight megabytes. All the black stuff on the right is the shroud covering the heat sink. The unit is absolutely silent.

Finally, here it is in the final configuration. I’ve got an older Maxell external USB 250 megabyte drive as a backup device. The Small Business Server 2011 backup is much improved over Windows backup software that came with earlier Windows server software…almost as good as the Mac Time Machine.

This is the first purpose-bought server that I’ve bought in more than ten years for my business. I had a couple in the nineties. Then for two or three iterations, I’d buy Dell Precision workstations to use as my personal workstation, and then I’d bump them down to be a server. All of these machines have been very reliable. I even used one of the Optiplex GX270 desktops as a production server for more than six months.

Tech Friday: More on Windows Small Business Server 2011

So, after fiddling for a week, I decided to commit, and make the SBS 2011 my real office server, at least for awhile. Amazing how much tweaking is required. Out of the box it doesn’t work out of the box, and despite the presence of numerous wizards and checklists, I find that it requires a fair amount of network knowledge to get things up and running. Ideas:

1. Under the covers, SBS 2011 uses Windows Server 2008, and Microsoft Exchange 2010.

2. In its default state, SBS assumes it will control everything, even unto DHCP. DHCP is usually enabled by default on most routers. It is the function that assigns an internal IP address to each workstation as it comes on the network. I prefer that the function stay with the router, so if the server is off for some reason, workstations can still get a legal IP address to be able to go out on to the internet. For the moment, I’ve acquiesced and given that function to SBS.

3. Since I’m planning to run Exchange, I needed to have a domain assigned to my SBS server. I have a fixed outward facing IP address from Comcast, my internet service provider. I assigned a “third level domain name” to my SBS server. This is often done for individual machines within a domain. So, for example of your company’s domain is, you mail server might be, and your sbs server might be Third level domain names do not usually cost extra. I then configured a DNS server on the SBS box using the assigned third-level domain. So far, I haven’t been able to find my domain mapping using nslookup, so I’m a little worried that something is awry.

4. The above is not to be confused with the “windows domain”, which is a single name for the local area network’s SBS machine. I named mine ghq. SBS then translates this to ghq.local which is assigned to the server’s internal ip address.

5. The next issue, is to get the network workstations connected to the server. Before doing that, the help file suggests creating the user accounts on the server. Once you do that, you can go to the individual workstations, and run the web browser, and try to find http://connect. If this is successful, then you’ll see the following screen:

This is only a link to download a “launcher.exe” file which is a script which connects the computer to the network. If there are local user profiles available, it allows you to choose one to migrate to a domain account. (Again, showing essentially that the SBS developers assume that this is the first server of a one-server network, and you would only be migrating local workstation accounts to domain accounts anyway.)

If you can’t bring up the web page, then something is misconfigured, somewhere. It took me several tries to make sure everything was working as expected. I thought the last loose end was the fact that my third level domain name hadn’t propagated yet, but between the time I started writing and the time I’ve finished, it now appears under NSLOOKUP.

Laplink PC Mover migrates Windows Users to new machines

Moving users to new Windows machines is a pain. PC Mover helps automate the process, and it even assists when you are migrating users between Windows versions, such as upgrades from Windows XP to Windows 7.

Despite being lead to believe otherwise, PC Mover does not fully migrate OutLook accounts. Rather it will migrate the account server connection but it does not migrate the OutLook messages. I confirmed this with their technical support people.

You can migrate messages by copying the OutLook.PST file from the old machine to the new machine. I found I had to do this each time I migrated a user from Windows XP to Windows 7 on a new machine. Everything else, however, migrates smoothly. To do this:

1. Make sure the new machine is connected to the network.
2. If you can (or need to) register the computer with the Microsoft Domain Controller (under Control Panel, go to System ->Computer Name, and see that the computer is a member of the domain.
3. Log in to the new computer with the target user’s domain account. This will create a new user profile on the new computer.
4. Log off, and log in again as the Domain Administrator. This will give you rights to perform the migration on the new computer.
5. Install and run PC Mover on the new computer.
6. Log in as an administrator on the old computer.
7. Install PC Mover on the old computer. (I use a thumb drive for this).
8. Run PC Mover on the old computer. It will find the new computer on the network .
9. Choose the user’s domain account on the old computer for migration to the new computer. (This is the reason for step 3 above. Before doing this, I received an error message from PC Mover on the old computer saying that it can’t migrate the domain account. I’m presuming that is because the account didn’t exist on the new computer.)
10. In general, you don’t want to migrate old versions of applications that won’t be used on the new machine. So, these being Dells, I didn’t migrate things like Roxio CD Creator from the old machine to the new one. Also, if you already have applications installed (Office 2007?) on the new machine, you don’t need to migrate the whole application again.

One thing that is helpful is there is a rollback function, so if the migration doesn’t work as expected, you can roll back and try again with different settings.

Tech Friday: Installing Windows Small Business Server 2011

I’ve received  a Dell T110 server, to install here at Microdesign GHQ.  I originally got it with two 250 gigabyte disks, I’ve been fooling around with various images and DVD disks trying several ways of installing it.  Some ideas:

1. SBS 2008 or 2011 requires a minimum of 8 megabytes of RAM, with twelve megabytes recommended for a production server. One reason I broke down and bought new hardware is that I had no recent Windows workstation that I could repurpose that could use more than 4 megabytes of RAM. I tested several candidates using the Crucial on-line tester. Then in desperation I went the Dell web site, and tried there as well. My latest workstation hardware, circa 2005, was too old. 

2. Being a cheapskate, I configured the server with two 250 gigabyte drives, thinking I’d mirror the drives. But it looks like Dell wants 9 megs or so for a utility partition, and that  the Windows installer won’t mirror anything before installation, so the operating system itself will go on a single drive. I’ll configure the second drive for data for starters, and then buy another one to mirror, so that I have mirrored data disks. This is what we ended up doing with the FreeNAS server that we’re using for student data; the O/S is on its own drive. Presumably, if that drive fails, then you could reinstall on a fresh drive, and the data remains intact on its own array. 

The only way around this predicament is to get a RAID controller that does all of the mirroring or RAID in hardware. The controller then “presents” the array as a single drive to the operating system.  

3. The higher RAM requirement also precluded playing with the O/S in a virtual machine… at least with Parallels.  This may be a mixed blessing. Even on dedicated hardware the installation is taking over an hour from DVD. So, in a VM the whole thing would be really slow.

4. Using the technique described last fall  for Windows embedded booting, I’m preparing a USB drive as an alternate boot media, just to see if that works, and if it does if it is any faster. This involves formatting the USB drive, and copying the bootloader files from the Windows setup DVD.

5. The downloaded .iso DVD image for Windows SBS 2011 is larger than the typical 4.7 gigabyte  single-sided DVD. I had to go to Staples and buy double-sided DVDs which hold 8.5 gigs. I never knew they existed, but I’m happy to see that both my Mac Superdrive, and the server DVD reader can read them.

FreeNAS: Automate Drive Mappings for Windows Users

This is the third in a series about FreeNAS, the free network attached storage application which allows you to create an inexpensive but highly capable network file server for backups, iTunes, and general file sharing. Our application is a server for student data. We want to give each student a secure folder in which to store files that they create and use when working in our student computer labs.  The two previous postings are:

Creating a FreeNAS server for student data

Adding students and creating folders 

Note that the first link picks up at the point that the FreeNAS server software has been installed on to server hardware with a minimal configuration. The FreeNAS web site has links to several tutorials as well as the official setup guide.

By the way, FreeNAS installs really nicely within a virtual machine so you can easily test it out. I’ve got it running in Parallels on my MacBook, with software RAID 5 providing redundant disk storage.

Mapping a drive to a student folder

Once I set up the student’s folder and account on the FreeNAS server, I wanted to be able to give them the opportunity to access it from any workstation in our student lab.  The cleanest way I could think of was to create an icon on the desktop which runs a script. The script does the following:
1. Asks for the student login name
2. Asks for the student’s password
3. Maps the H: drive to the student’s folder on the FreeNAS server.

Student folders are named exactly the same as the student login, and they all appear under a shared folder called “StudentData”.  The full path is /mnt/StudentData/.  So, when student Myron Kapoodle logs in with his user name mkapoodle, the script takes him to: 


Thus, when the student accesses drive H:, they find themselves in their own folder. They can’t select a folder “above” their own, and they can’t access anyone else’s folder, even if they can see it when browsing around the network neighborhood.

The Script

' VBScript to map a network drive.
' Heavily borrowed from ....
' Guy Thomas
' Larry Keyes
' ------------------------------------------------------'
Option Explicit
Dim strDriveLetter, strRemotePath, strUser, strPassword
Dim objNetwork, objShell, objFSO
Dim CheckDrive, AlreadyConnected, intDrive

' This section gets the name and password
strUser=InputBox("Enter your User Name")
strPassword=InputBox("Enter your Password")

' The section sets the variables.
strDriveLetter = "H:"
strRemotePath = "\\freenas\StudentData\" & strUser

' This sections creates two objects:
' objShell and objNetwork and counts the drives
Set objShell = WScript.CreateObject("WScript.Shell")
Set objNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set CheckDrive = objNetwork.EnumNetworkDrives()

If objFSO.DriveExists(strDriveLetter) Then
objShell.Popup "The H: Drive is already mapped"
objNetwork.RemoveNetworkDrive strDriveLetter
strRemotePath = "\\freenas\StudentData\" & strUser
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath , false, strUser, strPassword
strRemotePath = "\\freenas\StudentData\" & strUser
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath , false, strUser, strPassword
End if

'Section which actually (re)names the Mapped Drive to eliminate naming problem.
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter & "\").Self.Name = strUser
Wscript.Echo "Check : "& strDriveLetter & " for " & strUser

There is some extra stuff in there that attempts to fix an issue that appeared in Windows 7, where if the drive mapping is reused, it shows up with the name of the previous user.

Our student workstations have a single “student” local account.  Every student logs in to that account when they use the workstation. There are no individual user profiles. In some cases I have the student account log in automatically, and I’ll probably do this on all machines that use the FreeNAS network so that a student doesn’t have to log in twice…once to the desktop and once with their own user name and password on the FreeNAS server.

This script should be installed on each Windows workstation, with a desktop icon to appear on the desktop of the student account.

Two other observations and questions:

1. Obviously you can simply map a drive from the command line using Start->Run->CMD, and then at the prompt  type MAP H: /freeNAS/StudentData/mkapoodle.

2. I searched all over for a more elegant way to have a screen that came up that would ask for the name and password and then make the call to create the drive mapping. First I looked at C#, then, because Visual Basic has a “shell” command, I switched to VB. However that required a full-blown Windows installation of the .exe file, as well as a batch file which was called by the VB program. I finally decided I could live with two windows popping up; one asking for the name and another for the password.

freeNAS File Server for Student Data – Adding Students

Last time I talked about freeNAS, the free Network Attached Storage application that allows you to easily create a file server.  There are several sites online which have documentation on how to get a freeNAS server up and running. What I hadn’t found was much information about how to create a secure multi-user environment to allow students to save their data.  Here are the specs:

1. Students will access the server from a Windows XP or Windows 7 workstation
2. Students will use a mapped drive to access the freeNAS server
3. Students will have their own dedicated folder.
4. Students will be restricted to their own folder, and any subfolders that they create.
5. Students are issued a user name and password for the freeNAS password

Initial steps to prepare the server: using the freeNAS web page
1. Create a mount point on the server.  I called mine “StudentData”
2. From the Services Menu, Select CIFS
3. Create a folder share using the StudentData as the name, and the StudentData mount point.
4. From the Access menu create an access group called “Students”.

Using the freeNAS console –
3. Select 6 from menu to get to a shell prompt
4. Change to the “root” of the mounted volume.
cd /mnt/StudentData
5. Allow everyone to traverse the directory, but not to change or execute, only the root (supervisor) can delete or add.
chmod 711 /mnt/StudentData
chown root /mnt/StudentData

Organize the student user names and passwords
1. Get the full name of each student.
2. Assign passwords to each student.
3. Assign the login name for each student.  I use the first initial and last name
4. Add the student within the Gui under Access : Users and Groups
5. Add the student’s login name, and password
6. Assign the student’s home folder as /mnt/StudentData/ Note that the folder does not have to physically exist yet, although if you want to be able to choose the correct folder from the drop down box, it needs to be created on the disk beforehand. 
7. Save changes
8. Be sure to save the changes clicking on the button “Apply Changes”.

At the freeNAS console:
4. Create a folder on the server with the same name as the login name.
Example: I have a student named Myron Kapoodle, this person will get a folder called mkapoodle.

mdir /mnt/StudentData/mkapoodle

5. Give the student ownership of their folder, and allow the owner to read/write/execute within their folder.

chmod 700 /mnt/StudentData/mkapoodle
chown mkapoodle /mnt/StudentData/mkapoodle

6. At this point, the folder should be accessible from the network.  For example, from a Windows machine you can map a drive …

MAP H: \\freeNAS\StudentServer\mkapoodle
You’ll have to enter the name and password.
This may not be entirely foolproof in a lab situation with numerous students accessing the same workstation, so I’ve developed at least a partial solution which I’ll outline in a future post.