2022-05-24 11:42:45 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-09-22 18:53:34 +02:00
|
|
|
run_directory=$(dirname $(readlink -f "$0"))
|
2022-05-24 11:42:45 +02:00
|
|
|
|
2022-08-19 20:34:00 +02:00
|
|
|
# WARNING Unlike our usual install scripts, this one should NEVER be run unattended;
|
|
|
|
# Make sure to create .disabled file.
|
2022-05-24 11:42:45 +02:00
|
|
|
if [ -f $run_directory/.disabled ]; then
|
|
|
|
echo "Installation is disabled. Exiting..."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2022-08-19 20:28:42 +02:00
|
|
|
if [[ $user != 'root' ]]; then
|
|
|
|
sudo="sudo"
|
|
|
|
else
|
|
|
|
sudo=""
|
|
|
|
fi
|
|
|
|
|
2022-05-24 11:42:45 +02:00
|
|
|
echo "Copying Systemd units and drop-ins to system directory..."
|
2022-08-19 20:28:42 +02:00
|
|
|
$sudo cp $run_directory/etc-letsencrypt.mount /etc/systemd/system/
|
2022-08-19 20:34:00 +02:00
|
|
|
if [ ! -d /etc/systemd/system/nginx.service.d ]; then
|
2022-08-19 20:28:42 +02:00
|
|
|
$sudo mkdir /etc/systemd/system/nginx.service.d
|
2022-05-24 20:34:03 +02:00
|
|
|
fi
|
2022-08-19 20:28:42 +02:00
|
|
|
$sudo cp $run_directory/start-lighttpd.conf /etc/systemd/system/nginx.service.d/
|
|
|
|
$sudo cp $run_directory/wait-for-dns.conf /etc/systemd/system/nginx.service.d/
|
2022-05-24 11:42:45 +02:00
|
|
|
|
|
|
|
echo "Setting up lighttpd..."
|
2022-08-19 20:28:42 +02:00
|
|
|
$sudo cp $run_directory/lighttpd-webssh.conf /etc/lighttpd/conf-available/99-webssh.conf
|
|
|
|
$sudo rm /etc/lighttpd/conf-enabled/*
|
|
|
|
$sudo ln -s /etc/lighttpd/conf-available/10-proxy.conf /etc/lighttpd/conf-enabled/
|
|
|
|
$sudo ln -s /etc/lighttpd/conf-available/10-ssl.conf /etc/lighttpd/conf-enabled/
|
|
|
|
$sudo ln -s /etc/lighttpd/conf-available/99-webssh.conf /etc/lighttpd/conf-enabled/
|
2022-08-19 20:34:00 +02:00
|
|
|
if [ ! -f /etc/lighttpd/server.pem ]; then
|
2022-05-24 11:42:45 +02:00
|
|
|
echo "Creating an SSL certificate for lighttpd:"
|
2022-08-19 20:28:42 +02:00
|
|
|
$sudo openssl req -newkey rsa:4096 -x509 -sha256 -days 999 -nodes -out /etc/lighttpd/server.pem -keyout \
|
2022-08-19 20:34:00 +02:00
|
|
|
/etc/lighttpd/server.pem -subj "/C=/ST=/L=/O=/OU=/CN="
|
2022-05-24 11:42:45 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Reloading Systemd..."
|
2022-08-19 20:28:42 +02:00
|
|
|
$sudo systemctl daemon-reload
|
2022-05-24 11:42:45 +02:00
|
|
|
echo "Disabling nginx and enabling lighttpd..."
|
2022-08-19 20:28:42 +02:00
|
|
|
$sudo systemctl disable nginx
|
|
|
|
$sudo systemctl enable lighttpd
|
2022-05-24 11:42:45 +02:00
|
|
|
|
|
|
|
echo "Finished install. Exiting..."
|
|
|
|
echo "NOTE: Neither nginx nor lighttpd were started/stopped."
|
|
|
|
exit 0
|