Created
July 22, 2016 05:35
-
-
Save Shellbye/fbbd4b82e61b392a5f45a4e9857f45f3 to your computer and use it in GitHub Desktop.
create django basic files with the deploy uwsgi config ini file and nginx conf file
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
| #!/usr/bin/env bash | |
| if [ $# -eq 0 ] | |
| then | |
| echo "Please input project name!" | |
| echo "Usage: ./auto_django_basic.sh project_name" | |
| exit | |
| fi | |
| echo $1 | |
| echo "Creating virtualenv $1..." | |
| virtualenv ~/.virtualenvs/$1 | |
| echo "Activate env..." | |
| source ~/.virtualenvs/$1/bin/activate | |
| echo "Upgrade pip..." | |
| pip install --upgrade pip | |
| echo "Install Django..." | |
| pip install django | |
| echo "Start project..." | |
| django-admin startproject $1 | |
| cd $1 | |
| echo "Get uwsgi ini file..." | |
| wget https://gist.githubusercontent.com/Shellbye/7e07c76a4c84d8a17066b2c691fc1bf1/raw/6ef7489b3deddd4b2b520d6b6b15f0802933fd0d/project_uwsgi.ini | |
| echo "Change the ini file content..." | |
| sed -i '' "s/project_name_to_be_replaced/$1/" project_uwsgi.ini | |
| mv project_uwsgi.ini uwsgi_$1.ini | |
| echo "Get nginx conf file..." | |
| wget https://gist.githubusercontent.com/Shellbye/7e07c76a4c84d8a17066b2c691fc1bf1/raw/6ef7489b3deddd4b2b520d6b6b15f0802933fd0d/project_nginx.conf | |
| echo "Change the conf file content..." | |
| sed -i '' "s/django_project/django_$1/" project_nginx.conf | |
| sed -i '' "s/project.sock/$1.sock/" project_nginx.conf | |
| mv project_nginx.conf nginx_$1.conf | |
| echo "Create Readme file..." | |
| echo $1 > README.md | |
| echo "Get the restart script..." | |
| wget https://gist.githubusercontent.com/Shellbye/7e07c76a4c84d8a17066b2c691fc1bf1/raw/6ef7489b3deddd4b2b520d6b6b15f0802933fd0d/restart.sh | |
| echo "Change the script content..." | |
| sed -i '' "s/project_uwsgi/$1/" restart.sh | |
| echo "Get the deploy script..." | |
| wget https://gist.githubusercontent.com/Shellbye/7e07c76a4c84d8a17066b2c691fc1bf1/raw/d115ce1877f3a61d71afea14f178311f948cb9ba/deploy.sh | |
| echo "Create the pip requirements.txt..." | |
| touch requirements.txt | |
| echo "Get the gitignore file..." | |
| wget https://gist.githubusercontent.com/Shellbye/e9f7510add592eaaaeb0ac4e5b2a9e65/raw/85d59e87f19831d99be4bc6ee17f964aa9f2fdf3/.gitignore | |
| echo "Init git repository..." | |
| git init | |
| echo "Commit the init status" | |
| git add . | |
| git commit -m "init" | |
| echo "OK" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment