Simple tool to detect the (network) neighborhood based on the MAC of the gateway. Based on the detection result reconfigure/start/stop services.
Find a file
2025-08-20 17:50:59 +02:00
doc lint 2025-08-18 13:45:21 +02:00
examples chg: use subcommands 2025-08-17 23:04:22 +02:00
internal src: consistent naming 2025-08-20 17:22:30 +02:00
.golangci.yml Squashed commit of the following: 2025-08-15 17:27:34 +02:00
go.mod go: ignore local/ directory 2025-08-17 23:08:09 +02:00
go.sum new: add go tool go-md2man 2025-08-17 21:36:38 +02:00
LICENSE.txt Squashed commit of the following: 2025-08-15 17:27:34 +02:00
main.go src: consistent naming 2025-08-20 17:22:30 +02:00
README.md src: link README to doc/*.md 2025-08-20 17:50:59 +02:00
whereami.8 chg: use subcommands 2025-08-17 23:04:22 +02:00

WHEREAMI 8 "August 2025" "local" "local system manager commands"

whereami - detect current network location and act upon it

SYNOPSIS

whereami [options] list|status|run|register [options]

DESCRIPTION

whereami tries to detect the current network (location). It does so by getting the MAC address of the current default gateway and stops/starts services according the location.

GLOBAL OPTIONS

The following options apply to all commands.

-root dir: The root directory for the links. Defaults to "/".

-verbose: Be more verbose about what's going on.

COMMANDS

The operational mode is selected by one of the following commands.

  • list: List the available locations and exit.
  • run: Switch the current location and exit. This command accepts the -force option.
  • status: Show the current location (and the "running" one, if configured).
  • register name: Register the current location for name. The configuration dir name must exist.

FILES

The static following layout is used:

/etc/whereami
├── ether:00:0D:B9:35:A3:60 -> office
├── ether:24:69:A5:D6:3C:B7 -> home
├── ip:1.1.1.1 -> home
├── ip:1.1.1.* -> home
├── home
│   ├── run.d
│   │   └── 00local
│   └── squid.conf
└── office
    ├── run.d
    │   └── 00local
    └── squid.conf

The runtime directory contains a symlink, e.g.:

/run/whereami -> /etc/whereami/home

And for specific configuration (as for squid in our example) we use

/etc/squid/local.conf -> /run/whereami/squid.conf

INSTALLATION

The whereami tool needs to be on any change in the network setup. For NetworkManager a good place is /etc/NetworkManager/dispatcher.d/02local as

#!/bin/sh
exec systemctl-run --description "whereami for $1" whereami -v

AUTHOR

Heiko Schlittermann hs@schlittermann.de, https://schlittermann.de