Add support for providing other certificate

This commit is contained in:
Alexandre CATTEAU 2022-11-16 18:28:13 +01:00
parent d433f0d04f
commit 6b29e8ff3f
4 changed files with 21 additions and 10 deletions

View File

@ -18,8 +18,8 @@ fi
echo "Copying Systemd units to system directory..."
if [ ! -f /etc/ssl/cert.crt ]; then
$sudo openssl req -newkey rsa:4096 -x509 -sha256 -days 999 -nodes -out /etc/ssl/cert.crt -keyout /etc/ssl/cert.key \
if [ ! -f $crt_path ]; then
$sudo openssl req -newkey rsa:4096 -x509 -sha256 -days 999 -nodes -out $crt_path -keyout $key_path \
-subj "/C=/ST=/L=/O=/OU=/CN="
fi
if [ -d /etc/nginx ]; then
@ -32,7 +32,9 @@ if [ "$filebrowser" = "yes" ]; then
$sudo sed -i -e "s/PH_NAS_USER/$nas_user/g" /etc/systemd/system/filebrowser.service
$sudo sed -i -e "s:PH_NAS_DIRECTORY:$nas_location:g" /etc/systemd/system/filebrowser.service
$sudo cp $run_directory/nginx-blocks/filebrowser /etc/nginx/sites-available/filebrowser
$sudo sed -i -e "s/PH_FQDN/$(hostname)/g" /etc/nginx/sites-available/filebrowser
$sudo sed -i -e "s/PH_SRVNAME/$filebrowser_server_name/g" /etc/nginx/sites-available/filebrowser
$sudo sed -i -e "s:PH_CRT:$crt_path:g" /etc/nginx/sites-available/filebrowser
$sudo sed -i -e "s:PH_KEY:$key_path:g" /etc/nginx/sites-available/filebrowser
$sudo ln -sf ../sites-available/filebrowser /etc/nginx/sites-enabled/filebrowser
fi
@ -52,7 +54,9 @@ if [ "$dl_server" = "yes" ]; then
$sudo sed -i -e "s:PH_DIRECTORY:$run_directory:g" /etc/systemd/system/transmission-vpn.service
$sudo cp $run_directory/systemd-templates/transmission-vpn.timer /etc/systemd/system/
$sudo cp $run_directory/nginx-blocks/transmission /etc/nginx/sites-available/transmission
$sudo sed -i -e "s/PH_FQDN/$(hostname)/g" /etc/nginx/sites-available/transmission
$sudo sed -i -e "s/PH_SRVNAME/$transmission_server_name/g" /etc/nginx/sites-available/transmission
$sudo sed -i -e "s:PH_CRT:$crt_path:g" /etc/nginx/sites-available/transmission
$sudo sed -i -e "s:PH_KEY:$key_path:g" /etc/nginx/sites-available/transmission
$sudo ln -sf ../sites-available/transmission /etc/nginx/sites-enabled/transmission
fi

View File

@ -1,9 +1,9 @@
server {
listen 443 ssl;
server_name nas.PH_FQDN;
server_name PH_SRVNAME;
ssl_certificate /etc/ssl/cert.crt;
ssl_certificate_key /etc/ssl/cert.key;
ssl_certificate PH_CRT;
ssl_certificate_key PH_KEY;
location / {
proxy_pass http://127.0.0.1:8080;

View File

@ -1,9 +1,9 @@
server {
listen 443 ssl;
server_name dl.PH_FQDN;
server_name PH_SRVNAME;
ssl_certificate /etc/ssl/cert.crt;
ssl_certificate_key /etc/ssl/cert.key;
ssl_certificate PH_CRT;
ssl_certificate_key PH_KEY;
location / {
proxy_pass http://127.0.0.1:9091;

View File

@ -5,14 +5,21 @@
nas_location=""
nas_user=""
# Paths to X509 certificate and key
# If they do not exist, they will be created as a self-singed certificate
crt_path="/etc/ssl/cert.crt"
key_path="/etc/ssl/cert.key"
# Set up File Browser
filebrowser="yes"
filebrowser_server_name="files.$(hostname)"
# Set up MiniDLNA
dlna_server="yes"
# Set up Transmission and OpenVPN
dl_server="yes"
transmission_server_name="dl.$(hostname)"
real_ip="" # for VPN check
authorized_ips="" # for transmission web interface
user="" # user for transmission web interface