dimsumlabs / hackman

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NaNNaNNaNNaNNaNNaNNaNNaN Hackman!

The Dim Sum Labs payment, door and membership system. Allows members to register their (cash or paypal) payment and receive login credentials. These can be used to open the door via either web interface or rfid card.

The system's workflow

payments

  1. The dsl-accounts repository is updated by the space orga when payments are made.
  2. The hackman-paymentimport service (included here) downloads the dsl-accounts data every hour.

missing payments

If there is an issue with the paymentimport or the space orga have missed an update. You can submit that you have paid.

  1. Go to https://door.dimsumlabs.com/ and log in with your credentials.
  2. Go to Account actions
  3. Select the month you are paying for and inform the door of your payment

Note: Informing the door this way is temporary and will only last until the next payment import.

To-Do

  • UDEV-based autostart for the components that depend on hardware:
    • hackman-rfidd expects to find a usb serial adaptor
    • dsl-lights expects to find a pimoroni Mote Host USB device

Hacking

Hackman uses Poetry as it's Python dependency manager.

Using direnv

To use direnv to manage the development environment simply run direnv allow. This will call out to Nix and Poetry internally.

Manual hacking

Install Poetry and manage the development manually, it's left as an exercise reader how that is done.

Prerequisites

Installation on raspberry pi

The intent is to have a documented process that depends only on the Raspberry Pi hardware and thus can be easily tested or trialed. That being said, there are several ways to speed up or otherwise improve on this in the future.

  1. Start with a fresh raspian lite bullseye install image, with ssh enabled
  2. Dont forget to change the passwords and set up any extra users on the pi
  3. sudo apt-get update && sudo apt-get -y upgrade
  4. sudo apt install -y -f hackman_0.1.0-1_armhf.deb
  5. reboot to activate all changes
  6. Never run anything manually again \o/

Upgrades

  1. This auto-updates from the latest Github release automatically.
  2. If that were to fail you can manually install the updated deb.

Day to Day Operations

  • Run a payment import right now: systemctl start hackman-paymentimport.service
  • Check the last payment import: ls -al /var/lib/hackman/db/payments.json
  • Dump all the users and their paid-until dates: hackman-manage paymentlist

Deployment

After CI builds a new image, perform these steps to prepare a new SD card:

  1. burn the image to SD card (e.g. balenaEtcher)
  2. pg_dump the old database pg_dump -Ft postgresql://hackman:hackman@localhost/hackman > /tmp/hackman_dump_<date>.tar
  3. transfer tar ball to new card
  4. prepare database and user:
    • sudo -u postgres psql
    • create database hackman;
    • create user hackman with encrypted password ``hackman``
    • grant all privileges on database hackman to hackman;
  5. load tar ball to postgresql pg_restore -v -d postgresql://hackman:hackman@localhost/hackman /tmp/hackman_dump_<date>.tar
  6. copy ~/.ssh/authorized_keys
  7. edit SMTP credentials sudo EDITOR=vim systemctl edit hackman
    [Service]
    Environment="EMAIL_HOST=<value>"
    Environment="EMAIL_PORT=<value>"
    Environment="EMAIL_HOST_USER=<value>"
    Environment="EMAIL_HOST_PASSWORD=<value>"
    Environment="DEFAULT_FROM_EMAIL=<value>"
    

About


Languages

Language:Python 88.7%Language:Jinja 9.0%Language:CSS 1.3%Language:JavaScript 0.7%Language:Nix 0.3%Language:Procfile 0.1%