diff --git a/app/client/index.html b/app/client/index.html index 8e5cdf7..ffe6810 100644 --- a/app/client/index.html +++ b/app/client/index.html @@ -47,7 +47,8 @@
diff --git a/install/install.sh b/install/install.sh new file mode 100755 index 0000000..8914d05 --- /dev/null +++ b/install/install.sh @@ -0,0 +1,81 @@ +#!/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() { + printf "%s\n" "$@" +} + +cancel() { + print "$@" + exit 1 +} + +print "Installation script for Open Rowing Monitor" + +if [[ "$(uname -n)" != "raspberrypi" ]]; then + cancel "This script currently only works on Raspberry Pi OS, you will have to do a manual installation." +fi + +print "This script will set up Open Rowing Monitor on a Raspberry Pi 3 / 4 with Raspberry Pi OS (lite)." +print "You should only run this script on a SD Card that does not contain any important other data." + +VERSION=$(grep -oP '(?<=^VERSION=).+' /etc/os-release | tr -d '"') +if [[ $VERSION != "10 (buster)" ]]; then + 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?" +fi + +read -p "Press RETURN to continue or CTRL + C to abort" + +print "installing dependencies..." +sudo apt-get -y update +sudo apt-get -y dist-upgrade +sudo systemctl disable bluetooth +sudo apt-get -y install bluetooth bluez libbluetooth-dev libudev-dev git + +curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - +sudo apt-get install -y nodejs + +print "installing openrowingmonitor..." +INSTALL_DIR="/opt/openrowingmonitor" +GIT_REMOTE="https://github.com/laberning/openrowingmonitor.git" + +if ! [[ -d "${INSTALL_DIR}" ]]; then + sudo mkdir -p $INSTALL_DIR +fi + +cd $INSTALL_DIR + +# get project code from repository +sudo git init -q +sudo git config remote.origin.url $GIT_REMOTE +sudo git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/* +# prevent altering line endings +sudo git config core.autocrlf false +sudo git fetch --force origin +sudo git fetch --force --tags origin +sudo git reset --hard origin/main + +# otherwise node-gyp would fail while building the system dependencies +sudo npm config set user 0 + +print "downloading and compiling dependencies..." +sudo npm install +sudo npm run build + +sudo cp install/openrowingmonitor.service /lib/systemd/system/ +sudo systemctl daemon-reload +sudo systemctl enable openrowingmonitor +sudo systemctl restart openrowingmonitor + +print "installation finished" +print "Open Rowing Monitor should now be up and running... (open http:// to verify)" diff --git a/install/openrowingmonitor.service b/install/openrowingmonitor.service new file mode 100644 index 0000000..c64b7f3 --- /dev/null +++ b/install/openrowingmonitor.service @@ -0,0 +1,13 @@ +[Unit] +Description=Open Rowing Monitor +After=multi-user.target + +[Service] +Type=simple +User=root +Restart=on-failure +WorkingDirectory=/opt/openrowingmonitor +ExecStart=npm start + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 61e5df4..69ca553 100644 --- a/package-lock.json +++ b/package-lock.json @@ -726,9 +726,9 @@ } }, "esbuild": { - "version": "0.9.6", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.9.6.tgz", - "integrity": "sha512-F6vASxU0wT/Davt9aj2qtDwDNSkQxh9VbyO56M7PDWD+D/Vgq/rmUDGDQo7te76W5auauVojjnQr/wTu3vpaUA==", + "version": "0.9.7", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.9.7.tgz", + "integrity": "sha512-VtUf6aQ89VTmMLKrWHYG50uByMF4JQlVysb8dmg6cOgW8JnFCipmz7p+HNBl+RR3LLCuBxFGVauAe2wfnF9bLg==", "dev": true }, "escape-html": { @@ -743,9 +743,9 @@ "dev": true }, "eslint": { - "version": "7.22.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.22.0.tgz", - "integrity": "sha512-3VawOtjSJUQiiqac8MQc+w457iGLfuNGLFn8JmF051tTKbh5/x/0vlcEj8OgDCaw7Ysa2Jn8paGshV7x2abKXg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.23.0.tgz", + "integrity": "sha512-kqvNVbdkjzpFy0XOszNwjkKzZ+6TcwCQ/h+ozlcIWwaimBBuhlQ4nN6kbiM2L+OjDcznkTJxzYfRFH92sx4a0Q==", "dev": true, "requires": { "@babel/code-frame": "7.12.11", @@ -1454,9 +1454,9 @@ } }, "husky": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/husky/-/husky-5.2.0.tgz", - "integrity": "sha512-AM8T/auHXRBxlrfPVLKP6jt49GCM2Zz47m8G3FOMsLmTv8Dj/fKVWE0Rh2d4Qrvmy131xEsdQnb3OXRib67PGg==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/husky/-/husky-6.0.0.tgz", + "integrity": "sha512-SQS2gDTB7tBN486QSoKPKQItZw97BMOd+Kdb6ghfpBc0yXyzrddI0oDV5MkDAbuB4X2mO3/nj60TRMcYxwzZeQ==", "dev": true }, "iconv-lite": { @@ -1795,6 +1795,12 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "dev": true + }, "lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", @@ -1812,6 +1818,12 @@ "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=", "dev": true }, + "lodash.truncate": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", + "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", + "dev": true + }, "loglevel": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.7.1.tgz", @@ -2770,9 +2782,9 @@ } }, "rollup": { - "version": "2.42.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.42.3.tgz", - "integrity": "sha512-JjaT9WaUS5vmjy6xUrnPOskjkQg2cN4WSACNCwbOvBz8VDmbiKVdmTFUoMPRqTud0tsex8Xy9/boLbDW9HKD1w==", + "version": "2.44.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.44.0.tgz", + "integrity": "sha512-rGSF4pLwvuaH/x4nAS+zP6UNn5YUDWf/TeEU5IoXSZKBbKRNTCI3qMnYXKZgrC0D2KzS2baiOZt1OlqhMu5rnQ==", "dev": true, "requires": { "fsevents": "~2.3.1" @@ -3119,21 +3131,26 @@ } }, "table": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/table/-/table-6.0.7.tgz", - "integrity": "sha512-rxZevLGTUzWna/qBLObOe16kB2RTnnbhciwgPbMMlazz1yZGVEgnZK762xyVdVznhqxrfCeBMmMkgOOaPwjH7g==", + "version": "6.0.9", + "resolved": "https://registry.npmjs.org/table/-/table-6.0.9.tgz", + "integrity": "sha512-F3cLs9a3hL1Z7N4+EkSscsel3z55XT950AvB05bwayrNg5T1/gykXtigioTAjbltvbMSJvvhFCbnf6mX+ntnJQ==", "dev": true, "requires": { - "ajv": "^7.0.2", - "lodash": "^4.17.20", + "ajv": "^8.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "lodash.clonedeep": "^4.5.0", + "lodash.flatten": "^4.4.0", + "lodash.truncate": "^4.4.2", "slice-ansi": "^4.0.0", "string-width": "^4.2.0" }, "dependencies": { "ajv": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.2.3.tgz", - "integrity": "sha512-idv5WZvKVXDqKralOImQgPM9v6WOdLNa0IY3B3doOjw/YxRGT8I+allIJ6kd7Uaj+SF1xZUSU+nPM5aDNBVtnw==", + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.0.2.tgz", + "integrity": "sha512-V0HGxJd0PiDF0ecHYIesTOqfd1gJguwQUOYfMfAWnRsWQEXfc5ifbUFhD3Wjc+O+y7VAqL+g07prq9gHQ/JOZQ==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -3317,15 +3334,15 @@ "dev": true }, "unbox-primitive": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.0.tgz", - "integrity": "sha512-P/51NX+JXyxK/aigg1/ZgyccdAxm5K1+n8+tvqSntjOivPt19gvm1VC49RWYetsiub8WViUchdxl/KWHHB0kzA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", + "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", "dev": true, "requires": { "function-bind": "^1.1.1", - "has-bigints": "^1.0.0", - "has-symbols": "^1.0.0", - "which-boxed-primitive": "^1.0.1" + "has-bigints": "^1.0.1", + "has-symbols": "^1.0.2", + "which-boxed-primitive": "^1.0.2" } }, "unpipe": { diff --git a/package.json b/package.json index db6aacd..2f9e9f5 100644 --- a/package.json +++ b/package.json @@ -34,12 +34,12 @@ "ws": "^7.4.4" }, "devDependencies": { - "eslint": "^7.22.0", + "eslint": "^7.23.0", "eslint-config-standard": "^16.0.2", "eslint-plugin-import": "^2.22.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.3.1", - "husky": "^5.1.3", + "husky": "^6.0.0", "markdownlint-cli": "^0.27.1", "npm-run-all": "^4.1.5", "snowpack": "^3.1.2",