birnel.org

2013-03-17

This is the first entry in the Noah Birnel blog. I've spent a lot of time thinking about starting this blog, and what I wanted to put in it. I've put a little less time researching and setting up the software to host it.

Now, I don't have anything to say.

This is intended to be a record of my thoughts on programming, cooking, gardening, playing and listening to music, raising my daughter, and whatever else comes to mind. I have no idea what direction it will take.

We'll see what I have to add in the next few days.

2013-03-18 - re-install unpleasantness

I hosed my OpenSuse box at work last week. While I was under the desk fiddling with another box, I kicked the UPS and knocked out the power. When I rebooted, OpenSuse couldn't get out of single-user mode. Rather than try to diagnose the stupid thing, I figured I'd install something I'm a little more comfortable with. I use this box mostly as a thin-client to remote into the 25 different Windows machines I have to deal with at work, so it doesn't matter much what the OS is.

First, I tried FreeBSD, which is what I use at home. FreeBSD's installer couldn't acquire a DHCP lease.

Second, I tried Debian, which I used to use at home. Debian's installer couldn't cope with my archaic graphics card.

Third, I tried OpenBSD, which I haven't used, but figured would be FreeBSD-ish. OpenBSD installed just fine. I typed startx, and - gray checkbox screen, cursor... then back to the shell. Render error detected... blah blah blah. A quick google gave nothing that seemed immediately applicable, and I finally gave up. Time to go back to OpenSuse, which I at least knew from experience would install and run X on this ten-year-old box.

Here is the record of the things I had to do to get OpenSuse running the way I want / had it before. This is less than it was the first time around, since I had an unharmed home directory with all of my 'OpenSuse stop doing that!' dotfile kludges.

The install went ok. After install, the first thing I went to do was build dwm (my window manager) which I had already sitting with a nice config in my home directory. I typed make, and got an error message. OpenSuse doesn't have make installed by default. So I ran yast to install it. (Which is /sbin/yast2, by the way.)

An error occurred during repository initialization.
repo-update-non-oss:
http://download.opensuse.org/update/12.3-non-oss/ 
repo-update-non-oss|http://download.opensuse.org/update/1
2.3-non-oss/] Repository is not cached

Even though the installer could figure out network cards for purposes of installing - the actual installed OS needs help.

OK, I fixed that through yast. Now let's install make, and while we're at it - yes, we have no compiler. Throw in gcc, the one lib I need for dwm, and we're ready to start.

Built dwm and dmenu, and got myself a sane window manager. Now I could work a little more comfortably, and install my other needs. Back to yast for tmux, git, synergy, and rdesktop - the last being the main thing I want this computer for.

Rdesktop was no problem, but synergy is not in the repos at all. That's OK, because I had previously compiled it in my home directory. Unfortunately I had no notes on how to get it up and running, and synergy's README just points me to a wiki which no longer exists. So I ran synergyc --help, which sensibly enough told me to run it with the server's hostname. I did this, and the server complained that an unknown host was attempting to attach. I checked synergy.sgc on server, and it matched what $PS1 says on the OpenSuse box - but wait! hostname gives something different! Or rather, the same thing, but with the domain name appended. I updated synergy.sgc on the synergy host, restarted syngerys.exe, and now I can smoothly carry my pointer from the Windows 7 desktop to the OpenSuse desktop.

Finally, I made sure my screen-locker was working (gotta have that SOC2 compliance!). I had slock in $HOME/src, but I didn't see xautolock, and vaguely remembered using yast to get it. Yast, confusingly, called this xautolck. But, it was the right program.

Finally, I attempted to run visudo so sudo would stop asking me for the root password. Surprise! OpenSuse ships without visudo. So I did sudo vim /etc/sudoers with the root password. However, sudo is still asking me for the root password. At this point, more urgent work beckoned, and I had to leave off reading the man page to discover how OpenSuse has modified good old sudo. It'll have to wait for tomorrow.

And that, my friends, was re-installing OpenSuse. Maybe fixing the original problem would have been quicker after all.

[edit 2013-03-19]

Ok, google to the rescue again. visudo was present after all, just not where I thought. visudo is /usr/sbin/visudo.

sudo /usr/sbin/usermod -G wheel {username}
sudo /usr/sbin/visudo

Comment out Defaults targetpw and ALL etc. (This, I hadn't noticed or been aware of.) Uncomment %wheel line. (This, I did yesterday.) And while we're at it, s/^Defaults !insults/Defaults insults/

And now sudo works the way it ought to.

2013-03-20 an associative array in shell (sort of)

I had a little "most recent" script for this site almost complete when I realized I wanted an associative array - a hash in perl parlance. As it stood, I had:

for i in 1 7 28; do
    echo "Last $i days:"
    (find files older than $i days)
done

Which is obviously wrong for 1 days. I thought about inserting

case $i in
  1)
    echo "Last day:"
    ;;
  7)
    echo "Last week:"
    ;;
  etc
esac

but this looked immediately wordy and annoying. I considered rewriting in awk or perl, but that would be a waste of 20 perfectly good lines of shell!

Finally I came up with simulating an associative array:

for i in 1_day 7_week 28_month; do
    n=$(echo $i | sed 's/^\([1-9][0-9]*\)_.*/\1/')
    interval="$(echo $i | sed 's/^[1-9][0-9]*_//')"
    echo "Last $interval:"
    (find files older than $n days)
done

A little gross, admittedly, but it ties the number of days and the name together.

2013-03-27 installing PC-BSD

I got a nicer box to run *nix on at work. Time to try out PC-BSD.

The install was easy and smooth. There were no DHCP or X problems, and it has a 'developer' option, so I got git, rdesktop, gcc, etc right out of the box.

All I had to do was:

This might be the smoothest install of any os I've ever had.

[edit 2013-03-29]

Ok, a wee bit of trouble. I couldn't get ssh to work, in or out. sshd was running, and responding on localhost, and our sysad denied blocking anything on the internal network. Turns out PC-BSD ships with pf_enable="YES" in /etc/rc.conf. Turned that off, and IPv6 while I was in there, and ssh is good.

I still haven't figured out how to mount all the cifs shares (it is not simply a matter of copying over my old fstab lines), but that can wait for another day.