printscan-server/setup.sh

33 lines
982 B
Bash
Raw Permalink Normal View History

2022-03-13 13:04:12 +01:00
#!/usr/bin/env bash
2021-10-22 16:04:48 +02:00
run_directory=$(dirname $(readlink -f "$0"))
2024-08-12 20:59:49 +02:00
user=$(whoami)
2021-10-22 16:04:48 +02:00
if [[ $user != 'root' ]]; then
sudo="sudo"
else
sudo=""
fi
2021-10-22 16:04:48 +02:00
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
echo "Installing scanservjs directly from GitHub..."
2023-11-12 13:43:30 +01:00
curl -s https://raw.githubusercontent.com/sbs20/scanservjs/master/bootstrap.sh | sudo bash -s -- -v latest
2022-03-11 20:07:05 +01:00
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 \
-subj "/C=/ST=/L=/O=/OU=/CN="
$sudo chmod o+r /etc/ssl/cert.key
2022-03-11 20:07:05 +01:00
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
2022-03-11 20:07:05 +01:00
# TODO add a firewall rule to prevent access to http:8080 from other than local
2021-10-22 16:04:48 +02:00
exit 0