This commit is contained in:
nmemmert committed 2025-11-06 14:22:43 -05:00
1 parent 0eff4d1eaa
commit 068899798e
4 files changed
+47 -8

No files matched your search

+1
View File
@@ -128,6 +128,7 @@ Users can choose their preferred login method on the login page.
- **Processing Requirements**: All five pieces of student information must be present for the PDF to be processed - **Processing Requirements**: All five pieces of student information must be present for the PDF to be processed
- **Error Handling**: Files without the required information or with extraction errors will be skipped with detailed error messages - **Error Handling**: Files without the required information or with extraction errors will be skipped with detailed error messages
- **Security**: All processing happens server-side with temporary file storage - **Security**: All processing happens server-side with temporary file storage
- **File Storage**: Processed ZIP files are stored in the `processed/` folder within the application directory
- **Limits**: Maximum upload size is limited to 500MB - **Limits**: Maximum upload size is limited to 500MB
- **Output**: Creates a structured folder hierarchy within the downloaded ZIP (Episode/School/Grade/Gender) - **Output**: Creates a structured folder hierarchy within the downloaded ZIP (Episode/School/Grade/Gender)
Binary file not shown.
+2 -1
View File
@@ -11,7 +11,8 @@ from PyPDF2 import PdfReader
from authlib.integrations.flask_client import OAuth from authlib.integrations.flask_client import OAuth
app = Flask(__name__) app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = tempfile.mkdtemp() app.config['UPLOAD_FOLDER'] = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'processed')
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
app.config['MAX_CONTENT_LENGTH'] = 500 * 1024 * 1024 # 500MB limit app.config['MAX_CONTENT_LENGTH'] = 500 * 1024 * 1024 # 500MB limit
app.secret_key = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production') app.secret_key = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production')
+44 -7
View File
@@ -7,6 +7,21 @@ set -e
echo "Starting installation of PDF Renamer Flask App..." echo "Starting installation of PDF Renamer Flask App..."
# Check if already installed
if systemctl is-active --quiet pdf-renamer 2>/dev/null; then
echo "WARNING: PDF Renamer service is already running."
echo "This will reinstall/update the application."
echo "Press Ctrl+C to cancel or Enter to continue..."
read -r || exit 1
fi
# Check if running with sudo
if [ "$EUID" -ne 0 ]; then
echo "ERROR: This script must be run with sudo privileges"
echo "Usage: sudo ./ubuntu-install.sh"
exit 1
fi
# Update system packages # Update system packages
echo "Updating system packages..." echo "Updating system packages..."
sudo apt update && sudo apt upgrade -y sudo apt update && sudo apt upgrade -y
@@ -17,8 +32,25 @@ sudo apt install -y python3 python3-pip python3-venv nginx git
# Clone the repository (replace with your actual repo URL if different) # Clone the repository (replace with your actual repo URL if different)
echo "Cloning the repository..." echo "Cloning the repository..."
git clone https://gitlab.com/trbc-dev/pdf-rename-sort.git # Check if we're already in the repository directory
cd pdf-rename-sort if [ -d ".git" ]; then
echo "Already in repository directory, skipping clone..."
else
# Try HTTPS first, fallback to SSH if available
if git clone https://gitlab.com/trbc-dev/pdf-rename-sort.git 2>/dev/null; then
echo "Cloned via HTTPS"
cd pdf-rename-sort
elif git clone git@gitlab.com:trbc-dev/pdf-rename-sort.git 2>/dev/null; then
echo "Cloned via SSH"
cd pdf-rename-sort
else
echo "ERROR: Could not clone repository. Please check:"
echo "1. Repository URL is correct"
echo "2. SSH keys are configured (for SSH clone)"
echo "3. Internet connection is working"
exit 1
fi
fi
# Create virtual environment and install dependencies # Create virtual environment and install dependencies
echo "Setting up Python virtual environment..." echo "Setting up Python virtual environment..."
@@ -34,6 +66,10 @@ mkdir -p static
# Copy logo if it exists in repo, otherwise you'll need to add it # Copy logo if it exists in repo, otherwise you'll need to add it
# cp path/to/trbc-logo-full.png static/ # Uncomment and adjust if needed # cp path/to/trbc-logo-full.png static/ # Uncomment and adjust if needed
# Get the current user (fallback to ubuntu if not detected)
CURRENT_USER=${USER:-ubuntu}
echo "Installing for user: $CURRENT_USER"
# Create systemd service file # Create systemd service file
echo "Creating systemd service..." echo "Creating systemd service..."
sudo tee /etc/systemd/system/pdf-renamer.service > /dev/null <<EOF sudo tee /etc/systemd/system/pdf-renamer.service > /dev/null <<EOF
@@ -42,9 +78,9 @@ Description=PDF Renamer Flask App
After=network.target After=network.target
[Service] [Service]
User=ubuntu User=$CURRENT_USER
WorkingDirectory=/home/ubuntu/pdf-rename-sort WorkingDirectory=/home/$CURRENT_USER/pdf-rename-sort
Environment="PATH=/home/ubuntu/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=YOUR_MICROSOFT_ENTRA_TENANT_ID"
Environment="CLIENT_ID=YOUR_MICROSOFT_ENTRA_CLIENT_ID" Environment="CLIENT_ID=YOUR_MICROSOFT_ENTRA_CLIENT_ID"
@@ -59,7 +95,7 @@ WantedBy=multi-user.target
EOF EOF
# Set proper permissions # Set proper permissions
sudo chown -R ubuntu:ubuntu /home/ubuntu/pdf-rename-sort sudo chown -R $CURRENT_USER:$CURRENT_USER /home/$CURRENT_USER/pdf-rename-sort
# Enable and start the service # Enable and start the service
echo "Starting the application service..." echo "Starting the application service..."
@@ -86,7 +122,7 @@ server {
# Handle static files # Handle static files
location /static { location /static {
alias /home/ubuntu/pdf-rename-sort/static; alias /home/$CURRENT_USER/pdf-rename-sort/static;
expires 1y; expires 1y;
add_header Cache-Control "public, immutable"; add_header Cache-Control "public, immutable";
} }
@@ -176,3 +212,4 @@ 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 your subdomain on port 80/443." echo "The PDF Renamer will be accessible at your subdomain on port 80/443."
echo "Installed for user: $CURRENT_USER"