Update
This commit is contained in:
1 parent
0eff4d1eaa
commit
068899798e
4 files changed
+46
-7
No files matched your search
@@ -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
|
||||
- **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
|
||||
- **File Storage**: Processed ZIP files are stored in the `processed/` folder within the application directory
|
||||
- **Limits**: Maximum upload size is limited to 500MB
|
||||
- **Output**: Creates a structured folder hierarchy within the downloaded ZIP (Episode/School/Grade/Gender)
|
||||
|
||||
|
||||
Binary file not shown.
+2
-1
@@ -11,7 +11,8 @@ from PyPDF2 import PdfReader
|
||||
from authlib.integrations.flask_client import OAuth
|
||||
|
||||
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.secret_key = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production')
|
||||
|
||||
|
||||
+43
-6
@@ -7,6 +7,21 @@ set -e
|
||||
|
||||
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
|
||||
echo "Updating system packages..."
|
||||
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)
|
||||
echo "Cloning the repository..."
|
||||
git clone https://gitlab.com/trbc-dev/pdf-rename-sort.git
|
||||
# Check if we're already in the repository directory
|
||||
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
|
||||
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
|
||||
# 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
|
||||
echo "Creating systemd service..."
|
||||
sudo tee /etc/systemd/system/pdf-renamer.service > /dev/null <<EOF
|
||||
@@ -42,9 +78,9 @@ Description=PDF Renamer Flask App
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=ubuntu
|
||||
WorkingDirectory=/home/ubuntu/pdf-rename-sort
|
||||
Environment="PATH=/home/ubuntu/pdf-rename-sort/venv/bin"
|
||||
User=$CURRENT_USER
|
||||
WorkingDirectory=/home/$CURRENT_USER/pdf-rename-sort
|
||||
Environment="PATH=/home/$CURRENT_USER/pdf-rename-sort/venv/bin"
|
||||
Environment="SECRET_KEY=CHANGE_THIS_SECRET_KEY_IN_PRODUCTION"
|
||||
Environment="TENANT_ID=YOUR_MICROSOFT_ENTRA_TENANT_ID"
|
||||
Environment="CLIENT_ID=YOUR_MICROSOFT_ENTRA_CLIENT_ID"
|
||||
@@ -59,7 +95,7 @@ WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# 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
|
||||
echo "Starting the application service..."
|
||||
@@ -86,7 +122,7 @@ server {
|
||||
|
||||
# Handle static files
|
||||
location /static {
|
||||
alias /home/ubuntu/pdf-rename-sort/static;
|
||||
alias /home/$CURRENT_USER/pdf-rename-sort/static;
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
@@ -176,3 +212,4 @@ echo " sudo systemctl status nginx"
|
||||
echo ""
|
||||
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 "Installed for user: $CURRENT_USER"
|
||||
Reference in new issue
Block a user