9 Commits

Author SHA1 Message Date
ducoterra
47d22200a9 log create project dir to pylogloc 2019-04-16 21:37:38 -04:00
ducoterra
b11d7b6ebc it's ok if tar gz files aren't removed 2019-04-16 21:29:40 -04:00
ducoterra
62c1e9cfc6 do not disable nginx 2019-04-16 21:27:45 -04:00
ducoterra
e8d23701e0 don't redownload python 2019-04-16 21:21:32 -04:00
ducoterra
f0333c9b27 only uninstall from usr/local/bin 2019-04-16 21:17:58 -04:00
ducoterra
9c42d31518 add uninstaller 2019-04-16 20:45:11 -04:00
ducoterra
6f47be3532 remove the right directories 2019-04-16 20:31:14 -04:00
ducoterra
456a336150 cd out of install directory 2019-04-16 20:25:26 -04:00
ducoterra
2af22596a4 clean up sqlite files 2019-04-16 17:34:26 -04:00
4 changed files with 64 additions and 178 deletions

View File

@@ -1,4 +1,4 @@
# Django Setup for Raspbian Jessie # Django Setup for Debian 9, Ubuntu. 18.04, and Raspbian Stretch
## Install ## Install
```bash ```bash
vim vars vim vars

View File

@@ -37,8 +37,9 @@ done
# Sqlite3 # Sqlite3
# Download and setup Sqlite3 and modules # Download and setup Sqlite3 and modules
################################################################################ ################################################################################
echo -e "Install Sqlite3" echo -e "Installing Sqlite3"
if [ ! -d sqlite ] ; then
# fetch Sqlite # fetch Sqlite
wget -O sqlite.tar.gz $sqlink 1> $pylogloc 2>> $pylogloc 3>> $pylogloc wget -O sqlite.tar.gz $sqlink 1> $pylogloc 2>> $pylogloc 3>> $pylogloc
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
@@ -52,6 +53,7 @@ if [ $? -ne 0 ] ; then
echo -e "Failed to unzip sqlite. $pylogmsg" echo -e "Failed to unzip sqlite. $pylogmsg"
exit 1 exit 1
fi fi
fi;
cd sqlite cd sqlite
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
@@ -81,6 +83,11 @@ if [ $? -ne 0 ] ; then
exit 1 exit 1
fi fi
cd ..
rm sqlite.tar.gz 1>> $pylogloc 2>> $pylogloc
if [ $? -ne 0 ] ; then
echo -e "\tNot removing Sqlite3 tar.gz file."
fi
################################################################################ ################################################################################
# Python # Python
@@ -88,6 +95,7 @@ fi
################################################################################ ################################################################################
echo -e "Installing Python" echo -e "Installing Python"
if [ ! -d python ] ; then
wget -O python.tar.gz $pylink 1> $pylogloc 2>> $pylogloc 3>> $pylogloc wget -O python.tar.gz $pylink 1> $pylogloc 2>> $pylogloc 3>> $pylogloc
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo -e "Failed to fetch python, make sure wget is installed and $pylink is what you're after. $pylogmsg" echo -e "Failed to fetch python, make sure wget is installed and $pylink is what you're after. $pylogmsg"
@@ -100,6 +108,7 @@ if [ $? -ne 0 ] ; then
echo -e "Failed to unzip python. $pylogmsg" echo -e "Failed to unzip python. $pylogmsg"
exit 1 exit 1
fi fi
fi
cd python cd python
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
@@ -136,127 +145,24 @@ if [ $? -ne 0 ] ; then
echo -e "pip upgrade failed. $pylogmsg" echo -e "pip upgrade failed. $pylogmsg"
exit 1 exit 1
fi fi
echo -e "\tInstalling virtualenv" echo -e "\tInstalling virtualenv"
python3 -m pip install virtualenv 1>> $pylogloc 2>> $pylogloc 3>> $pylogloc python3 -m pip install virtualenv 1>> $pylogloc 2>> $pylogloc 3>> $pylogloc
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo -e "installing virtualenv failed. $pylogmsg" echo -e "installing virtualenv failed. $pylogmsg"
exit 1 exit 1
fi fi
cd /root/
rm python.tar.xz 1>> $pylogloc 2>> $pylogloc cd ..
rm -rf python 1>> $pylogloc 2>> $pylogloc rm python.tar.gz 1>> $pylogloc 2>> $pylogloc
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo -e "Failed to remove Python install files. $pylogmsg" echo -e "\tNot removing Python tar.gz file."
fi fi
# ################################################################################ # create the sites directory
# # Django echo -e "\tCreating project directory"
# # Download, setup and configure Django mkdir /sites/ 1>> $pylogloc 2>> $pylogloc 3>> $pylogloc
# ################################################################################
# tput setaf 2
# echo -e "Starting Django project"
# tput setaf 9
# 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 # # Gunicorn

View File

@@ -9,18 +9,17 @@
# source vars # source vars
source vars source vars
# remove nginx conf # source vars
tput setaf 2 source vars
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 # remove python
tput setaf 2 echo "Uninstalling Python"
echo "Uninstalling gunicorn" for dir in $(whereis python3 | tr " " "\n" | grep usr/local/bin | tr "\n" " ");
tput setaf 9 do rm -r $dir;
systemctl disable gunicorn 1> /dev/null 2> /dev/null done;
systemctl stop gunicorn 1> /dev/null 2> /dev/null
rm -f /etc/systemd/system/gunicorn.service # remove sqlite
echo "Uninstalling Sqlite3"
for dir in $(whereis sqlite3 | tr " " "\n" | grep usr/local/bin | tr "\n" " ");
do rm -r $dir;
done;

View File

@@ -7,39 +7,20 @@
# source vars # source vars
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 # remove python
tput setaf 2 echo "Uninstalling Python"
echo "Uninstalling python" for dir in $(whereis python3 | tr " " "\n" | grep usr/local/bin | tr "\n" " ");
tput setaf 9 do rm -r $dir;
rm -rf $pyinstalldir 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 # remove yum dependencies
tput setaf 2
echo "Uninstalling dependencies" 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[@]}; for package in ${packages[@]};
do do
echo -e "\tRemoving $package" echo -e "\tRemoving $package"