#!/usr/bin/env bash
run_directory=$(dirname $(readlink -f "$0"))
# WARNING Unlike our usual install scripts, this one should NEVER be run unattended;
# Make sure to create .disabled file.
if [ -f $run_directory/.disabled ]; then
echo "Installation is disabled. Exiting..."
exit 0
fi
if [[ $user != 'root' ]]; then
sudo="sudo"
else
sudo=""
echo "Copying Systemd units and drop-ins to system directory..."
$sudo cp $run_directory/etc-letsencrypt.mount /etc/systemd/system/
if [ ! -d /etc/systemd/system/systemd-cryptsetup@lecrypt.service.d ]; then
$sudo mkdir /etc/systemd/system/systemd-cryptsetup@lecrypt.service.d
$sudo cp $run_directory/timeout.conf /etc/systemd/system/systemd-cryptsetup@lecrypt.service.d/
if [ ! -d /etc/systemd/system/nginx.service.d ]; then
$sudo mkdir /etc/systemd/system/nginx.service.d
$sudo cp $run_directory/wait-for-dns.conf /etc/systemd/system/nginx.service.d/
echo "Reloading Systemd..."
$sudo systemctl daemon-reload
echo "Enabling etc-letsencrypt.mount..."
$sudo systemctl enable etc-letsencrypt.mount
# WARNING you should enable this mount (and keep nginx.service disabled) if your volume does not unlock automatically
echo "Finished install. Exiting..."