From 0f7077008cc3be51f80e3bd6ef92f202bb2f4afc Mon Sep 17 00:00:00 2001 From: Alexandre CATTEAU Date: Tue, 24 Sep 2024 20:24:28 +0200 Subject: [PATCH] Update due to change to Arch --- README.md | 2 ++ apache-sites/scanservjs.conf | 2 +- setup.sh | 55 ++++++++++++++++++++++++++++++------ 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9723d99..64bddaf 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Version 3.1 implementation works roughly as follows * CUPS is configured to provide a remote printer to network * SANE is configured to provide local scan * [scanservjs](https://github.com/sbs20/scanservjs) runs on the SBC, providing a web interface for scan + * if you need adjustments (as in https://github.com/sbs20/scanservjs/blob/master/docs/10-configuration.md), first do: + * `sudo ln -s /usr/share/webapps/scanservjs /usr/lib/scanservjs` ### Files Files in this repository cover only the server setup. SBC setup is now handled by `armbian-setup` diff --git a/apache-sites/scanservjs.conf b/apache-sites/scanservjs.conf index 1e9e440..70834cd 100644 --- a/apache-sites/scanservjs.conf +++ b/apache-sites/scanservjs.conf @@ -1,5 +1,5 @@ - ServerName printscan.hp3.kto.black + ServerName printscan SSLEngine on SSLCertificateFile "/etc/ssl/cert.crt" diff --git a/setup.sh b/setup.sh index 23267d1..266a05c 100755 --- a/setup.sh +++ b/setup.sh @@ -9,12 +9,25 @@ else sudo="" fi -echo "Setting CUPS configuration" -$sudo mv /etc/cups/cupsd.conf /etc/cups/cupsd.conf.orig -$sudo cp $run_directory/cupsd.conf /etc/cups/cupsd.conf +distro=$(lsb_release -si) -echo "Installing scanservjs directly from GitHub..." -curl -s https://raw.githubusercontent.com/sbs20/scanservjs/master/bootstrap.sh | sudo bash -s -- -v latest +# TODO if Arch +if [[ $distro == "Debian" ]]; then + echo "Setting CUPS configuration" + $sudo mv /etc/cups/cupsd.conf /etc/cups/cupsd.conf.orig + $sudo cp $run_directory/cupsd.conf /etc/cups/cupsd.conf +else + echo "TODO: Edit cupsd.conf so as to allow remote access (see Arch wiki)." +fi + +if [[ $distro == "Debian" ]]; then + echo "Installing scanservjs directly from GitHub..." + curl -s https://raw.githubusercontent.com/sbs20/scanservjs/master/bootstrap.sh | sudo bash -s -- -v latest +fi +if [[ $distro == "Arch" ]]; then + echo "Starting and enabling scanservjs..." + $sudo systemctl enable --now scanservjs.service +fi echo "Generating TLS certificate" $sudo openssl req -newkey rsa:4096 -x509 -sha256 -days 999 -nodes -out /etc/ssl/cert.crt -keyout /etc/ssl/cert.key \ @@ -22,10 +35,34 @@ $sudo openssl req -newkey rsa:4096 -x509 -sha256 -days 999 -nodes -out /etc/ssl/ $sudo chmod o+r /etc/ssl/cert.key echo "Setting up Apache HTTP Server" -$sudo cp $run_directory/apache-sites/scanservjs.conf /etc/apache2/sites-available/ -$sudo a2dissite 000-default -$sudo a2ensite scanservjs -$sudo a2enmod ssl proxy proxy_http proxy_http2 +if [[ $distro == "Arch" ]]; then + $sudo cp $run_directory/apache-sites/scanservjs.conf /etc/apache2/sites-available/scanservjs.conf + $sudo a2dissite 000-default + $sudo a2ensite scanservjs + $sudo a2enmod ssl proxy proxy_http proxy_http2 +fi +if [[ $distro == "Arch" ]]; then + $sudo cp $run_directory/apache-sites/scanservjs.conf /etc/httpd/conf/scanservjs.conf + $sudo sed -i -e "s/#ServerName www.example.com:80/#ServerName www.example.com:80\nServerName mn2.hr.kto.black/g" \ + /etc/httpd/conf/httpd.conf + $sudo sed -i -e "s:#LoadModule ssl_module modules/mod_ssl.so:LoadModule ssl_module modules/mod_ssl.so:g" \ + /etc/httpd/conf/httpd.conf + $sudo sed -i -e "s:#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so:LoadModule socache_shmcb_module modules/mod_socache_shmcb.so:g" \ + /etc/httpd/conf/httpd.conf + $sudo sed -i -e "s/Listen 80/Listen 443/g" /etc/httpd/conf/httpd.conf + $sudo sed -i -e "s:#LoadModule proxy_module modules/mod_proxy.so:LoadModule proxy_module modules/mod_proxy.so:g" \ + /etc/httpd/conf/httpd.conf + $sudo sed -i -e "s:#LoadModule proxy_http_module modules/mod_proxy_http.so:LoadModule proxy_http_module modules/mod_proxy_http.so:g" \ + /etc/httpd/conf/httpd.conf + $sudo sed -i -e "s:#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so:LoadModule proxy_balancer_module modules/mod_proxy_balancer.so:g" \ + /etc/httpd/conf/httpd.conf + $sudo sed -i -e "s:#LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so:LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so:g" \ + /etc/httpd/conf/httpd.conf + $sudo sed -i -e "s:#LoadModule watchdog_module modules/mod_watchdog.so:LoadModule watchdog_module modules/mod_watchdog.so:g" \ + /etc/httpd/conf/httpd.conf + $sudo bash -c 'echo "Include conf/scanservjs.conf" >> /etc/httpd/conf/httpd.conf' + $sudo systemctl enable --now httpd.service +fi # TODO add a firewall rule to prevent access to http:8080 from other than local