-
Notifications
You must be signed in to change notification settings - Fork 1
/
rs
executable file
·35 lines (29 loc) · 824 Bytes
/
rs
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
#!/bin/sh
# Start the Django project in the current directory using runserver,
# with a unique port if the project name is known, and then open
# the front page in a browser.
if [ "$1" = "." ] ; then
# "." means don't open the page in a browser
OPEN=false
shift
else
# Try to figure out how to open a page on this system, and set
# OPEN to the command.
case `uname` in
Darwin) OPEN=open;;
Linux) OPEN=xdg-open;;
*) echo "Don't know how to open URLs on "`uname`; exit 1;;
esac
fi
case $VIRTUAL_ENV in
*/Project1) PORT=8001;;
*/Project2) PORT=8002;;
# ...
*) PORT=8000;;
esac
TARGET=localhost:$PORT
# Open page in browser after giving Django a few seconds to start
if [ "$OPEN" != "false" ] ; then
(sleep 4;$OPEN http://$TARGET)&
fi
exec python manage.py runserver "$@" "$TARGET"