Archive for November, 2013

29 November, 2013

OSX, VMWare, CentOS, and postfix

by gorthx

(Original title: “mail server arrrgh”)

I’m running VMWare Fusion on my Mac. I often run multiple VMs for testing Postgres on various OSes, and decided it would be fun if I could get system emails from the guests on the mac host. Yeah, “it would be fun”. Even though I was working with Postfix, this task gave me flashbacks to my sendmail experiences many years ago.

This is what I had to do to get it working. This isn’t in the order I did all the steps; there was a ton of trial, error, and wtfery that went on here. Also, this is on a machine that’s behind a few firewalls; probably not something you want to configure on a server that actually has a port open on the Internet. Although it seems that most of the mailserver-related footguns are no longer enabled by default. Caveat Emptor, or something.

Host: Mac OSX Lion 10.7.5
Guests: CentOS 6.4
VMWare: Fusion 4.1.3

Set up postfix on the mac host; starting with the instructions here: http://www.phase2technology.com/blog/how-to-enable-local-smtp-server-postfix-on-os-x-leopard/

This “worked” in that the simple “telnet to port 25” test worked (see “Useful tools and commands” below), but I had to make some additional changes to receive mail from my guest OSes.

On the Mac host, I made some changes to /etc/postfix/main.cf:
myhostname = princess
mydomain = localdomain
mydestination = $myhostname, $myhostname.$mydomain, localhost.$mydomain, localhost, mailhost.$mydomain
inet_interfaces = 192.168.247.1, 127.0.0.1
mynetworks = 192.168.247.0/24, 127.0.0.0/8

The value for inet_interfaces is the IP of my vmware interface, obtained from ifconfig. You want the vmware8 interface and it should be a 192.168 address. I just added the whole vmware subnet to mynetworks parameter. You can read more about these parameters in main.cf; it is surprisingly well-commented.

I also commented out imap_submit_cred_file line as discussed here https://discussions.apple.com/thread/3247974. I’m not going to bother with this for local use.

‘postfix reload’ did not apply these changes for me; I had to explicitly stop and restart it1:
postfix stop
postfix start

On the guest:
First, I added the vmware host IP to /etc/hosts:
192.168.247.1 princess princess.localdomain mailhost mailhost.localdomain

This worked via the ‘telnet to port 25’ test method, but regular email wasn’t getting delivered; in fact, it was bouncing. Looking into the mail queue, I discovered it was trying to use a completely different IP for its mailhost.

I checked out the ‘hosts’ value in /etc/nsswitch.conf (just grep hosts /etc/nsswitch.conf) and determined that it was set to ‘files dns’, which ordinarily indicates that /etc/hosts should override dns from the vmware dns server. That wasn’t what was happening. A bit of investigation revealed that postfix was already running2, so I had to dink with it on the guests as well.

Fixed by editing /etc/postfix/main.cf (on the guest) to include this:
relayhost = mailhost.localdomain

Booyah.

Thanks to mjm for keeping me sane during this.

Useful tools/commands:
‘postfix status’ # see what postfix thinks it’s doing and get its pid, since the processes aren’t named postfix and therefor ‘ps -ef | grep post’ won’t show them :)

netstat -an | grep ‘\.25 ‘ # see if anything’s listening on port 25:
gabrielle@princess-~/
(master *) :::-->netstat -an | grep '\.25 '
tcp4 0 0 192.168.247.1.25 *.* LISTEN
tcp4 0 0 127.0.0.1.25 *.* LISTEN

mailq # see status of queued mail messages

[tail|vi|whatever] /var/log/mail.log # see connections, postfix startup/reload, etc

SMTP test program, something like this http://www.port25.com/how-to-check-an-smtp-connection-with-a-manual-telnet-session-2

You may want this as well: http://topicdesk.com/faqs/os-x-server-mail-services-faq/69-how-do-i-completely-disable-postfix-and-cyrus



1 – I’ve since been told it’s better to use launchctl to control processes.
2 – This surprised me, given the other things that are locked down/not available on the CentOS default.

Advertisements
22 November, 2013

My Current “Most Useful” Android Apps

by gorthx

I’ve only been using CamScanner for a month or so, but it’s already saved me at least an hour of dealing with a flatbed scanner. It’s very easy to photograph, crop, convert to B&W, convert to a .pdf and send them off to someone (or share via DropBox or some other method). I recommend doing the short tutorial to get a feel for what the different icons mean.

The MultcoLib app was really slow when it was first released, but has improved dramatically. Search, hold, renew – all from your phone!

Much-awaited by Portlanders, the TriMet Ticketer still has some quirks, not the least of which is that some bus drivers don’t seem to know what to do with electronic tickets. Still, it’s super-convenient if you’re stranded somewhere. As long as it wasn’t Tri-Met that stranded you there.

I started using CardioTrainer to record my running workouts after my iPod nano died1. It really grew on me – I get a map of my route, it works for a variety of activities (running, mt biking, hiking, house cleaning2), it interfaces with a HRM, etc. Unfortunately, the only way to get access to your raw data (if you haven’t rooted your phone) is to upload it to the Noom website and use their export tool. This doesn’t work with my phone (HTC One), and the company has no plans for further development. So I’m looking for an alternative, because I really like being able to fold, spindle, and mutilate my data myself. etc Strava is completely unacceptable, for reasons I won’t go into here.

