-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRUN.sh
49 lines (40 loc) · 1.16 KB
/
RUN.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
#!/bin/bash
# Set the virtual environment directory
VENV_DIR="PYTHON_ENV"
# Activate the virtual environment based on the operating system
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
# Windows
source "$VENV_DIR/Scripts/activate"
echo "Environment activated"
else
# Linux/Mac
source "$VENV_DIR/bin/activate"
echo "Environment activated"
fi
# Variable to store IP addresses
ip_address=""
# Function to get IP addresses on Linux
get_ip_linux() {
ip_address=$(ip addr | awk '/inet / {print $2}' | cut -f1 -d'/' | sed -n '2p')
}
# Function to get IP addresses on Windows
get_ip_windows() {
ip_address=$(ipconfig | awk '/IPv4 Address/ {print $NF}')
}
# Check the operating system and call the appropriate function
if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then
# Linux
get_ip_linux
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
# Windows
echo "Win"
get_ip_windows
else
echo "Unsupported operating system."
exit 1
fi
# Print the IP addresses
echo "Network ip addresses:"
echo $ip_address
# Run the project
python manage.py runserver "$ip_address:8000"