Fix Paperless setup script - remove Django dependency and simplify secret generation
This commit is contained in:
@@ -15,49 +15,61 @@ fi
|
||||
|
||||
# Generate a random secret key for Paperless
|
||||
echo "🔑 Generating Paperless secret key..."
|
||||
PAPERLESS_SECRET=$(python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")
|
||||
PAPERLESS_SECRET=$(openssl rand -base64 50 | tr -d "=+/" | cut -c1-50)
|
||||
|
||||
echo "📝 Add this to your .env file:"
|
||||
echo "📝 Please add this to your app/.env file:"
|
||||
echo "PAPERLESS_SECRET_KEY=$PAPERLESS_SECRET"
|
||||
echo ""
|
||||
echo "Press Enter to continue after you've added the secret key to your .env file..."
|
||||
read -r
|
||||
|
||||
# Start containers
|
||||
echo "🚀 Starting containers..."
|
||||
# Restart containers to pick up new environment variables
|
||||
echo "<EFBFBD> Restarting containers..."
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
|
||||
# Wait for database to be ready
|
||||
echo "⏳ Waiting for database to be ready..."
|
||||
sleep 60
|
||||
|
||||
# Wait for Paperless to be ready
|
||||
echo "⏳ Waiting for Paperless to initialize..."
|
||||
sleep 30
|
||||
|
||||
# Create database for Paperless if it doesn't exist
|
||||
echo "🗄️ Setting up Paperless database..."
|
||||
docker-compose exec -T db psql -U ${POSTGRES_USER:-stiftung} -d ${POSTGRES_DB:-stiftung} -c "CREATE DATABASE paperless_prod;" || echo "Database may already exist"
|
||||
docker-compose exec -T db psql -U ${POSTGRES_USER:-stiftung} -d ${POSTGRES_DB:-stiftung} -c "CREATE USER paperless_user WITH PASSWORD 'secure-paperless-password';" || echo "User may already exist"
|
||||
docker-compose exec -T db psql -U ${POSTGRES_USER:-stiftung} -d ${POSTGRES_DB:-stiftung} -c "GRANT ALL PRIVILEGES ON DATABASE paperless_prod TO paperless_user;" || echo "Privileges may already be granted"
|
||||
# Check if Paperless is running
|
||||
echo "🔍 Checking Paperless container status..."
|
||||
docker-compose ps paperless
|
||||
|
||||
# Run Paperless migrations
|
||||
echo "📊 Running Paperless migrations..."
|
||||
docker-compose exec -T paperless python3 manage.py migrate
|
||||
docker-compose exec -T paperless python3 manage.py migrate --no-input
|
||||
|
||||
# Create Paperless superuser
|
||||
# Create Paperless superuser non-interactively
|
||||
echo "👤 Creating Paperless superuser..."
|
||||
echo "Note: You'll need to set a strong password for the admin user"
|
||||
docker-compose exec paperless python3 manage.py createsuperuser --username admin --email admin@vhtv-stiftung.de
|
||||
|
||||
# Get API token
|
||||
echo "🔐 Getting API token for Django integration..."
|
||||
echo "You can get your API token by:"
|
||||
echo "1. Visiting https://vhtv-stiftung.de/paperless/admin/"
|
||||
echo "2. Going to Authentication and Authorization > Tokens"
|
||||
echo "3. Creating a new token for your admin user"
|
||||
echo "4. Adding the token to your .env file as PAPERLESS_API_TOKEN"
|
||||
docker-compose exec -T paperless python3 manage.py shell -c "
|
||||
from django.contrib.auth import get_user_model
|
||||
User = get_user_model()
|
||||
if not User.objects.filter(username='admin').exists():
|
||||
User.objects.create_superuser('admin', 'admin@vhtv-stiftung.de', 'admin123')
|
||||
print('Admin user created successfully')
|
||||
else:
|
||||
print('Admin user already exists')
|
||||
"
|
||||
|
||||
echo ""
|
||||
echo "✅ Paperless-ngx setup complete!"
|
||||
echo ""
|
||||
echo "📚 Next steps:"
|
||||
echo "1. Update your .env file with the generated PAPERLESS_SECRET_KEY"
|
||||
echo "2. Visit https://vhtv-stiftung.de/paperless/ to access Paperless"
|
||||
echo "3. Create an API token in the Paperless admin interface"
|
||||
echo "4. Update PAPERLESS_API_TOKEN in your .env file"
|
||||
echo "5. Restart containers: docker-compose restart"
|
||||
echo "📚 Login details:"
|
||||
echo "URL: https://vhtv-stiftung.de/paperless/"
|
||||
echo "Username: admin"
|
||||
echo "Password: admin123"
|
||||
echo ""
|
||||
echo "⚠️ IMPORTANT: Change the admin password immediately after first login!"
|
||||
echo ""
|
||||
echo "<22> Next steps:"
|
||||
echo "1. Visit https://vhtv-stiftung.de/paperless/ and change the admin password"
|
||||
echo "2. Go to https://vhtv-stiftung.de/paperless/admin/"
|
||||
echo "3. Navigate to Authentication and Authorization > Tokens"
|
||||
echo "4. Create a new token for the admin user"
|
||||
echo "5. Add the token to your app/.env file as PAPERLESS_API_TOKEN"
|
||||
echo "6. Restart containers: docker-compose restart"
|
||||
|
||||
Reference in New Issue
Block a user