17 April

Getting the current session name from tmux

Are you talking to me?

Had the little mystery of how to get the name of the current session in tmux into a shell script. Why? Because that script should talk to the same pane/window/session again later. Hacking and searching around a bit, this is what I came up with:

SESSION=`tmux list-panes -F '#{session_name}'`

Funny enough it uses the list-panes command, which by default lists only the panes of the current window and session. Then, using the -F format string, we can tell it to give us the session name only.

Later I can use this in the script like this:

tmux select-window -t$SESSION:window_name

... and there shouldn't be any mistakes as to which session I'm talking to.

Posted by betabug at 21:00 | Comments (1) | Trackbacks (0)
14 April

openbsd ipsec.conf roadwarrior puzzlestone

Took me a while to notice...

When setting up the IPSec NAT on my "roadwarrior" laptop, I was baffled for quite some time with the question: How do I set up the src address, without having to edit ipsec.conf whenever I am on a different network in a different RFC1918 private natted address range? One day I would be on and the next on

# this can't be it!! wtf?
# ike dynamic from iwn0 to any
# ike dynamic from iwn0 to any
ike dynamic from iwn0 to any

Add up DHCP on all those networks and this really can't be it.

Turns out the information / solution actually is in the man page (yay for OpenBSD man pages):

Addresses can be specified in CIDR notation (matching netblocks), as
symbolic host names, interface names, or interface group names.

So basically what you can do is to start your ipsec.conf setup with your interface name as something like:

ike dynamic esp from iwn0 to any

Which means that the ipsec tunnel will get set up on whatever address that interface gets assigned. And you could even create an interface group "vpn" to cover both your wifi and ethernet interfaces. Neat.

The next thing to find out for me is how I can do from iwn0 to any but not to my local subnet... but I guess I'll figure that out too some day.

BTW: having OpenBSD IPSec on both sides of my VPN made the setup really easy.

Posted by betabug at 17:55 | Comments (0) | Trackbacks (0)
31 March

xrandr example script

Switching an extra VGA monitor around on an OpenBSD laptop

To set up and configure an external monitor in X on OpenBSD, we typically use xrandr(1). There are some GUI tools (like lxrandr, from ports) to "help" with that, but for me, a very simple shell script can do the job:


# TODO: handle HDMI-3 / 4 / 5

case "$1" in
    xrandr --output VGA --same-as LVDS
    xrandr --output LVDS --off --output VGA --auto
    # external monitor is off, internal on
    xrandr --output LVDS --auto --output VGA --off
    xrandr --output VGA --auto --right-of LVDS
    xrandr --output VGA --auto --left-of LVDS
    # default fall through ...
    # external monitor is off, internal on
    xrandr --output LVDS --auto --output VGA --off

Usage: I save this as a script with the name "monitor" and then use it as one of monitor mirror, monitor right, ... etc.

When a more special setup is needed, this script can serve as a cheat sheet. Further than that, the xrandr man page is pretty good.

Differences to lxrandr: lxrandr doesn't do dual monitor setups (the ones where the extra monitor is used in addition to the internal one), it only does mirroring and "choose one of them". On the other hand, lxrandr handles changing of the resolutions. Also my script is only set up for the VGA port, if I ever get around to hook up something to the displayport, I'll have to adapt it.

Posted by betabug at 20:12 | Comments (0) | Trackbacks (0)
24 February

watch for syslog.conf

I've been bitten more than once by this so I have to write this down.
The problem: spamd wasn't logging to /var/log/spamd even though I followed the spamd(8) man page which says:

daemon.err;daemon.warn;daemon.info /var/log/spamd

What I didn't pay attention is the way that syslog.conf(5) seperates fields:

The selector field is separated from the action field by one or more tab characters.

So the problem was that I simply copy/paste 'ing and with it not seperating fields with tab.
I found this message by Jared which suggested:

sed -ne '/spam/l' /etc/syslog.conf

This will show you 'tabs' (\t) which in my case were missing.
Hope this helps others.

Posted by rgouveia at 22:08 | Comments (0) | Trackbacks (0)