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
|
# Generate a random secret key for Paperless
|
||||||
echo "🔑 Generating Paperless secret key..."
|
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 "PAPERLESS_SECRET_KEY=$PAPERLESS_SECRET"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "Press Enter to continue after you've added the secret key to your .env file..."
|
||||||
|
read -r
|
||||||
|
|
||||||
# Start containers
|
# Restart containers to pick up new environment variables
|
||||||
echo "🚀 Starting containers..."
|
echo "<EFBFBD> Restarting containers..."
|
||||||
|
docker-compose down
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
|
||||||
# Wait for database to be ready
|
# Wait for database to be ready
|
||||||
echo "⏳ Waiting 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
|
sleep 30
|
||||||
|
|
||||||
# Create database for Paperless if it doesn't exist
|
# Check if Paperless is running
|
||||||
echo "🗄️ Setting up Paperless database..."
|
echo "🔍 Checking Paperless container status..."
|
||||||
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 ps paperless
|
||||||
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"
|
|
||||||
|
|
||||||
# Run Paperless migrations
|
# Run Paperless migrations
|
||||||
echo "📊 Running 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 "👤 Creating Paperless superuser..."
|
||||||
echo "Note: You'll need to set a strong password for the admin user"
|
docker-compose exec -T paperless python3 manage.py shell -c "
|
||||||
docker-compose exec paperless python3 manage.py createsuperuser --username admin --email admin@vhtv-stiftung.de
|
from django.contrib.auth import get_user_model
|
||||||
|
User = get_user_model()
|
||||||
# Get API token
|
if not User.objects.filter(username='admin').exists():
|
||||||
echo "🔐 Getting API token for Django integration..."
|
User.objects.create_superuser('admin', 'admin@vhtv-stiftung.de', 'admin123')
|
||||||
echo "You can get your API token by:"
|
print('Admin user created successfully')
|
||||||
echo "1. Visiting https://vhtv-stiftung.de/paperless/admin/"
|
else:
|
||||||
echo "2. Going to Authentication and Authorization > Tokens"
|
print('Admin user already exists')
|
||||||
echo "3. Creating a new token for your admin user"
|
"
|
||||||
echo "4. Adding the token to your .env file as PAPERLESS_API_TOKEN"
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "✅ Paperless-ngx setup complete!"
|
echo "✅ Paperless-ngx setup complete!"
|
||||||
echo ""
|
echo ""
|
||||||
echo "📚 Next steps:"
|
echo "📚 Login details:"
|
||||||
echo "1. Update your .env file with the generated PAPERLESS_SECRET_KEY"
|
echo "URL: https://vhtv-stiftung.de/paperless/"
|
||||||
echo "2. Visit https://vhtv-stiftung.de/paperless/ to access Paperless"
|
echo "Username: admin"
|
||||||
echo "3. Create an API token in the Paperless admin interface"
|
echo "Password: admin123"
|
||||||
echo "4. Update PAPERLESS_API_TOKEN in your .env file"
|
echo ""
|
||||||
echo "5. Restart containers: docker-compose restart"
|
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