-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·84 lines (63 loc) · 2.8 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Author: [CrazyHxs]
# Navigate to the project directory
cd /home/user/dropshipv2
# Run the script
python3 start.sh
# Install requirements
pip3 install -r requirements.txt
# Run migrations
python3 dropship_project/manage.py migrate
# Create a superuser if it doesn't exist
python3 dropship_project/manage.py shell << END
# Create a superuser if it doesn't existpython3 dropship_project/manage.py shell << END
from django.contrib.auth import get_user_model
User = get_user_model()
if not User.objects.filter(is_superuser=True).exists():
User.objects.create_superuser('admin', '[email protected]', 'adminpassword')
print("Superuser created.")
else:
print("Superuser already exists.")
END
# Run the development server
python3 dropship_project/manage.py runserver 0.0.0.0:8000
# Function to create a superuser if one doesn't exist
# Create a superuser if one doesn't exist
# """
# This function attempts to create a superuser for the Django project if one does not already exist.
# It retrieves the user model using Django's get_user_model function and runs a Python command
# within the manage.py shell to check for the existence of a superuser. If no superuser is found,
# a new superuser is created with predefined credentials.
# """
create_superuser() -> None {
"""Create a superuser for the Django project if one does not already exist.
This function retrieves the user model using Django's get_user_model function
and runs a Python command within the manage.py shell to check for the
existence of a superuser. If no superuser is found, a new superuser is
created with predefined credentials.
"""
local user_model: str
user_model=$(python3 -c 'from django.contrib.auth import get_user_model; print(get_user_model().__module__ + "." + get_user_model().__qualname__)')
python3 dropship_project/manage.py shell << END
# Import the user model
from ${user_model} import ${user_model##*.}
from ${user_model} import ${user_model##*.}
# Check if a superuser exists
if not ${user_model##*.}.objects.filter(is_superuser=True).exists():
# Create a superuser
${user_model##*.}.objects.create_superuser('admin', '[email protected]', 'adminpassword')
if not ${user_model##*.}.objects.filter(is_superuser=True).exists():
${user_model##*.}.objects.create_superuser('admin', '[email protected]', 'adminpassword')
END
END
}
# Main script execution
create_superuser
# Collect static files
python3 dropship_project/manage.py collectstatic --no-input
# Start the scheduler in the background
python3 scheduler.py &
# Run the development server
python3 dropship_project/manage.py runserver 0.0.0.0:8000
# Start the development server
python3 dropship_project/manage.py runserver 0.0.0.0:8000