Coder Social home page Coder Social logo

schlomo / chromebooks-in-deutschland Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 2.0 2.26 MB

Chromebooks in Deutschland Website

Home Page: https://chromebooks-in-deutschland.de/

License: Apache License 2.0

HTML 15.19% JavaScript 67.65% CSS 4.12% Shell 6.13% Dockerfile 0.45% HCL 5.69% Makefile 0.78%
chromebooks

chromebooks-in-deutschland's Introduction

Chromebooks in Deutschland

Sources for the website https://chromebooks-in-deutschland.de/

Please freel free to submit pull requests for features and bugfixes, they will be greatly appreciated.

Development

  • For Owners Setup credentials to run firebase functions:shell (and remember to remove the credentials). Otherwise everything should work without credentials using the emulator.
  • Use yarn start to start local development web server for frontend development with all Firebase emulators active. Can load full database dump from backup.json (create by downloading /api/data from production), will generate random prices otherwise.
  • Device data is now static JSON, only dynamic data is in database
  • Integromat used for email notifications for Cloud Build results based on Push Subscription to web hook from cloud-build Pub/Sub topic.
  • https://iconify.design/docs/icon-bundles/ explains about local icon bundles
  • Lambda function can be tested locally via SAM, pip install aws-sam-cli in a venv
  • Lambda deployment is via terragrunt and needs terraform and [sops](https://github.com/mozilla/sops

Running the Agent

  • Agents need keys in the database under /keys, emulator uses dummy key for local testing
  • Optimum agent run interval seems to be 7 minutes

Cronjob

Agent (download pecompiled binary from Releases) can be run with a script like this from a CRON job:

#!/bin/bash
cd "$(dirname "$(readlink -f "$0")")"

export CID_API_KEY=THE_SECRET_KEY
export CID_API_URL=https://DOMAIN_NAME/api

bins=( updateprice*linux* )
bin=${bins[-1]}

result="$(./$bin)"
if ! grep -q "OK: 1" <<<"$result" ; then
    echo "$result"
    exit 1
fi

(Make sure that the pattern matches the binaries that you use!)

Agent (from a source checkout checkout out to ./chromebooks-in-deutschland) can be run with a script like this:

#!/bin/bash
cd "$(dirname "$(readlink -f "$0")")"

export CID_API_KEY=THE_SECRET_KEY
export CID_API_URL=https://DOMAIN_NAME/api

cd chromebooks-in-deutschland/functions

result="$(node updateprice.js)"
if ! grep -q "OK: 1" <<<"$result" ; then
    echo "$result"
    exit 1
fi

Systemd Unit and Docker

The agent can be also run as a Docker container. On Debian/Ubuntu simply install the chromebooks-in-deutschland-service Debian package from the Releases. Make sure to create the configuration file /etc/chromebooks-in-deutschland.env. It has to set the API key like this:

CID_API_KEY=some-api-key-uuid

This works on ARM (32/64bit) and X86_64. If you have curl and jq installed then you can get the URL for the latest DEB package like this:

curl -s https://api.github.com/repos/schlomo/chromebooks-in-deutschland/releases | jq -r '.[0].assets | .[] | select(.content_type == "application/x-debian-package").browser_download_url'

Special Use Cases

  • On Raspberry Pi 1 consider modifying the unit to have a longer timeout, e.g. 600 seconds, to accomodate longer startup and image pull times.
  • On ODROID C1+ I had to use host networking to get Docker to work on the old 3.10 kernel.
  • If running on SD cards and having enough RAM, consider mounting /var/lib/docker on tmpfs to reduce the load on the SD card.

Adding Chromebooks

Chromebooks are described in YAML files under chromebooks. We use one file per Chromebook model (to easily remove old data). The files must be sorted alphabetically (use a YAML sort tool for that). The filename reflects the Chromebook model name without the vendor as defined by the expiration data.

For datasheet we try to link to the vendors original documentation. Sources for that are:

  • https://psref.lenovo.com/ - put the full variant code (including GE at the end) into the search box
  • https://pcb.inc.hp.com/webapp/ - select the Germany catalog and search for the variant, sometimes the devices are listed only under their HP model code which must be "guessed" from other sources.
  • A web search for "data sheet VARIANT pdf" or "tech spec VARIANT pdf" can also lead to useful spec sheets

Pull requests with more devices are most welcome!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.