FreeBSD 4.x always annoyed me the way it did filesystem checks when something wasn't unmounted properly. If for some reason you lost power, or patience--it happens even with best of OSes--you'd be dropped to an sh prompt before the boot process went any further. You were then expected to just know what to do. Which was to run fsck. I remember the big freakout I had the first time this happened.
Eventually, I just got used to running fsck manually in such situations. Which was bad for servers that needed to come back up without manual intervention. And only slightly less annoying than that old Windows scandisk feature that would take years to determine that your hardrive was perfectly fine.
With 5.x FreeBSD boots right up & then runs fsck in the background if there is a filesystem problem, after a 60 second delay. Only rarely is there a problem, and these are automatically fixed, the filesystems marked clean, and you hardly notice. Definitely the way to do it.
So, check this out: I had a server running here at work off a regular powercord, no surge protector or anything like that. It had only been up a week until a power surge fried the mother board today. Luckily, I dropped the hard drive into another server, made a few small changes to reflect the NIC in the new machine, and got it up & running again.
Very rough sketch of an idea for some scripts that seamlessly handle IP changes & other network interface changes on bsd or linux seamlessly. The problem with an ip change is that it usually involves (1) rebooting to make the settings take effect and/or (2) losing your ssh connection to the machine, so that if something goes wrong, you have to physically visit the server to bring it back up.
The first script will install a one-shot crontab entry for you at a specified time in the future. The second script, run by cron, will make the necessary ifconfig changes. If the interface doesn't come up under the new changes, it will back them out & revert to the original ones. You'll probably lose your ssh connection but you'll have some guarantee the machine will come back up in a few minutes.
A little follow-up on my decision to by a Toshiba A45-S150 laptop. Here are some things I really don't like about it:
Here's an idea I have for a low bandwidth diff of two remote files. You first compute a checksum for the entire file on each end, and then exchange these checksums. If they are the same, the files are the same (with high probability depending on the checksum algorithm). If, not split the files in half and exchange checksums for the halves. Lather, rinse, repeat: essentially, do a binary search to narrow down those chunks of the file that actually differ, then transfer those differences.
Maybe this idea is kindergarten level and rsync / cvs / whatever else have been using it for years now. Will check on this.
Tonight my spacebar stopped working when attacked from the right side. I was so frustrated I bought a new laptop, the Toshiba A45-S150. It's not as much of an impulse buy as I would like you to believe...have had the mouse poised over the buy now button for some time. Now that I've finally got this Thinkpad configured to my satisfaction--it only took me two or three weeks--I must needs return it, for it is not actually mine. Sigh.
Here's the deal I got. This will look silly I'm sure in under a year but I document it here for posterity. About it...
Incidentally I want to just mention that I fixed the spacebar on the Thinkpad. Pried off the key cover with a screw driver & sure enough there was a crumb under the right-side spring. My fears about not being able to replace the cover were unfounded: after positioning it over the key and pressing down, it snapped into place again.
cd /usr/local/openssl/certs /usr/local/openssl/misc/CA.pl -newcert mv newreq.pem yourdomain.crt chmod 400 yourdomain.crt
SSLCertificateFile /usr/local/openssl/certs/yourdomain.crt
# SSLCertificateKeyFile /usr/local/etc/apache2/ssl.key/server.key
apachectl stop apachectl startssl
cd /usr/ports/www/apache2 make install WITH_BERKELEYDB=db4
cd /usr/local/lib ln -s apache2/libapr-0.so.9 libapr-0.so.9 ln -s apache2/libaprutil-0.so.9 libaprutil-0.so.9
cd /usr/ports/devel/subversion make install -DWITH_SVNSERVE_WRAPPER -DWITH_APACHE2_APR
Oops, crap. One of the first ports I install on a new FreeBSD server is cvsup. However by default this pulls in a lot of X11 dependencies, which I don't even want to have around, since this is just a web and project services machine. Next time remember to do "make install -DWITHOUT_X11" for cvsup.
my $params = { 'firstname' => 'John',
'lastname' => 'Doe',
'email' => 'jdoe@fake.com',
'account.username' => 'jdoe',
'account.password' => 'foobar',
'account.settings.enabled' => 1 };
my $user = { firstname => 'John',
lastname => 'Doe',
email => 'jdoe@fake.com',
account => { username => 'jdoe',
password => 'foobar',
settings => { enabled => 1 } } };
my $against = { 'firstname' => qr/\w+/,
'lastname' => qr/\w+/,
'email' => qr/^\s*[\w]+\@[\w\.]+\s*$/,
'account' => { 'username' => qr/^[\w]{4,}$/,
'password' => [ qr/^.{8,}$/,
qr/[a-z]/,
qr/[A-Z]/,
qr/\d/,
qr/[\!-\.]/ ] } };
use CGI;
use Struct::Marshaller;
use Struct::Validator;
use strict;
my $q = CGI->new();
my $marshaller = Struct::Marshaller->new();
my $validator = Struct::Validator->new();
my $user = $marshaller->unmarshal($q->Vars());
my $results = $validator->validate($user, $against);
if (!$validator->is_valid($results)) {
# do something
}