This entry is to let Google know that a MacBook Pro with serial number W89420K47XK has been stolen. Last known whereabouts: Dallas, TX.
If you have a bunch of VMWare Fusion virtual machines running, you can suspend them programmatically using vmrun and rsync them to a mounted volume. Then, with the copy completed, you can resume the virtual machines.
#!/bin/bash BACKUPDIR=/Volumes/Backup/VMs /Library/Application\ Support/VMware\ Fusion/vmrun list | tail -n +2 | while read VM do echo "Suspending $VM" time /Library/Application\ Support/VMware\ Fusion/vmrun -T fusion suspend "$VM" echo "Suspended $VM" DIR=`dirname "$VM"` echo "Rsyncing $DIR" rsync -av "$DIR" "$BACKUPDIR" echo "Resuming $VM" time /Library/Application\ Support/VMware\ Fusion/vmrun -T fusion start "$VM" echo "Resumed $VM" doneNote: this hung on Windows VMs until I updated VMWare Tools to the latest version on the guest. The above is currently working on Fusion 3.1 for RHEL5 and Windows 2008 R2 Server guests.
I had a need today to batch-change a lot of database connection strings in Drupal installations. You might need to do this if you have a lot of sites and are switching from webserver-and-database-server-on-the-same-box to Drupal with a separate database server. Here were some handy shell commands that I used.
Find all the settings.php files in this directory tree:
find /var/www/html -name settings.php -print
Show all the current database connection strings (make sure no one's looking over your shoulder!):
find . -name settings.php -exec grep -nH ^\$db_url {} \;
The grep finds lines beginning with $db_url. The -n switch prints out the line number of the match; the -H switch prints the filepath. Sample output:
./foo/site1/sites/default/settings.php:93:$db_url = 'mysql://myuser:secret@localhost/database1';
./foo/site2/sites/default/settings.php:93:$db_url = 'mysql://myotheruser:othersecret@localhost/database2';
...
Now, change the sites from pointing to localhost to pointing to database.example.com:
find /var/www/html -name settings.php -exec sed -i '80,95s#t@localhost#t@database.example.com#' {} \;
Translation to English: descend recursively into the /var/www/html directory. When you find a file named settings.php, look in lines 80-95 of the file. If you find a string that contains t@localhost, change it to t@database.example.com. Save the file, overwriting the file that is currently there (that's the -i switch to sed). The # characters are delimiters.
Note that I'm cheating here, because I happen to know that all passwords end with the letter t which makes my string matching easier.
I have a busy web frontend server many files in a single directory. The server is running FreeBSD 8 amd64. Here is the result of changing the sysctl vfs.ufs.dirhash_maxmem to 67108864. Note the change in system (red) area. The vertical arrow shows when the change was made:
I updated two servers using my normal upgrade process and all is well. My process:
I assume awstats (and awstats-selinux) are already installed.
Step 1: Install the most excellent GeoLite data from MaxMind
mkdir /usr/local/share/GeoIP
cd /usr/local/share/GeoIP
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
gunzip *gz
Step 2: Install the GeoIP C API
There will be a dependency on zlib so make sure zlib-devel is installed:
yum install zlib-devel
Now download and compile:
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz
tar xvzf GeoIP-1.4.6.tar.gz
cd GeoIP-1.4.6
./configure
make
make check
sudo make install
Make it possible to link against the geoip library:
sudo echo '/usr/local/lib' > /etc/ld.so.conf.d/geoip.conf
sudo ldconfig
Step 3: Install the Geo::IP Perl Module
cd ~
wget http://geolite.maxmind.com/download/geoip/api/perl/Geo-IP-1.38.tar.gz
tar xzvf Geo-IP-1.38.tar.gz
cd Geo-IP-1.38
perl Makefile.PL LIBS='-L/usr/local/lib'
make
make test
sudo make install
Step 4: Enable the GeoIP Plugin
Edit /etc/awstats/awstats.yourdomain.conf to add these lines:
LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"
LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoLiteCity.dat"
LoadPlugin="geoip_org_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoIPASNum.dat"
Reference: GeoIP Information for AWStats
Speedup Awstats by using GeoIP instead of DNS Lookups
I've been buying G-DRIVE external hard drives since firing LaCie. G-Tech drives were formerly made by Fabrik, which was bought out by Hitachi last year.
I had my first G-DRIVE hard drive failure happen, on a 1TB G-DRIVE Q (for quad interface: eSATA, USB 2.0, and Firewire 400/800). There was no data loss since this particular drive was the primary drive on a Mac Mini, and I've been using the excellent SuperDuper! to do scheduled cloning from the external drive to the Mini's internal drive. Thus, when the external hard drive failed, the Mini silently failed over to the internal drive. But I digress.
Two weeks after getting an RMA number and shipping the drive back, I received a package from Hitachi. I expected the old enclosure back, possibly with a refurbished drive in it. Instead, a brand-new 2TB drive. That's right, 2TB instead of 1TB. New power supply and everything. Even a Firewire 400-to-800 cable enclosed.
Thanks, Hitachi.
Here are the slides and the two testing modules from my presentation at DrupalCon San Francisco 2010. The modules run on Drupal 7.
Slides from Batch vs Queue: an API Smackdown (5.8 MB PDF)
I'm doing some experimentation with JpGraph on Red Hat Enterprise Linux 5.5. So I wanted to install some TrueType fonts. Here's a step-by-step of how I did it, following the superb instructions given here.
Installed the rpm-build utility.
# yum install rpm-build
Then installed the cabextract utility, available on EPEL.
# yum install cabextract
Downloaded the latest spec file for msttcorefonts:
curl -O http://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec
Created a ~/.rpmmacros file containing one line:
%_topdir %(echo $HOME)/rpmbuild
Then I followed the instructions to create necessary directories:
$ mkdir -p ~/rpmbuild/BUILD
$ mkdir -p ~/rpmbuild/RPMS/noarch
Built the rpm:
$ rpmbuild -bb msttcorefonts-2.0-1.noarch.rpm
For me, it stopped once during the build with a 500 error from Sourceforge:
Resolving hivelocity.dl.sourceforge.net... 74.50.111.26
Connecting to hivelocity.dl.sourceforge.net|74.50.111.26|:80... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2010-04-12 13:26:10 ERROR 500: Internal Server Error.
error: Bad exit status from /var/tmp/rpm-tmp.51326 (%prep)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.51326 (%prep)
I simply ran the previous command again and it worked.
Installed the rpm as root:
# rpm -ivh /home/john/rpmbuild/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm
I now see that the fonts are in /usr/share/
# find /usr -name *ttf -print
...
/usr/share/fonts/msttcorefonts/georgiaz.ttf
/usr/share/fonts/msttcorefonts/comic.ttf
/usr/share/fonts/msttcorefonts/times.ttf
/usr/share/fonts/msttcorefonts/timesbi.ttf
/usr/share/fonts/msttcorefonts/impact.ttf
/usr/share/fonts/msttcorefonts/verdanaz.ttf
/usr/share/fonts/msttcorefonts/georgiab.ttf
/usr/share/fonts/msttcorefonts/arialbi.ttf
/usr/share/fonts/msttcorefonts/arialbd.ttf
/usr/share/fonts/msttcorefonts/ariblk.ttf
/usr/share/fonts/msttcorefonts/trebucbd.ttf
/usr/share/fonts/msttcorefonts/couri.ttf
/usr/share/fonts/msttcorefonts/trebuc.ttf
/usr/share/fonts/msttcorefonts/timesi.ttf
/usr/share/fonts/msttcorefonts/verdanab.ttf
/usr/share/fonts/msttcorefonts/timesbd.ttf
/usr/share/fonts/msttcorefonts/courbd.ttf
/usr/share/fonts/msttcorefonts/arial.ttf
/usr/share/fonts/msttcorefonts/georgiai.ttf
/usr/share/fonts/msttcorefonts/ariali.ttf
/usr/share/fonts/msttcorefonts/courbi.ttf
/usr/share/fonts/msttcorefonts/comicbd.ttf
/usr/share/fonts/msttcorefonts/webdings.ttf
/usr/share/fonts/msttcorefonts/trebucbi.ttf
/usr/share/fonts/msttcorefonts/georgia.ttf
/usr/share/fonts/msttcorefonts/trebucit.ttf
/usr/share/fonts/msttcorefonts/cour.ttf
/usr/share/fonts/msttcorefonts/tahoma.ttf
/usr/share/fonts/msttcorefonts/verdanai.ttf
/usr/share/fonts/msttcorefonts/verdana.ttf
/usr/share/fonts/msttcorefonts/andalemo.ttf
...
Reference: An easy way to install Microsoft's TrueType core fonts on linux