Allow uploads to shareport sites

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-10-04 16:09:21 +02:00
parent cc700f6cdb
commit 2026baaff2
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5

View file

@ -1,18 +1,18 @@
function gen_prefix() { function gen_prefix() {
tr -dc 'a-z0-9' </dev/urandom | head -c 8 || true tr -dc 'a-z0-9' </dev/urandom | head -c 8 || true
} }
# Generate an unique ID and set config path for it # Generate an unique ID and set config path for it
share_id=${FQDN_PREFIX:-} share_id=${FQDN_PREFIX:-}
while :; do while :; do
config_file="/home/shareport/nginx/shareport_${share_id}.conf" config_file="/home/shareport/nginx/shareport_${share_id}.conf"
if [[ -z $share_id ]] || [[ -e $config_file ]]; then if [[ -z $share_id ]] || [[ -e $config_file ]]; then
share_id=$(gen_prefix) share_id=$(gen_prefix)
continue continue
fi fi
break break
done done
# Ensure configuration directory is there # Ensure configuration directory is there
@ -24,6 +24,8 @@ server {
listen 443 ssl http2; listen 443 ssl http2;
server_name ${share_id}.knut.dev; server_name ${share_id}.knut.dev;
client_max_body_size 1024m;
ssl_certificate /data/ssl/nginxle/knut.dev.pem; ssl_certificate /data/ssl/nginxle/knut.dev.pem;
ssl_certificate_key /data/ssl/nginxle/knut.dev.key; ssl_certificate_key /data/ssl/nginxle/knut.dev.key;
@ -41,9 +43,9 @@ EOF
# Register cleanup for script exit # Register cleanup for script exit
function cleanup() { function cleanup() {
rm -f \ rm -f \
${config_file} ${config_file}
sudo /bin/systemctl reload nginx.service sudo /bin/systemctl reload nginx.service
} }
trap cleanup EXIT trap cleanup EXIT