adding entra info to installer

This commit is contained in:
nmemmert committed 2025-11-06 14:56:23 -05:00
1 parent 4b63917064
commit 5ed8131529
1 file changed
+57 -14
+57 -14
View File
@@ -8,6 +8,45 @@ set -e
echo "Starting installation of PDF Renamer Flask App..." echo "Starting installation of PDF Renamer Flask App..."
# Interactive configuration
echo ""
echo "=== PDF Renamer Configuration ==="
echo ""
# Get domain name
read -p "Enter the domain name for this installation (e.g., nextgenpdf.trbc.org): " DOMAIN_NAME
if [ -z "$DOMAIN_NAME" ]; then
echo "ERROR: Domain name is required"
exit 1
fi
# Get Microsoft Entra ID configuration
echo ""
echo "=== Microsoft Entra ID Configuration ==="
echo "If you don't have these values yet, you can get them after installation."
echo "Leave blank to configure later."
echo ""
read -p "Microsoft Entra Tenant ID (optional): " TENANT_ID
read -p "Microsoft Entra Client ID (optional): " CLIENT_ID
read -p "Microsoft Entra Client Secret (optional): " CLIENT_SECRET
# Get admin credentials
echo ""
echo "=== Admin Login Configuration ==="
read -p "Admin username (default: trbcit): " ADMIN_USER
ADMIN_USER=${ADMIN_USER:-trbcit}
read -s -p "Admin password (default: atdrmbicn): " ADMIN_PASS
echo ""
ADMIN_PASS=${ADMIN_PASS:-atdrmbicn}
echo ""
echo "Configuration complete!"
echo "Domain: $DOMAIN_NAME"
echo "Admin User: $ADMIN_USER"
echo ""
# Check if already installed # Check if already installed
if systemctl is-active --quiet pdf-renamer 2>/dev/null; then if systemctl is-active --quiet pdf-renamer 2>/dev/null; then
echo "WARNING: PDF Renamer service is already running." echo "WARNING: PDF Renamer service is already running."
@@ -91,11 +130,11 @@ User=$CURRENT_USER
WorkingDirectory=/home/$CURRENT_USER/pdf-rename-sort WorkingDirectory=/home/$CURRENT_USER/pdf-rename-sort
Environment="PATH=/home/$CURRENT_USER/pdf-rename-sort/venv/bin" Environment="PATH=/home/$CURRENT_USER/pdf-rename-sort/venv/bin"
Environment="SECRET_KEY=CHANGE_THIS_SECRET_KEY_IN_PRODUCTION" Environment="SECRET_KEY=CHANGE_THIS_SECRET_KEY_IN_PRODUCTION"
Environment="TENANT_ID=YOUR_MICROSOFT_ENTRA_TENANT_ID" Environment="TENANT_ID=${TENANT_ID:-YOUR_MICROSOFT_ENTRA_TENANT_ID}"
Environment="CLIENT_ID=YOUR_MICROSOFT_ENTRA_CLIENT_ID" Environment="CLIENT_ID=${CLIENT_ID:-YOUR_MICROSOFT_ENTRA_CLIENT_ID}"
Environment="CLIENT_SECRET=YOUR_MICROSOFT_ENTRA_CLIENT_SECRET" Environment="CLIENT_SECRET=${CLIENT_SECRET:-YOUR_MICROSOFT_ENTRA_CLIENT_SECRET}"
Environment="ADMIN_USERNAME=trbcit" Environment="ADMIN_USERNAME=$ADMIN_USER"
Environment="ADMIN_PASSWORD=CHANGE_THIS_PASSWORD" Environment="ADMIN_PASSWORD=$ADMIN_PASS"
ExecStart=/home/$CURRENT_USER/pdf-rename-sort/venv/bin/gunicorn --bind 127.0.0.1:3000 pdf_renamer:app ExecStart=/home/$CURRENT_USER/pdf-rename-sort/venv/bin/gunicorn --bind 127.0.0.1:3000 pdf_renamer:app
Restart=always Restart=always
@@ -127,7 +166,7 @@ echo "Configuring Nginx reverse proxy for PDF Renamer..."
sudo tee /etc/nginx/sites-available/pdf-renamer > /dev/null <<EOF sudo tee /etc/nginx/sites-available/pdf-renamer > /dev/null <<EOF
server { server {
listen 80; listen 80;
server_name nextgenpdf.trbc.org; # Production domain server_name $DOMAIN_NAME; # Configured domain
# Handle large file uploads (500MB) # Handle large file uploads (500MB)
client_max_body_size 500M; client_max_body_size 500M;
@@ -188,6 +227,11 @@ sudo nginx -t
echo "Reloading Nginx..." echo "Reloading Nginx..."
sudo systemctl reload nginx sudo systemctl reload nginx
# Install SSL certificate with Let's Encrypt
echo "Installing SSL certificate with Let's Encrypt..."
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d $DOMAIN_NAME --non-interactive --agree-tos --email admin@$DOMAIN_NAME
# Configure firewall (UFW) # Configure firewall (UFW)
echo "Configuring firewall..." echo "Configuring firewall..."
sudo ufw allow ssh sudo ufw allow ssh
@@ -202,7 +246,7 @@ echo "1. Go to Azure Portal > Microsoft Entra ID > App registrations"
echo "2. Create a new registration or use existing one" echo "2. Create a new registration or use existing one"
echo "3. Note the Application (client) ID and Directory (tenant) ID" echo "3. Note the Application (client) ID and Directory (tenant) ID"
echo "4. Add a client secret under Certificates & secrets" echo "4. Add a client secret under Certificates & secrets"
echo "5. Add redirect URI: https://nextgenpdf.trbc.org/auth/microsoft/callback" echo "5. Add redirect URI: https://$DOMAIN_NAME/auth/microsoft/callback"
echo "6. Grant appropriate permissions if needed" echo "6. Grant appropriate permissions if needed"
echo "" echo ""
echo "Next steps:" echo "Next steps:"
@@ -214,13 +258,12 @@ echo " - CLIENT_SECRET: Your Microsoft Entra client secret"
echo " - ADMIN_USERNAME and ADMIN_PASSWORD: Set secure admin credentials" echo " - ADMIN_USERNAME and ADMIN_PASSWORD: Set secure admin credentials"
echo "" echo ""
echo "2. Update the server_name in /etc/nginx/sites-available/pdf-renamer:" echo "2. Update the server_name in /etc/nginx/sites-available/pdf-renamer:"
echo " - Change 'pdf-renamer.your-domain.com' to 'nextgenpdf.trbc.org'" echo " - Change 'pdf-renamer.your-domain.com' to '$DOMAIN_NAME'"
echo " - Point your DNS for nextgenpdf.trbc.org to this server's IP" echo " - Point your DNS for $DOMAIN_NAME to this server's IP"
echo ""
echo "3. For SSL/HTTPS, install certbot:"
echo " sudo apt install certbot python3-certbot-nginx"
echo " sudo certbot --nginx -d nextgenpdf.trbc.org"
echo "" echo ""
echo "3. SSL certificate has been automatically installed with Let's Encrypt"
echo " - Certificate for: $DOMAIN_NAME"
echo " - Auto-renewal is configured"
echo "4. Reload systemd after updating environment variables:" echo "4. Reload systemd after updating environment variables:"
echo " sudo systemctl daemon-reload" echo " sudo systemctl daemon-reload"
echo " sudo systemctl restart pdf-renamer" echo " sudo systemctl restart pdf-renamer"
@@ -230,6 +273,6 @@ echo " sudo systemctl status pdf-renamer"
echo " sudo systemctl status nginx" echo " sudo systemctl status nginx"
echo "" echo ""
echo "NOTE: This setup runs alongside your existing app on port 5000." echo "NOTE: This setup runs alongside your existing app on port 5000."
echo "The PDF Renamer will be accessible at https://nextgenpdf.trbc.org." echo "The PDF Renamer will be accessible at https://$DOMAIN_NAME."
echo "File permissions have been set for web access (755 for directories)." echo "File permissions have been set for web access (755 for directories)."
echo "Installed for user: $CURRENT_USER" echo "Installed for user: $CURRENT_USER"