enables installer to also set up a browser in kiosk mode
This commit is contained in:
parent
a618419702
commit
e903037d68
|
|
@ -12,7 +12,7 @@ I suspect it works well with DIY rowing machines like the [Openergo](https://ope
|
|||
|
||||
## Features
|
||||
|
||||
Currently the feature set is pretty basic, I'll add more features in the future, check the [Development Roadmap](docs/backlog.md) if you are curious.
|
||||
The following items describe most of the current features, more functionality will be added in the future, check the [Development Roadmap](docs/backlog.md) if you are curious.
|
||||
|
||||
### Rowing Metrics
|
||||
|
||||
|
|
@ -28,7 +28,9 @@ Open Rowing Monitor implements a physics model to simulate the typical metrics o
|
|||
|
||||
### Web Interface
|
||||
|
||||
The web interface visualizes the rowing metrics on any device that can run a browser (i.e. a smartphone that you attach to your rowing machine while training). It uses web sockets to show the rowing status in Realtime. Besides that it does not do much (yet).
|
||||
The web interface visualizes the rowing metrics on any device that can run a web browser (i.e. a smartphone that you attach to your rowing machine while training). It uses web sockets to show the rowing status in realtime. It can also be used to reset the training metrics and to select the BLE Rower.
|
||||
|
||||
If you connect a screen to the Raspberry Pi, then this interface can also be directly shown on the device. The installation script can set up a web browser in kiosk mode that runs on the Raspberry Pi.
|
||||
|
||||
<!-- markdownlint-disable-next-line no-inline-html -->
|
||||
<img src="docs/img/openrowingmonitor_frontend.png" width="700"><br clear="left">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Open Rowing Monitor, https://github.com/laberning/openrowingmonitor
|
||||
#
|
||||
# Start script for Open Rowing Monitor
|
||||
#
|
||||
|
||||
# treat unset variables as an error when substituting
|
||||
set -u
|
||||
# exit when a command fails
|
||||
set -e
|
||||
|
||||
print() {
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
CURRENT_DIR=$(pwd)
|
||||
SCRIPT_DIR="$( cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd )"
|
||||
INSTALL_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
cd $INSTALL_DIR
|
||||
npm start
|
||||
cd $CURRENT_DIR
|
||||
|
|
@ -11,7 +11,7 @@ set -u
|
|||
set -e
|
||||
|
||||
print() {
|
||||
printf "%s\n" "$@"
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
cancel() {
|
||||
|
|
@ -19,8 +19,38 @@ cancel() {
|
|||
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 </dev/tty
|
||||
|
||||
if [[ -z $reply ]]; then
|
||||
reply=$default
|
||||
fi
|
||||
|
||||
case "$reply" in
|
||||
Y*|y*) return 0 ;;
|
||||
N*|n*) return 1 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
CURRENT_DIR=$(pwd)
|
||||
INSTALL_DIR="/opt/openrowingmonitor"
|
||||
SCRIPT_DIR="$( cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd )"
|
||||
INSTALL_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
GIT_REMOTE="https://github.com/laberning/openrowingmonitor.git"
|
||||
|
||||
print "Update script for Open Rowing Monitor"
|
||||
|
|
@ -35,9 +65,7 @@ REMOTE_VERSION=$(git ls-remote $GIT_REMOTE HEAD | awk '{print $1;}')
|
|||
if [ "$LOCAL_VERSION" = "$REMOTE_VERSION" ]; then
|
||||
print "You are using the latest version of Open Rowing Monitor."
|
||||
else
|
||||
print "A new version of Open Rowing Monitor is available. Do you want to update?"
|
||||
print
|
||||
read -p "Press RETURN to continue or CTRL + C to abort"
|
||||
if ask "A new version of Open Rowing Monitor is available. Do you want to update?" Y; then
|
||||
print "Stopping Open Rowing Monitor..."
|
||||
sudo systemctl stop openrowingmonitor
|
||||
|
||||
|
|
@ -56,6 +84,7 @@ else
|
|||
print
|
||||
print "Update complete, Open Rowing Monitor now has the following exciting new features:"
|
||||
git log --reverse --pretty=format:"- %s" $LOCAL_VERSION..HEAD
|
||||
fi
|
||||
fi
|
||||
|
||||
cd $CURRENT_DIR
|
||||
|
|
@ -36,12 +36,12 @@ Connect to the device with SSH and initiate the following command to set up all
|
|||
Open Rowing Monitor does not provide proper releases (yet), but you can update to the latest development version with this command:
|
||||
|
||||
```zsh
|
||||
sudo /opt/openrowingmonitor/install/update.sh
|
||||
updateopenrowingmonitor.sh
|
||||
```
|
||||
|
||||
### Running Open Rowing Monitor without root permissions
|
||||
|
||||
The default installation will run Open Rowing Monitor with root permissions. If you want you can also run it as user by modifying the following system services:
|
||||
The default installation will run Open Rowing Monitor with root permissions. You can also run it as normal user by modifying the following system services:
|
||||
|
||||
#### To use BLE and open the Web-Server on port 80
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ set -u
|
|||
set -e
|
||||
|
||||
print() {
|
||||
printf "%s\n" "$@"
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
cancel() {
|
||||
|
|
@ -19,6 +19,39 @@ cancel() {
|
|||
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 </dev/tty
|
||||
|
||||
if [[ -z $reply ]]; then
|
||||
reply=$default
|
||||
fi
|
||||
|
||||
case "$reply" in
|
||||
Y*|y*) return 0 ;;
|
||||
N*|n*) return 1 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
CURRENT_DIR=$(pwd)
|
||||
INSTALL_DIR="/opt/openrowingmonitor"
|
||||
GIT_REMOTE="https://github.com/laberning/openrowingmonitor.git"
|
||||
|
||||
print "This script will set up Open Rowing Monitor on one of the following devices"
|
||||
print " Raspberry Pi Zero W or WH"
|
||||
print " Raspberry Pi 3 Model A+, B or B+"
|
||||
|
|
@ -27,7 +60,12 @@ print
|
|||
print "You should only run this script on a SD Card that contains Raspberry Pi OS 10 (Lite)"
|
||||
print "and does not contain any important data."
|
||||
|
||||
OSID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
|
||||
if [[ -f "/etc/os-release" ]]; then
|
||||
OSID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
|
||||
else
|
||||
OSID="undefined"
|
||||
fi
|
||||
|
||||
if [[ $OSID != "raspbian" ]]; then
|
||||
print
|
||||
cancel "This script currently only works on Raspberry Pi OS, you will have to do a manual installation."
|
||||
|
|
@ -37,13 +75,22 @@ VERSION=$(grep -oP '(?<=^VERSION=).+' /etc/os-release | tr -d '"')
|
|||
if [[ $VERSION != "10 (buster)" ]]; then
|
||||
print
|
||||
print "Warning: So far this install script has only been tested with Raspberry Pi OS 10 (buster)."
|
||||
print "You are running Raspberry Pi OS $VERSION, are you sure that you want to continue?"
|
||||
if ! ask "You are running Raspberry Pi OS $VERSION, are you sure that you want to continue?" N; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
print
|
||||
if ! ask "Do you want to start the installation of Open Rowing Monitor?" Y; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# todo: once we know what hardware we support we can check for that via /sys/firmware/devicetree/base/model
|
||||
|
||||
print
|
||||
read -p "Press RETURN to continue or CTRL + C to abort"
|
||||
INIT_GUI=false
|
||||
if ask "Do you also want to run the Graphical User Interface on this device (requires attached screen, optional)?" N; then
|
||||
INIT_GUI=true
|
||||
fi
|
||||
|
||||
print
|
||||
print "Installing System dependencies..."
|
||||
|
|
@ -59,7 +106,7 @@ then
|
|||
print "You are running a system with ARM v6 architecture. Official support for Node.js has been discontinued"
|
||||
print "for ARM v6. Installing experimental unofficial build of Node.js..."
|
||||
|
||||
NODEJS_VERSION=v14.16.1
|
||||
NODEJS_VERSION=v14.17.0
|
||||
sudo rm -rf /opt/nodejs
|
||||
sudo mkdir -p /opt/nodejs
|
||||
sudo curl https://unofficial-builds.nodejs.org/download/release/$NODEJS_VERSION/node-$NODEJS_VERSION-linux-armv6l.tar.gz | sudo tar -xz --strip 1 -C /opt/nodejs/
|
||||
|
|
@ -80,8 +127,6 @@ fi
|
|||
|
||||
print
|
||||
print "Installing Open Rowing Monitor..."
|
||||
INSTALL_DIR="/opt/openrowingmonitor"
|
||||
GIT_REMOTE="https://github.com/laberning/openrowingmonitor.git"
|
||||
|
||||
if ! [[ -d "${INSTALL_DIR}" ]]; then
|
||||
sudo mkdir -p $INSTALL_DIR
|
||||
|
|
@ -99,6 +144,9 @@ sudo git fetch --force origin
|
|||
sudo git fetch --force --tags origin
|
||||
sudo git reset --hard origin/main
|
||||
|
||||
# add bin directory to the system path
|
||||
echo "export PATH=\"\$PATH:$INSTALL_DIR/bin\"" >> ~/.bashrc
|
||||
|
||||
# otherwise node-gyp would fail while building the system dependencies
|
||||
sudo npm config set user 0
|
||||
|
||||
|
|
@ -117,6 +165,29 @@ 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 "Installation of Open Rowing Monitor finished"
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=X11 Web Browser Kiosk
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=pi
|
||||
Restart=on-failure
|
||||
WorkingDirectory=/opt/openrowingmonitor
|
||||
ExecStart=xinit /opt/openrowingmonitor/install/webbrowserkiosk.sh -- -nocursor
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Open Rowing Monitor, https://github.com/laberning/openrowingmonitor
|
||||
#
|
||||
# Runs the Web Frontend in a chromium browser in fullscreen kiosk mode
|
||||
#
|
||||
xset s off
|
||||
xset s noblank
|
||||
xset -dpms
|
||||
openbox-session &
|
||||
|
||||
# Start Chromium in kiosk mode
|
||||
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State'
|
||||
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences
|
||||
chromium-browser --disable-infobars --kiosk --noerrdialogs --disable-session-crashed-bubble --check-for-update-interval=604800 --app="http://127.0.0.1/#:kiosk:"
|
||||
Loading…
Reference in New Issue