From 4fdaf3e8defd5ad521cf2c1b8548ec2755a56082 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Sat, 27 Jan 2024 23:14:13 +0100 Subject: [PATCH] Downloader: Install perl modules and set up environment Signed-off-by: Robert C. Helling --- packaging/headless/Setting-up-downloader | 13 +++++++++---- scripts/downloader.pl | 6 +++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packaging/headless/Setting-up-downloader b/packaging/headless/Setting-up-downloader index 1c2ee155e..8b76badf8 100644 --- a/packaging/headless/Setting-up-downloader +++ b/packaging/headless/Setting-up-downloader @@ -38,18 +38,23 @@ sudo ln -s /etc/apache2/mods-available/cgi* /etc/apache2/mods-enabled/ and restart apache2 -6) copy ~/src/subsurface/scripts/downloader.pl to /usr/lib/cgi-bin and run +6) Install two perl modules: + +sudo cpan CGI +sudo cpan Get:Repository + +7) copy ~/src/subsurface/scripts/downloader.pl to /usr/lib/cgi-bin and run sudo chmod a+x /usr/lib/cgi-bin/downloader.pl It should then be there when you direct your browser to subsurfacepi.local/cgi-bin/downloader.pl -7) Give the www user access to the serial interface +8) Give the www user access to the serial interface sudo adduser pi dialout and restart apache2 -8) Create a directory to store the data +9) Create a directory to store the data sudo mkdir /opt/ssrf/ sudo touch /opt/ssrf/ssrf.conf sudo chown -R www-data.www-data /opt/ssrf -9) If you want to use the pi with an iPhone where the iPhone provides the internet connectivity, follow https://gist.github.com/antronic/157e047cdefa98b3150195c2eacb56b8 +10) If you want to use the pi with an iPhone where the iPhone provides the internet connectivity, follow https://gist.github.com/antronic/157e047cdefa98b3150195c2eacb56b8 diff --git a/scripts/downloader.pl b/scripts/downloader.pl index 59b5cfd84..08306bedc 100644 --- a/scripts/downloader.pl +++ b/scripts/downloader.pl @@ -17,6 +17,10 @@ my %conf; # Use unbuffered output $| = 1; +# Setup some environemnt variables to make subsurface startup happy +$ENV{HOME} = '/tmp'; +$ENV{LOGNAME} = 'www-data'; + my $q = CGI->new; print $q->header('text/html'); @@ -114,7 +118,7 @@ print $q->end_form(); print $q->br(), $q->a({-href => $q->url() . "?action=config"}, "Configure cloud credentials"); sub load_supported_dcs { - open IN, "/home/pi/src/subsurface/build/subsurface-downloader --list-dc|"; + open IN, "$downloader --list-dc|" || die "Cannot run $downloader: $!"; while() { last if /Supported dive computers:/;