From ab0082dfcc26e56c4dfcea209f96f8152cc876da Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Thu, 13 May 2021 12:16:55 -0500 Subject: [PATCH 1/6] Dont stop output when showing status --- easyinstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easyinstall.sh b/easyinstall.sh index 66728bdc..e5ee7499 100755 --- a/easyinstall.sh +++ b/easyinstall.sh @@ -134,7 +134,7 @@ function updateRaScsiWebInterface() { } function showRaScsiStatus() { - sudo systemctl status rascsi + sudo systemctl status rascsi | tee } function createDrive600MB() { From a2a323cdb84ad3e6f7090f75c607c39daf8bf528 Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Thu, 13 May 2021 12:17:15 -0500 Subject: [PATCH 2/6] Update to flask 2.0 --- src/web/requirements.txt | 10 +++++----- src/web/web.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/web/requirements.txt b/src/web/requirements.txt index 64d25bb4..ab184b10 100644 --- a/src/web/requirements.txt +++ b/src/web/requirements.txt @@ -1,12 +1,12 @@ click==7.1.2 -Flask==1.1.2 -itsdangerous==1.1.0 -Jinja2==2.11.2 +Flask==2.0.0 +itsdangerous==2.0.0 +Jinja2==3.0.0 machfs==1.2.4 macresources==1.2 -MarkupSafe==1.1.1 +MarkupSafe==2.0.0 rsrcfork==1.8.0 waitress==1.4.4 -Werkzeug==1.0.1 +Werkzeug==2.0.0 zope.event==4.5.0 zope.interface==5.1.2 diff --git a/src/web/web.py b/src/web/web.py index 2268d43d..0699443c 100644 --- a/src/web/web.py +++ b/src/web/web.py @@ -55,7 +55,7 @@ def config_save(): with open(file_name, "w") as csv_file: writer = csv.writer(csv_file) for device in list_devices(): - if device["type"] is not "-": + if device["type"] != "-": writer.writerow(device.values()) flash(f"Saved config to {file_name}!") return redirect(url_for("index")) From c2c0d5cbf7b8c8d74c7b78e0bb20ebcc0603ea91 Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Thu, 13 May 2021 12:20:36 -0500 Subject: [PATCH 3/6] Use truncate instead of dd --- easyinstall.sh | 2 +- src/web/file_cmds.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/easyinstall.sh b/easyinstall.sh index e5ee7499..d2688e23 100755 --- a/easyinstall.sh +++ b/easyinstall.sh @@ -221,7 +221,7 @@ function createDrive() { if [ ! -f $drivePath ]; then echo "Creating a ${driveSize}MB Drive" - dd if=/dev/zero of=$drivePath bs=1M count=$driveSize + truncate --size ${driveSize}m $drivePath echo "Formatting drive with HFS" formatDrive "$drivePath" "$driveName" diff --git a/src/web/file_cmds.py b/src/web/file_cmds.py index c424f82f..7ca5d19e 100644 --- a/src/web/file_cmds.py +++ b/src/web/file_cmds.py @@ -17,7 +17,7 @@ def create_new_image(file_name, type, size): file_name = file_name + "." + type return subprocess.run( - ["dd", "if=/dev/zero", "of=" + base_dir + file_name, "bs=1M", "count=" + size], + ["truncate", "--size", f"{size}m", f"{base_dir}{file_name}"], capture_output=True, ) From ffc9c36456339fd5744072effc51ff874d0a6dde Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Thu, 13 May 2021 12:41:30 -0500 Subject: [PATCH 4/6] unlimited upload in nginx --- src/web/service-infra/nginx-default.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/web/service-infra/nginx-default.conf b/src/web/service-infra/nginx-default.conf index bffa96cc..bfd286da 100644 --- a/src/web/service-infra/nginx-default.conf +++ b/src/web/service-infra/nginx-default.conf @@ -5,6 +5,8 @@ server { proxy_pass http://localhost:8080; } + client_max_body_size 0; + error_page 502 /502.html; location = /502.html { root /var/www/html/; From 968d34bb1415965ce3148d022b22f9d85be7175f Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Thu, 13 May 2021 12:48:11 -0500 Subject: [PATCH 5/6] Increase nginx timeouts --- src/web/service-infra/nginx-default.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/web/service-infra/nginx-default.conf b/src/web/service-infra/nginx-default.conf index bfd286da..fc73e44e 100644 --- a/src/web/service-infra/nginx-default.conf +++ b/src/web/service-infra/nginx-default.conf @@ -5,7 +5,11 @@ server { proxy_pass http://localhost:8080; } + # Large files client_max_body_size 0; + proxy_read_timeout 1000; + proxy_connect_timeout 1000; + proxy_send_timeout 1000; error_page 502 /502.html; location = /502.html { From b5d82c103752d544721988182a51e4535bac616a Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Sun, 23 May 2021 10:55:24 -0500 Subject: [PATCH 6/6] Update readme for dev setup of web --- src/web/README.md | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/web/README.md b/src/web/README.md index 82088ba2..352e5ce3 100644 --- a/src/web/README.md +++ b/src/web/README.md @@ -1,12 +1,35 @@ # RaSCSI Web -## Mocking for local development +## Setup local dev env -Set a few env vars to point to the mock scripts and base dir - -``` -BASE_DIR=/tmp/images/ -PATH=$PATH:`pwd`/mock/bin/ +```bash +# Make a virtual env named venv +$ python3 -m venv venv +# Use that virtual env in this shell +$ source venv/bin/activate +# Install requirements +$ pip install -r requirements.txt +# Use mocks and a temp dir - start the web server +$ BASE_DIR=/tmp/images/ PATH=$PATH:`pwd`/mock/bin/ python3 web.py ``` -Edit response to commands in `mock/bin/*` +### Mocks for local development + +You may edit the files under `mock/bin` to simulate rascsi command responses. + +## Pushing to the Pi via git + +Setup a bare repo on the rascsi +``` +$ ssh pi@rascsi +$ mkdir /home/pi/dev.git && cd /home/pi/dev.git +$ git --bare init +Initialized empty Git repository in /home/pi/dev.git +``` + +Locally +``` +$ cd ~/source/RASCSI +$ git remote add pi ssh://pi@rascsi/home/pi/dev.git +$ git push pi master +```