#!/bin/bash # # Open Rowing Monitor, https://github.com/laberning/openrowingmonitor # # Installation script for Open Rowing Monitor, use at your own risk! # # treat unset variables as an error when substituting set -u # exit when a command fails set -e print() { echo "$@" } cancel() { print "$@" exit 1 } ask() { local prompt default reply if [[ ${2:-} = 'Y' ]]; then prompt='Y/n' default='Y' elif [[ ${2:-} = 'N' ]]; then prompt='y/N' default='N' else prompt='y/n' default='' fi while true; do echo -n "$1 [$prompt] " read -r reply > ~/.bashrc # otherwise node-gyp would fail while building the system dependencies sudo npm config set user 0 print print "Downloading and compiling Runtime dependencies..." sudo npm ci sudo npm run build if ! [[ -f "config/config.js" ]]; then sudo cp install/config.js config/ fi print print "Setting up Open Rowing Monitor as autostarting system service..." sudo cp install/openrowingmonitor.service /lib/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable openrowingmonitor sudo systemctl restart openrowingmonitor if $INIT_GUI; then print print "Installing Graphical User Interface" sudo apt-get -y install --no-install-recommends xserver-xorg xserver-xorg-legacy x11-xserver-utils xinit openbox chromium-browser sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config sudo cp install/webbrowserkiosk.service /lib/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable webbrowserkiosk sudo systemctl restart webbrowserkiosk print "sudo systemctl status webbrowserkiosk" sudo systemctl status webbrowserkiosk print print "Installation of Graphical User Interface finished." print "If the screen resolution or the screen borders are not correct, run 'sudo raspi-config' and modify the display options." fi cd $CURRENT_DIR print print "sudo systemctl status openrowingmonitor" sudo systemctl status openrowingmonitor print print "Installation of Open Rowing Monitor finished." print "Open Rowing Monitor should now be up and running." print print "You should now adjust the configuration in $INSTALL_DIR/config/config.js"