Readme 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # TimekeeperEnforcement
  2. Local enforcement for the Timekeeper e107 plugin. Once a minute it looks for each
  3. monitored student's games, asks the server how many play minutes are left
  4. (`timer.php`), warns, and closes the game when there are none.
  5. Needs Java 11 or newer. Run it as root (it stops other users' processes and shows
  6. popups as them).
  7. ## Build
  8. ```bash
  9. javac -d out src/au/pfip/*.java
  10. jar --create --file TimekeeperEnforcement.jar --main-class au.pfip.Main -C out .
  11. ```
  12. ## Settings
  13. The first of these that exists is used. Use `/etc/timekeeper.inf`, owned by root and
  14. not writable by the students: a settings file they can edit defeats the monitoring.
  15. 1. `/etc/timekeeper.inf`
  16. 2. `~/timekeeper.inf`
  17. 3. `~/.config/timekeeper/timekeeper.inf`
  18. 4. `./timekeeper.inf`
  19. If none exists, a new one is written to `~/.config/timekeeper/timekeeper.inf` with the
  20. defaults below. It is Java XML properties format.
  21. | Key | Default | Meaning |
  22. |---|---|---|
  23. | `UsersToMonitor` | *(empty, must be set)* | Comma separated accounts to watch, e.g. `alice,bob` |
  24. | `TimekeeperActive` | `true` | `false` makes the program wait 10 minutes and exit |
  25. | `ExemptNetwork` | *(empty = none)* | Network name where enforcement is off (checked at start-up only; anyone can name a hotspot after a network) |
  26. | `OfflineChecksBeforeKill` | `5` | Failed server checks in a row before a game is closed (`1` = close at once) |
  27. | `GamesRefreshMinutes` | `60` | How often the games list is fetched again |
  28. | `GamesURL`, `PlaytimeURL` | the overlord URLs | Server endpoints |
  29. | `LogFilePath` | home folder | Where `timekeeper<day>.log` is written |
  30. The games list is cached in `games.cache` next to the settings file and used when the
  31. server can't be reached.
  32. ## systemd
  33. ```ini
  34. [Unit]
  35. Description=Timekeeper enforcement
  36. After=network-online.target
  37. Wants=network-online.target
  38. [Service]
  39. ExecStart=/usr/bin/java -jar /opt/timekeeper/TimekeeperEnforcement.jar
  40. Restart=always
  41. RestartSec=30
  42. User=root
  43. [Install]
  44. WantedBy=multi-user.target
  45. ```
  46. ## Tests
  47. `test/au/pfip/Harness.java` and `Harness2.java` run against a fake local server and
  48. start and stop throwaway `sleep` processes owned by the current user:
  49. ```bash
  50. javac -d out src/au/pfip/*.java test/au/pfip/*.java
  51. java -cp out au.pfip.Harness
  52. java -cp out au.pfip.Harness2
  53. ```