Created
September 20, 2012 08:20
-
-
Save dhruvbaldawa/3754646 to your computer and use it in GitHub Desktop.
Bash script for automating some of django database cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### I am no Bash expert, I just googled and put this script together | |
#### Be free to fork and post updates to this gist | |
#### Also, you can change the username and email below for the django superuser | |
DEFAULT_USER="admin" | |
DEFAULT_EMAIL="[email protected]" | |
DEFAULT_PASS="pass" | |
function usage | |
{ | |
echo "usage: $0 [-r | --runserver]" | |
} | |
runserver= | |
while [ "$1" != "" ]; do | |
case $1 in | |
-r | --runserver ) runserver=1 | |
;; | |
-h | --help ) usage | |
exit | |
;; | |
* ) usage | |
exit 1 | |
esac | |
shift | |
done | |
######## MAIN CLEAN ######### | |
rm website.db | |
python manage.py syncdb --noinput | |
python manage.py migrate | |
### Create super-user | |
echo "from django.contrib.auth.models import User; User.objects.create_superuser('$DEFAULT_USER', '$DEFAULT_EMAIL', '$DEFAULT_PASS')" | python manage.py shell --plain | |
######## OPTIONAL RUNSERVER ######## | |
if [ "$runserver" = "1" ]; then | |
python manage.py runserver | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment