my half-arsed attempt at blogging
ENV
apt-listbugs and suite-wide scripted upgrades
Nov 28th
Having finally got fed up with logging in, individually, to upgrade each of the no2id machines and jails, a bit ago, I decided to write a script to do the ‘hard work’ for me.
This worked fine, until today, when I noticed apt-listbugs complaining, and causing the script to fail to dist-upgrade.
Not a problem, thought I. I’m sure others have had this issue too. Being lazy, I thought first point of call would be the internets. I’d have thought something like:
"DEBIAN_FRONTEND=noninteractive" "apt-listbugs"
might have done the trick. It didn’t (that I could find).
So I went back to doing what a lot of the new-breed of ‘devops’ fail to do, and what I’m quite hypocritical of; looking at the manpage.
The manpage provides us with this gem:
ENVIRONMENT VARIABLES
o APT_LISTBUGS_FRONTEND If this variable is set to “none”
apt-listbugs will not execute at all, this might be useful if
you would like to script the use of a program that calls
apt-listbugs.
So there we go.
for M in $MACHINES
do
echo "Connecting to ${M}.no2id.net"
- ssh root@${M}.no2id.net 'export TERM=xterm; export DEBIAN_FRONTEND=noninteractive; apt-get update && echo "" && echo "" && echo "This is "'${M}'".no2id.net" && echo "" && echo "" && apt-get dist-upgrade'
+ ssh root@${M}.no2id.net 'export TERM=xterm; export DEBIAN_FRONTEND=noninteractive; export APT_LISTBUGS_FRONTEND=none; apt-get update && echo "" && echo "" && echo "This is "'${M}'".no2id.net" && echo "" && echo "" && apt-get dist-upgrade'
done
hopefully, this will help others, whose first port of call is the internets, and not manpages.
You may, however be sensible — and have had the time to roll out Puppet (ugh, when did they change their website! Why‽) or Chef though.
Conditional Prompt colo(u)rs
Dec 23rd
I often work on several different machines, for different projects and things. It’s bloody annoying when I get the wrong machine!
I thought. I know what, I’ll make all of these machines use a colored prompt, and make that lot of machines use a different one.
(At this point, I should say that my dotfiles, and a variety of other things are kept in a subversion repo. Most of those bits are my-eyes-only (particularly a lot of the very badly/hastily thrown together scripts), but a few bits I’m gradually releasing.)
After mentioning this on twitter, a couple of people have been interested in how I did it.
The solution is quite easy, work out the hostname, and from that determine the ‘class’ of machine, and then apply some colors. The archwiki was useful in getting out the colors to use; along with underlining, and emboldening (I never use underlining, except in manuscript: ghastly thing that obscures text).
Whilst not perfect (the color parts could be set as a variable, and then passed to the PS1 line; I could have used “else” clauses…), it works. For me, so, erm, here’s my .bashrc — you want from the # work out machine name/domain: line.
A simple switch wotsits in screen(1), and
$ cd ~/pseudohome && svn up
followed with a
$ . .bashrc
is how I deploy (some people have an ’svn up’ in their start-up scripts, I don’t).
Comments here, if you want to.
