Skip to content

Latest commit

 

History

History
187 lines (157 loc) · 7.02 KB

File metadata and controls

187 lines (157 loc) · 7.02 KB

Iron Plaid Timeclock - Manual Installation

The scripted install is recommended, but on the chance you need to perform some of the install manually, the following are effectively the steps involved and are in fact what are accomplished via the script.


Hardware | Operating System | Display | Node.js | Database | App Installation | Autostart


Hardware

Operating System

The app has been tested on Raspbian Stretch version 4.14. Use either image "with desktop".

  1. Initial startup - follow prompts
    1. update country, language, and timezone
    2. set up a password (take note of this password)
    3. join wifi
    4. (Optional) Install updates when prompted
  2. restart

Display

Auto-hide the taskbar (reference)

This is necessary for the timeclock app to be able to use the full screen. This currently has to be done manually.

  1. Right-click on the taskbar and select "Panel Settings"
  2. Click on the "Advanced" tab
  3. Check "Minimize panel when not in use"
  4. Set "Size when minimized" to 0

Rotate the LCD

This is only necessary if the case mounts with the microUSB ports on top.

printf "\nlcd_rotate=2" | sudo tee -a /boot/config.txt

Update permissions to allow LCD brightness adjustment

sudo chmod o+w /sys/class/backlight/rpi_backlight/brightness

Hide the mouse cursor & disable screen sleep

A cursor looks out of place on a touchscreen, but you might want to wait to do this until you're done with the rest of the setup.

sudo sed -i 's/#xserver-command=X/xserver-command=X -core -nocursor -s 0 -dpms/g' /etc/lightdm/lightdm.conf

Node.js

As the runtime engine for the app, Node.js needs to be installed.

sudo apt-get update
curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -
sudo apt-get install -y nodejs

Confirm node and npm are working by checking their versions

node -v
npm -v

Database

The app uses MySQL for the database, so we need to install MySQL, create the database user and tables, and manually add at least one mentor team member to allow administration.

Install MySQL

sudo apt-get install -y mysql-server

Case Insensitivity

To make your life a little easier, recommend you configure case insensitivity.

printf "[mysqld]\nlower_case_table_names=1" | sudo tee -a /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart

Create Database User and Tables

Below is practically a script, but you'll need to replace <user> and <password> with those you choose to use, so don't just copy/paste.

sudo mysql -p -u root
CREATE USER '<user>'@'localhost' IDENTIFIED BY '<password>';
CREATE DATABASE timeclock;
GRANT ALL PRIVILEGES ON timeclock.* TO '<user>'@'localhost' IDENTIFIED BY '<password>';
FLUSH PRIVILEGES;

USE timeclock;

CREATE TABLE teammembers (
    id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
    lastname VARCHAR(25) NOT NULL,
    firstname VARCHAR(25) NOT NULL,
    email VARCHAR(255) DEFAULT '',
    role VARCHAR(10) DEFAULT 'Student',
    passcode VARCHAR(256) DEFAULT '',
    active BOOLEAN DEFAULT TRUE,
    deleted BOOLEAN DEFAULT FALSE,
    created DATETIME DEFAULT CURRENT_TIMESTAMP,
    updated DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (id)
);

create table punches (
    id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
    memberid SMALLINT UNSIGNED NOT NULL,
    punchtype TINYINT(1) NOT NULL,
    created DATETIME DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id)
);

Create Default Mentor

INSERT INTO teammembers (firstname, lastname, role, passcode)
VALUES ('Default', 'Mentor', 'Mentor', SHA2('15555','256'));

Once additional mentors have been added, deactivate the default mentor entry.

Secure MySQL

Initially, the MySQL installation is somewhat unsecure. Take the following steps to secure the installation.

sudo mysql_secure_installation

Answer 'y' to all prompts:

  1. Set root password to something of your choosing
  2. Remove anonymous users
  3. Disable root login remotely
  4. Remove test database and access to it
  5. Reload privilege tables

App Installation

The following instructions walk you through installation using the latest release from the repo. Alternatively, you can build the app on the RPi - see Build and Deployment Workflow.

Application executable

  1. Download the latest .AppImage file from releases
  2. Copy the .AppImage file to the pi user's root folder (~/)
  3. Rename the .AppImage file to "iptimeclock"
  4. Make the "iptimeclock" file executable:
    chmod +x ~/iptimeclock

Application configuration

  1. Download all files from the 'config' folder in the repo

  2. Make a new directory in the pi user's .config folder:

    mkdir ~/.config/iptimeclock
  3. Copy all config files to ~/.config/iptimeclock

  4. Create a file named 'key.txt' in this directory containing your decryption key (see below)

    config.json

    Database credentials, email server details, and scheduled task details are stored in this file. Most values are encrypted (see below).

    encrypt.js

    This script helps encrypt values that will be placed in config.json. Read comments in the script file for usage instructions.

    key.txt

    The file key.txt contains the private key needed to decrypt config.json entries. In order to maintain security of the information mentioned above, this file is purposefully not included in the repo. You'll need to get this key through some other means (talk to your mentors). If you fork and modify this project DO NOT STORE KEY.TXT IN YOUR REPO.

First-time startup

Start the app by opening a terminal window and typing:

./iptimeclock

The first time you start the app, the Raspberry Pi will display a prompt, the buttons for which will not likely be visible - just hit Enter.

Autostart

We want the timeclock to start up at boot time.

mkdir ~/.config/autostart
printf "[Desktop Entry]\nType=Application\nName=iptimeclock autostart\nComment=Iron Plaid Timeclock\nNoDisplay=false\nExec=/home/pi/iptimeclock" > ~/.config/autostart/iptimeclock.desktop

Additional OS configuration

printf "sudo chmod o+w /sys/class/backlight/rpi_backlight/brightness" >> ~/.bashrc
printf "alias dir='ls -alF'" >> .bash_aliases
sudo raspi-config nonint do_ssh 0
sudo raspi-config nonint do_vnc 0
sudo raspi-config nonint do_hostname iptimeclock