2022-03-13 13:04:12 +01:00
|
|
|
#!/usr/bin/env bash
|
2021-10-22 16:04:48 +02:00
|
|
|
|
2023-07-08 14:38:38 +02:00
|
|
|
run_directory=$(dirname $(readlink -f "$0"))
|
2021-10-22 16:04:48 +02:00
|
|
|
|
2023-07-08 14:38:38 +02:00
|
|
|
if [[ $user != 'root' ]]; then
|
|
|
|
sudo="sudo"
|
|
|
|
else
|
|
|
|
sudo=""
|
|
|
|
fi
|
2021-10-22 16:04:48 +02:00
|
|
|
|
2023-07-08 14:38:38 +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
|
2022-04-27 20:17:21 +02:00
|
|
|
|
2023-07-08 14:38:38 +02:00
|
|
|
echo "Installing scanservjs directly from GitHub..."
|
|
|
|
curl -s https://raw.githubusercontent.com/sbs20/scanservjs/master/packages/server/installer.sh | $sudo bash -s -- -a
|
2022-03-11 20:07:05 +01:00
|
|
|
|
2023-07-08 14:38:38 +02: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
|
|
|
|
2023-07-08 14:38:38 +02: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
|