#!/bin/bash set -e NEW_KEY=$(openssl rand -base64 64 | tr -d '\r\n') KEY_LEN=${#NEW_KEY} if [ "$KEY_LEN" -ge 64 ]; then sed -i '/^Jwt__/d' /etc/classnotify/classnotify.env echo "Jwt__SigningKey=${NEW_KEY}" >> /etc/classnotify/classnotify.env echo "Jwt__Issuer=ClassNotify.Server" >> /etc/classnotify/classnotify.env echo "Jwt__Audience=ClassNotify.Clients" >> /etc/classnotify/classnotify.env echo "Jwt__LifetimeDays=14" >> /etc/classnotify/classnotify.env chmod 600 /etc/classnotify/classnotify.env chown root:root /etc/classnotify/classnotify.env echo "SUCCESS: Key generated and injected on VPS (Key length: ${KEY_LEN} characters)" else echo "ERROR: generated key length invalid: ${KEY_LEN}" >&2 exit 1 fi