office-days-agent

command module
v0.0.0-...-6d8ba56 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

README

Office Days Agent

This is the background agent for the automated office days tracker.

What does it do?

  1. it periodically checks if you are connected to the office Wi-Fi, and records the days (it does not store any other data)
  2. it provides a REST API for other processes to use this information

Prerequisites

Important:

  • On Mac you must setup wifi-unredactor first.
  • On Linux you should install the iw package.

Installation

You can use the included Makefile to build and install the agent:

make

Note: do not use sudo to execute the makefile.

In order to check if the agent is running properly, you can use launchctl on Mac:

launchctl list | grep office-days-agent

...or use systemctl on Linux:

systemctl --user status office-days-agent

You should see the agent and the associated process id listed in the response. If you don't see it, check the Troubleshooting section of this readme.

API

Path Method Description
/list GET Get the stored days. Example response: {"20240101": true, "20240102": false}
/clear POST Clear the stored days.

By default, the API can be reached on http://localhost:23460/.

Troubleshooting

I can't see the agent in the list

Do not use sudo for installing or querying launchctl, otherwise the agent will be installed as a system daemon isntead of a user-agent. This will cause problems when executing wifi-unredactor as well as when writing/reading the database.

How can I check if the agent is running properly?
  1. check if the binary is installed correctly to ~/.local/bin
  2. (darwin) check if the launch agent is installed properly: ~/Library/LaunchAgents/hu.okki.office-days-agent.plist.
  3. (linux) check the presence & status of the systemd user service
  4. check that the agent has started up (see previous step)
  5. check if there is anything in the log files:
    1. /tmp/office-days-agent-stdout.log
    2. /tmp/office-days-agent-stderr.log

FAQ

How can I change the Office Wi-Fi Name?

In case you want the agent to monitor a different SSID, you can use the OFFICE_DAYS_WIFI_NAME environment variable. If you used the Mac Launch Agent, you will need to change this environment variable in ~/Library/LaunchAgents/hu.okki.office-days-agent.plist.

What configuration options are supported?

Here is a comprehensive list:

Environment Variable Mandatory/Default Description
OFFICE_DAYS_API_SERVER_PORT 23460 the port the api server is opened on
OFFICE_DAYS_DB_PATH mandatory database for the agent
OFFICE_DAYS_POLL_INTERVAL_SECONDS 600 how frequently the agent checks the wifi ssid
OFFICE_DAYS_WIFI_NAME mandatory the office wifi ssid
OFFICE_DAYS_WIFI_DEVICE_NAME en0 the wireless network adapter name

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL