How to mysqldump a single table's entries for the previous day, encrypt them with GPG, and mail them home OR The longest shell command of my career
Topic: Technology
6:17 am EST, Mar 6, 2007
mysqldump --user=me --password=pass --no-create-db --no-create-info -w 'SUBSTR(myTimeStampField FROM 1 FOR 10) = SUBSTR(DATE_SUB(now(), INTERVAL 1 DAY) FROM 1 FOR 10)' myDatabase myTable | gpg --yes -e -a -o - -r me@myaddress.com | mailx -s "Entries in myDatabase.myTable for `date`" me@myaddress.com
If you export your public key and copy it to the database server for encryption, you will need to sign it with that server's key. So, generate a key with 'gpg --gen-key' and then sign your public key with 'gpg --lsign me@myaddress'
I was totally unable to get gpg on OS X or solaris to manually adjust the trust of my public key, so signing it was the only choice. It works.
Now, I know this is just two pipes and single set of back-ticks but... if you knew how long it took to get gpg to use my public key, and to get it to work without asking me if I was sure, and to get mysqldump to take a where clause, and to get it to generate useful output for day - 1 after I happened to fix the timezone for that server, and to be sure it worked with the delay in mail delivery...
Solaris Things: How small can you make Open Solaris - Part 1
Topic: Technology
2:02 am EST, Mar 3, 2007
How small can you make Open Solaris - Part 1
Solaris started its life as operating system for workstations and then progressed to servers. It has always been an operating system dominated by features, showing Sun's R&D capability. This is great if you are installing a server or a desktop, but has far too many features for building an appliance. Luckily the installing comes with some reduced installation clusters which tries to bring the installation down to the bare minimum. Unfortunately the last time I looked the smallest install was still several hundred megabytes. Linux on the other hand has had a project going for while now called "Damn Small Linux", which strips Linux down to around 50 megabytes. This is a perfect base to start building an appliance, build your own distro, or strip the kernel down further for an embedded device.
Can Solaris become as small as "Damn Small Linux". The answer is a resounding yes (and probably smaller). Lets investigate how this can be done. The first thing to do is to state the goal, which is to be able to successfully boot into a shell and execute a simple command such as 'ls'. The logical place to start is with the smallest running version of Solaris supplied by Sun. If you have a x86 grub version of Solaris you will find a 52 megabyte file in your /boot directory called x86.miniroot-safe. This file is a gzipped UFS image that is booted when you select "Solaris failsafe" from the grub menu. Using it to boot to single user mode will mount the root filesystem and give you a root shell. It also contains the code to start a Solaris installation.
Now we have found an ideal candidate, lets start ripping it apart. The first step is to copy it (as you may need it if you break something), and setup new menu option in grub.
FreeNAS is a free NAS (Network-Attached Storage) server, supporting: CIFS (samba), FTP, NFS, AFP, RSYNC, iSCSI protocols, S.M.A.R.T., local user authentication, Software RAID (0,1,5) with a Full WEB configuration interface. FreeNAS takes less than 32MB once installed on Compact Flash, hard drive or USB key. The minimal FreeBSD distribution, Web interface, PHP scripts and documentation are based on M0n0wall.
“To hell with the advances in computers,” he says after he finishes singing. “YOU are supposed to advance and become, not the computers. Find out what’s inside you. And don’t kill anybody.
“There are no factories any more. Where are the jobs supposed to come from? There’s nothing for people to do anymore. We need to ask the Seminoles: ‘what the hell did you do?’’ after the tribe’s traditional livelihood was taken away.
Answering questions written in by students, he explains the meaning of life. “We should be kind to each other. Be civil. And appreciate the good moments by saying ‘If this isn’t nice, what is?’
“You’re awful cute” he says to someone in the front row. He grins and looks around. “If this isn’t nice, what is?
“You’re all perfectly safe, by the way. I took off my shoes at the airport. The terrorists hate the smell of feet.
“We are here on Earth to fart around,” he explains, and then embarks on a soliloquy about the joys of going to the store to buy an envelope. One talks to the people there, comments on the “silly-looking dog,” finds all sorts of adventures along the way.
As for being a midwesterner, he recalls his roots in nearby Indianapolis, a heartland town, the next one west of here. “I’m a fresh water person. When I swim in the ocean, I feel like I’m swimming in chicken soup. Who wants to swim in flavored water?”
A key to great writing, he adds, is to “never use semi-colons. What are they good for? What are you supposed to do with them? You’re reading along, and then suddenly, there it is. What does it mean? All semi-colons do is suggest you’ve been to college.”
Make sure, he adds, “that your reader is having a good time. Get to the who, when, where, what right away, so the reader knows what is going on.”
As for making money, “war is a very profitable thing for a few people. Jesus used to be so merciful and loving of the poor. But now he’s a Republican.
“Our economy today is not capitalism. It’s casino-ism. That’s all the stock market is about. Gambling.
I like Sun products. I use Solaris. I buy Sun Servers. I recommend Sun products. I tell people to buy Sun stock. I have had good experiences with Sun Support. I participate in the local OpenSolaris Users' Group. I believe in Sun as a company.
But Sun's website is a piece of shit. It is terrible. It is difficult to navigate, downloading anything is a pain, finding anything is impossible, and if anything is broken you can always rely on the outsourced web staff to not fix the problem. Which happens frequently. I have had Sun sales staff inform me that ever since their website was outsourced, these problems have plagued them. Gee whiz, who would have thought?
I want to believe in Sun, but its hard when they make the ENORMOUS MISTAKE of outsourcing their website development. They are a technology company, and their website BLOWS.
So click there and it still says "From $249 (US)." Now click "Customize it." It starts at $374. There is a non-optional license for each Sunray 2.
One moment it starts at $249. The next moment it is $374. What kind of total bullshit is that? The kind that makes me buy from someone else, thats what kind.
Of all the companies on planet earth, Sun has the LEAST excuse to have a bad, slow, crappy website. And yet they do. And they're supposed to be recovering. Well guess what? By the looks of their website, Sun is rotten. Rotten to the core.
Fire whoever was in charge of this, and get someone competent. And hire a westerner or two in the website department.