The Android Ravelry app Ravulous is the only paid app I have right now; I think it’s a dollar or two, and totally worth it for those spur-of-the-moment stops into the LYS. It does have some quirks:
– you can’t access your favorites
– you can’t update projects with * in the notes (known issue, see the Ravelry forums)
If you like to take a lot of WIP photos, I recommend getting the Ravelry Photo Uploader as a companion app.


1 – More about that in a later post.
2 – No, seriously.

8 November, 2013

nook Simple Touch 18-month review

by gorthx

I’ve had my simple touch for well over a year now, and I’m still pretty happy with it, especially since I’m traveling a bunch.

Initial review
6 month review

Updates on specific issues:
– I haven’t had any further problems with mangled print; I suspect that was a feature of the particular material I was reading.
– I never did get ebrary to work correctly, but my library doesn’t offer that anymore anyway, so it’s moot.
– I said I would purchase one again (and they’re going for about $70 right now), but I’d rather get a kobo just for philosophical reasons. I like the “open ebook format” idea.

Speaking of kobo, yes you can read kobo books on your nook. You just need to download them in the Adobe epub format, and use ADE to load them. (This works just fine with Wine on Ubuntu.)

My library offers two e-lending options: OverDrive (the new incarnation of library2go) and 3M Cloud Library. They’re both now searchable from my library’s catalog and from their respective websites, which makes finding stuff to read much simpler.

I prefer OverDrive because it’s more straightforward to use.

Downloads from the 3M Cloud Library are quirky and very slow (sometimes taking multiple hours), and the app crashes frequently. I haven’t tried running it on Windows yet; my problems may be due to using it with Wine. You do need to use 3M’s app to download books to an e-reader, as the web interface doesn’t do this.

Library2go used to provide a way to “return” ebooks before the lending period was up; no more. 3M doesn’t allow that either. If you are particularly voracious you will bump up against the 5 item limit in short order. Checked-out materials become unreadable on your device once the lending period is up. (Other e-lending solutions I’ve tried allow you to keep reading the book until you re-sync your device.) This left me stranded 30 pages from the end of a book I was really enjoying. Boo.

The nook itself has started getting a bit flaky: the touchscreen randomly doesn’t work, and sometimes the hard buttons cause it to skip ahead multiple pages. I cleaned it with a soft toothbrush & eyeglasses cloth, as discussed here, and that seems to have cleared it up[1]. If not, there’s always the option to take it apart and put it back together again.

One strange thing I’ve noticed is ADE shows a lot of “missing” books that don’t show up on a regular directory listing of the nook. They seem to be duplicate file listings; even if I delete them through ADE, they show back up next time I connect the nook. Still trying to figure that piece out.


1 – This is what happens when you take electronics camping.

Tags:
1 November, 2013

Powershell.

by gorthx

Yes, here we are again, with me using a Windows machine. I can’t decide if Powershell makes having to use Windows tolerable, or just throws salt in the wounds. Powershell provides much more efficient methods of searching files and moving/renaming them than messing with Exploder, but every time I need it, I have to look up the syntax because it’s just not familiar.

Here are samples of the commands I use regularly, so they’re all in one place & I can easily C&P them from anywhere.

Find all .zip files:
Get-ChildItem -path c:\path\to\search -recurse -filter *zip

Order of the options is not important, and recurse can be shortened to rec.

Find a certain file somewhere on my hard drive:
Get-ChildItem -path c:\ -filter settings.xml -rec

I search file content a lot, so I made an alias for grep (also in my profile), because it’s easier for me to remember:
Set-Alias grep select-string

Find my notes about JSON, somewhere on my hard drive:
Get-ChildItem -path c:\ -inc *.txt -rec | grep -pattern "json"
…this is a case-insensitive search.

Convoluted way to move files (still looking for something easier):
Get-ChildItem -path c:\old\path -rec -filter *zip | foreach-object { copy-item -path $_.fulllname -destination c:\new\path }

If your paths or filenames include spaces, you’ll have to quote them, of course.

There is a way to diff files but I find the output nearly unusable.

Additional tips:
– You don’t have to type the commands in in camel case; powershell will transform it.
– There is some tab-completion available.
– I added this to my profile to save my history between sessions: https://lopsa.org/content/persistent-history-powershell. There’s no up/down arrow paging for commands from a previous session, though; you have to list the history items and then execute them from the menu. (With a command e.g. “i 2”. Yeah, that’s intuitive. Feels like the 80s in here.)

And: <esc> for <ctrl>-u.


Useful links:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb613488(v=vs.85).aspx
http://www.powershellatoms.com/desktop-management/creating-persistent-aliases-in-powershell/
http://blogs.technet.com/b/heyscriptingguy/archive/2012/02/27/use-powershell-to-copy-files-to-a-shared-drive.aspx

Tags: