mirror of
https://github.com/makeplane/plane.git
synced 2026-07-12 21:40:18 +02:00
fix: takeoff script for ee is added (#75)
This commit is contained in:
committed by
GitHub
parent
74a216d05e
commit
ae37ecf751
28
apiserver/bin/takeoff.ee
Normal file
28
apiserver/bin/takeoff.ee
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
python manage.py wait_for_db
|
||||
python manage.py migrate
|
||||
|
||||
# Create the default bucket
|
||||
#!/bin/bash
|
||||
|
||||
# Collect system information
|
||||
HOSTNAME=$(hostname)
|
||||
MAC_ADDRESS=$(ip link show | awk '/ether/ {print $2}' | head -n 1)
|
||||
CPU_INFO=$(cat /proc/cpuinfo)
|
||||
MEMORY_INFO=$(free -h)
|
||||
DISK_INFO=$(df -h)
|
||||
|
||||
# Concatenate information and compute SHA-256 hash
|
||||
SIGNATURE=$(echo "$HOSTNAME$MAC_ADDRESS$CPU_INFO$MEMORY_INFO$DISK_INFO" | sha256sum | awk '{print $1}')
|
||||
|
||||
# Export the variables
|
||||
export MACHINE_SIGNATURE=$SIGNATURE
|
||||
|
||||
# Register instance
|
||||
python manage.py setup_instance $INSTANCE_ADMIN_EMAIL
|
||||
|
||||
# Create the default bucket
|
||||
python manage.py create_bucket
|
||||
|
||||
exec gunicorn -w $GUNICORN_WORKERS -k uvicorn.workers.UvicornWorker plane.asgi:application --bind 0.0.0.0:${PORT:-8000} --max-requests 1200 --max-requests-jitter 1000 --access-logfile -
|
||||
@@ -1,8 +1,10 @@
|
||||
# Python imports
|
||||
import json
|
||||
import secrets
|
||||
import uuid
|
||||
|
||||
# Django imports
|
||||
from django.contrib.auth.hashers import make_password
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.utils import timezone
|
||||
|
||||
@@ -32,7 +34,11 @@ class Command(BaseCommand):
|
||||
|
||||
user = User.objects.filter(email=admin_email).first()
|
||||
if user is None:
|
||||
raise CommandError("User not found")
|
||||
user = User.objects.create(
|
||||
email=admin_email,
|
||||
username=uuid.uuid4().hex,
|
||||
password=make_password(uuid.uuid4().hex),
|
||||
)
|
||||
|
||||
try:
|
||||
# Check if the instance is registered
|
||||
@@ -40,7 +46,7 @@ class Command(BaseCommand):
|
||||
|
||||
if instance is None:
|
||||
instance = Instance.objects.create(
|
||||
instance_name="Plane Cloud US",
|
||||
instance_name="Plane Enterprise",
|
||||
instance_id=secrets.token_hex(12),
|
||||
license_key=None,
|
||||
api_key=secrets.token_hex(8),
|
||||
@@ -53,20 +59,16 @@ class Command(BaseCommand):
|
||||
)
|
||||
|
||||
# Get or create an instance admin
|
||||
_ , created = InstanceAdmin.objects.get_or_create(
|
||||
_, created = InstanceAdmin.objects.get_or_create(
|
||||
user=user, instance=instance, role=20, is_verified=True
|
||||
)
|
||||
|
||||
if not created:
|
||||
raise CommandError("given email is already an instance admin")
|
||||
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
f"Successful"
|
||||
self.stdout.write(
|
||||
self.style.WARNING("given email is already an instance admin")
|
||||
)
|
||||
)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS(f"Successful"))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
raise CommandError(
|
||||
"Failure"
|
||||
)
|
||||
raise CommandError("Failure")
|
||||
Reference in New Issue
Block a user