-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
59 lines (51 loc) · 1.53 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
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
echo -e "\n"
echo " █████ ██████ ████████ ██████ ███████"
echo " ██ ██ ██ ██ ██ ██ ██ ██ "
echo " ███████ ██████ ██ ██████ ███████"
echo " ██ ██ ██ ██ ██ ██ ██"
echo " ██ ██ ██ ██ ██ ██ ███████"
printf "\n\t\e[1;33m Version 0.1\n\n \e[0m\n"
var="$1"
function validate_ip () {
local IP=$1
local stat=1
if [[ $IP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
IFS='.'
ip=($IP)
IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
fi
if [ "$stat" -eq 0 ]; then
return $stat
else
echo 'Bad IP'
exit 1
fi
}
function validate_port () {
local PORT=$1
if [ -z "$PORT" ]; then
echo 'Port can not be empty'
exit 1
fi
if [ "$PORT" -gt 1024 ] && [ "$PORT" -lt 65535 ]; then
return 0
else
echo 'Invalid Port'
exit 1
fi
}
if [ ! -z "$var" ]; then
IP=$(echo $var | awk -F':' '{print $1}')
PORT=$(echo $var | awk -F':' '{print $2}')
validate_ip $IP
validate_port $PORT
else
IP='0.0.0.0'
PORT='8000'
fi
source venv/bin/activate && python3 -m gunicorn -b ${IP}:${PORT} APTRS.wsgi:application --workers=1 --threads=10 --timeout=5600