Compare commits
9 Commits
debian
...
debian-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47d22200a9 | ||
|
|
b11d7b6ebc | ||
|
|
62c1e9cfc6 | ||
|
|
e8d23701e0 | ||
|
|
f0333c9b27 | ||
|
|
9c42d31518 | ||
|
|
6f47be3532 | ||
|
|
456a336150 | ||
|
|
2af22596a4 |
@@ -1,4 +1,4 @@
|
||||
# Django Setup for Raspbian Jessie
|
||||
# Django Setup for Debian 9, Ubuntu. 18.04, and Raspbian Stretch
|
||||
## Install
|
||||
```bash
|
||||
vim vars
|
||||
|
||||
158
install.sh
158
install.sh
@@ -37,21 +37,23 @@ done
|
||||
# Sqlite3
|
||||
# Download and setup Sqlite3 and modules
|
||||
################################################################################
|
||||
echo -e "Install Sqlite3"
|
||||
echo -e "Installing Sqlite3"
|
||||
|
||||
# fetch Sqlite
|
||||
wget -O sqlite.tar.gz $sqlink 1> $pylogloc 2>> $pylogloc 3>> $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
if [ ! -d sqlite ] ; then
|
||||
# fetch Sqlite
|
||||
wget -O sqlite.tar.gz $sqlink 1> $pylogloc 2>> $pylogloc 3>> $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo -e "Failed to fetch sqlite, make sure wget is installed and $pylink is what you're after. $pylogmsg"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir sqlite
|
||||
tar xf sqlite.tar.gz -C sqlite --strip-components=1 1>> $pylogloc 2>> $pylogloc 3>> $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
mkdir sqlite
|
||||
tar xf sqlite.tar.gz -C sqlite --strip-components=1 1>> $pylogloc 2>> $pylogloc 3>> $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo -e "Failed to unzip sqlite. $pylogmsg"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi;
|
||||
|
||||
cd sqlite
|
||||
if [ $? -ne 0 ] ; then
|
||||
@@ -81,6 +83,11 @@ if [ $? -ne 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd ..
|
||||
rm sqlite.tar.gz 1>> $pylogloc 2>> $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo -e "\tNot removing Sqlite3 tar.gz file."
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# Python
|
||||
@@ -88,17 +95,19 @@ fi
|
||||
################################################################################
|
||||
echo -e "Installing Python"
|
||||
|
||||
wget -O python.tar.gz $pylink 1> $pylogloc 2>> $pylogloc 3>> $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
if [ ! -d python ] ; then
|
||||
wget -O python.tar.gz $pylink 1> $pylogloc 2>> $pylogloc 3>> $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo -e "Failed to fetch python, make sure wget is installed and $pylink is what you're after. $pylogmsg"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir python
|
||||
tar xf python.tar.gz -C python --strip-components=1 1>> $pylogloc 2>> $pylogloc 3>> $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
mkdir python
|
||||
tar xf python.tar.gz -C python --strip-components=1 1>> $pylogloc 2>> $pylogloc 3>> $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo -e "Failed to unzip python. $pylogmsg"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
cd python
|
||||
@@ -136,127 +145,24 @@ if [ $? -ne 0 ] ; then
|
||||
echo -e "pip upgrade failed. $pylogmsg"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "\tInstalling virtualenv"
|
||||
python3 -m pip install virtualenv 1>> $pylogloc 2>> $pylogloc 3>> $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo -e "installing virtualenv failed. $pylogmsg"
|
||||
exit 1
|
||||
fi
|
||||
cd /root/
|
||||
rm python.tar.xz 1>> $pylogloc 2>> $pylogloc
|
||||
rm -rf python 1>> $pylogloc 2>> $pylogloc
|
||||
|
||||
cd ..
|
||||
rm python.tar.gz 1>> $pylogloc 2>> $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo -e "Failed to remove Python install files. $pylogmsg"
|
||||
echo -e "\tNot removing Python tar.gz file."
|
||||
fi
|
||||
|
||||
# ################################################################################
|
||||
# # Django
|
||||
# # Download, setup and configure Django
|
||||
# ################################################################################
|
||||
# tput setaf 2
|
||||
# echo -e "Starting Django project"
|
||||
# tput setaf 9
|
||||
# create the sites directory
|
||||
echo -e "\tCreating project directory"
|
||||
mkdir /sites/ 1>> $pylogloc 2>> $pylogloc 3>> $pylogloc
|
||||
|
||||
# adduser $user 1> /dev/null 2> /dev/null 3> /dev/null
|
||||
# if [ ! -d "/home/$user" ] ; then
|
||||
# mkdir /home/$user
|
||||
# chown -R $user:$user /home/$user
|
||||
# fi
|
||||
# mkdir /home/$user/$projectname
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to create $projectname directory. $djamsg"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# # virtual environment
|
||||
# echo -e "\tCreating venv"
|
||||
# cd /home/$user/$projectname
|
||||
# /usr/src/python37/bin/python3.7 -m virtualenv venv 1>> $djalogloc 2>> $djalogloc 3>> $djalogloc
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to create virtual environment. $djamsg"
|
||||
# exit 1
|
||||
# fi
|
||||
# source venv/bin/activate 1>> $djalogloc 2>> $djalogloc 3>> $djalogloc
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to source virtual environment. $djamsg"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# # pip installs
|
||||
# pips=(django gunicorn psycopg2-binary)
|
||||
# for pip in ${pips[@]};
|
||||
# do
|
||||
# echo -e "\tInstalling $pip"
|
||||
# pip install $pip 1>> $djalogloc 2>> $djalogloc 3>> $djalogloc
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to install $pip. $djamsg"
|
||||
# exit 1
|
||||
# fi
|
||||
# done
|
||||
|
||||
# if [ $usegit = False ] ; then
|
||||
# # start django project in the project directory
|
||||
# echo -e "\tStarting django project"
|
||||
# django-admin startproject config . 1>> $djalogloc 2>> $djalogloc 3>> $djalogloc
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to start project $projectname with django-admin. $djamsg"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# # update allowed hosts
|
||||
# echo -e "echo -e sed -i 's/ALLOWED_HOSTS = []/ALLOWED_HOSTS = ['localhost', os.environ.get('HOST')'] config/settings.py" >> $djalogloc
|
||||
# # | FROM | TO |
|
||||
# sed -i "s/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = \['localhost', os.environ.get('HOST')\]/" config/settings.py
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to change ALLOWED_HOSTS. $djamsg"
|
||||
# exit 1
|
||||
# fi
|
||||
# echo -e "echo -e STATIC_ROOT = os.path.join(BASE_DIR, 'static') >> config//settings.py" >> $djalogloc
|
||||
# echo -e "STATIC_ROOT = os.path.join(BASE_DIR, 'static')" >> config/settings.py
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to append STATIC_ROOT. $djamsg"
|
||||
# exit 1
|
||||
# fi
|
||||
# fi
|
||||
|
||||
# if [ $usegit = True ] ; then
|
||||
# echo -e "\tCloning django project"
|
||||
# git init 1>> $gitlogloc 2>> $gitlogloc 3>> $gitlogloc;
|
||||
# git remote add origin $giturl 1>> $gitlogloc 2>> $gitlogloc 3>> $gitlogloc;
|
||||
# ssh-agent bash -c 'ssh-add $gitkey 1>> $gitlogloc 2>> $gitlogloc 3>> $gitlogloc;
|
||||
# git pull origin master 1>> $gitlogloc 2>> $gitlogloc 3>> $gitlogloc;'
|
||||
# echo -e "\tInstalling pip requirements"
|
||||
# pip install -r requirements.txt 1>> $gitlogloc 2>> $gitlogloc 3>> $gitlogloc
|
||||
# fi
|
||||
|
||||
# # collect static, migrate
|
||||
# echo -e "\tCollecting static"
|
||||
# python manage.py collectstatic 1>> $djalogloc 2>> $djalogloc 3>> $djalogloc
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to collect static files. $djamsg"
|
||||
# exit 1
|
||||
# fi
|
||||
# echo -e "\tMaking migrations"
|
||||
# python manage.py makemigrations 1>> $djalogloc 2>> $djalogloc 3>> $djalogloc
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to make migrations. $djamsg"
|
||||
# exit 1
|
||||
# fi
|
||||
# echo -e "\tMigrating"
|
||||
# python manage.py migrate 1>> $djalogloc 2>> $djalogloc 3>> $djalogloc
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to migrate. You do not survive the winter. $djamsg"
|
||||
# exit 1
|
||||
# fi
|
||||
# deactivate
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to deactivate virtual environment, (this may not be an issue). $djamsg"
|
||||
# fi
|
||||
# chown -R $user:$user .
|
||||
# if [ $? -ne 0 ] ; then
|
||||
# echo -e "Failed to change permissions of $projectname. $djamsg"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# ################################################################################
|
||||
# # Gunicorn
|
||||
|
||||
27
reset.sh
27
reset.sh
@@ -9,18 +9,17 @@
|
||||
# source vars
|
||||
source vars
|
||||
|
||||
# remove nginx conf
|
||||
tput setaf 2
|
||||
echo "Disabling nginx"
|
||||
tput setaf 9
|
||||
systemctl stop nginx 1> /dev/null 2> /dev/null
|
||||
systemctl disable nginx 1> /dev/null 2> /dev/null
|
||||
rm -f /etc/nginx/conf.d/$projectname.conf
|
||||
# source vars
|
||||
source vars
|
||||
|
||||
# remove gunicorn
|
||||
tput setaf 2
|
||||
echo "Uninstalling gunicorn"
|
||||
tput setaf 9
|
||||
systemctl disable gunicorn 1> /dev/null 2> /dev/null
|
||||
systemctl stop gunicorn 1> /dev/null 2> /dev/null
|
||||
rm -f /etc/systemd/system/gunicorn.service
|
||||
# remove python
|
||||
echo "Uninstalling Python"
|
||||
for dir in $(whereis python3 | tr " " "\n" | grep usr/local/bin | tr "\n" " ");
|
||||
do rm -r $dir;
|
||||
done;
|
||||
|
||||
# remove sqlite
|
||||
echo "Uninstalling Sqlite3"
|
||||
for dir in $(whereis sqlite3 | tr " " "\n" | grep usr/local/bin | tr "\n" " ");
|
||||
do rm -r $dir;
|
||||
done;
|
||||
39
uninstall.sh
39
uninstall.sh
@@ -7,39 +7,20 @@
|
||||
# source vars
|
||||
source vars
|
||||
|
||||
# remove nginx conf
|
||||
tput setaf 2
|
||||
echo "Disabling nginx"
|
||||
tput setaf 9
|
||||
systemctl stop nginx 1> /dev/null 2> /dev/null
|
||||
systemctl disable nginx 1> /dev/null 2> /dev/null
|
||||
rm -f /etc/nginx/conf.d/$projectname.conf
|
||||
|
||||
# remove gunicorn
|
||||
tput setaf 2
|
||||
echo "Uninstalling gunicorn"
|
||||
tput setaf 9
|
||||
systemctl disable gunicorn 1> /dev/null 2> /dev/null
|
||||
systemctl stop gunicorn 1> /dev/null 2> /dev/null
|
||||
rm -f /etc/systemd/system/gunicorn.service
|
||||
|
||||
# remove project
|
||||
tput setaf 2
|
||||
echo "Removing Django project"
|
||||
tput setaf 9
|
||||
rm -rf /home/$user/$projectname
|
||||
|
||||
# remove python
|
||||
tput setaf 2
|
||||
echo "Uninstalling python"
|
||||
tput setaf 9
|
||||
rm -rf $pyinstalldir
|
||||
echo "Uninstalling Python"
|
||||
for dir in $(whereis python3 | tr " " "\n" | grep usr/local/bin | tr "\n" " ");
|
||||
do rm -r $dir;
|
||||
done;
|
||||
|
||||
# remove sqlite
|
||||
echo "Uninstalling Sqlite3"
|
||||
for dir in $(whereis sqlite3 | tr " " "\n" | grep usr/local/bin | tr "\n" " ");
|
||||
do rm -r $dir;
|
||||
done;
|
||||
|
||||
# remove yum dependencies
|
||||
tput setaf 2
|
||||
echo "Uninstalling dependencies"
|
||||
tput setaf 9
|
||||
packages=(gcc wget nginx ufw make sqlite3 bzip2 openssl libffi-dev libssl-dev libsqlite3-dev zlib1g-dev libbz2-dev)
|
||||
for package in ${packages[@]};
|
||||
do
|
||||
echo -e "\tRemoving $package"
|
||||
|
||||
Reference in New Issue
Block a user