fix color issues with uninstaller
This commit is contained in:
62
README.md
62
README.md
@@ -1,19 +1,61 @@
|
|||||||
# Django Setup for CentOS 7
|
# Django Installer for CentOS 7
|
||||||
## Quick Install
|
## Quick Install
|
||||||
```bash
|
```bash
|
||||||
vim vars
|
$ git clone https://gitlab.ducoterra.net/server/django_installer.git
|
||||||
|
$ cd django_installer
|
||||||
|
$ vim vars
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# django project settings
|
# django project settings
|
||||||
export user="centos" <-- change to your user
|
# django project settings
|
||||||
export projectname="mysite"
|
export user="centos" <---- set to your user (can use nginx)
|
||||||
export hostname="centos.duco.net" <-- change to your hostname
|
export projectname="mysite" <---- set to your project name
|
||||||
export letsencrypt=False
|
# TODO:
|
||||||
|
# change hostname to an array:
|
||||||
|
# (hostname1.net hostname2.net hostname2.net)
|
||||||
|
export hostname="centos.duco.net" <---- set to your hostname (ip or domain)
|
||||||
|
export letsencrypt=False <---- not working yet
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo ./install.sh
|
$ sudo ./install.sh
|
||||||
|
Installing dependencies
|
||||||
|
Installing gcc
|
||||||
|
Installing wget
|
||||||
|
Installing nginx
|
||||||
|
Installing libsqlite3x-devel.x86_64
|
||||||
|
Installing postgresql-server
|
||||||
|
Installing postgresql-devel
|
||||||
|
Installing postgresql-contrib
|
||||||
|
Installing bzip2-devel
|
||||||
|
Installing zlib-devel
|
||||||
|
Installing libffi-devel
|
||||||
|
Installing openssl-devel
|
||||||
|
Installing policycoreutils-python.x86_64
|
||||||
|
Installing Python
|
||||||
|
Configure
|
||||||
|
Make
|
||||||
|
Make altinstall
|
||||||
|
Upgrading pip
|
||||||
|
Installing virtualenv
|
||||||
|
Starting Django project
|
||||||
|
Creating venv
|
||||||
|
Installing django
|
||||||
|
Installing gunicorn
|
||||||
|
Installing psycopg2-binary
|
||||||
|
Starting django project
|
||||||
|
Collecting static
|
||||||
|
Making migrations
|
||||||
|
Migrating
|
||||||
|
Setting up gunicorn
|
||||||
|
Starting gunicorn
|
||||||
|
Enabling gunicorn at startup
|
||||||
|
Configuring Nginx
|
||||||
|
Starting nginx
|
||||||
|
Enabling nginx
|
||||||
|
Done!
|
||||||
|
$
|
||||||
```
|
```
|
||||||
|
|
||||||
Done!
|
Done!
|
||||||
@@ -69,7 +111,7 @@ In order for this script to work its magic you'll need a few packages provided b
|
|||||||
```bash
|
```bash
|
||||||
# check if root
|
# check if root
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
echo -e "This script must be run as root"
|
echo -e "This script must be run as root"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd /root/
|
cd /root/
|
||||||
@@ -246,7 +288,7 @@ Next the script starts the Django project. You'll notice that the project struct
|
|||||||
│ └── manage.py
|
│ └── manage.py
|
||||||
└── venv/
|
└── venv/
|
||||||
```
|
```
|
||||||
When making changes to nginx or gunicorn it's important to keep this structure in mind. There are 3 folders called ```$projectname```.
|
When making changes to nginx or gunicorn it's important to keep this structure in mind. There are 3 folders called ```$projectname```.
|
||||||
|
|
||||||
After this, the script updates allowed hosts, collects static, and makes migrations.
|
After this, the script updates allowed hosts, collects static, and makes migrations.
|
||||||
|
|
||||||
@@ -295,4 +337,4 @@ if [ ! $user = "nginx" ] ; then
|
|||||||
sed -i "s/user nginx/user $user nginx/" /etc/nginx/nginx.conf
|
sed -i "s/user nginx/user $user nginx/" /etc/nginx/nginx.conf
|
||||||
fi
|
fi
|
||||||
```
|
```
|
||||||
Which inserts the specified user (if not nginx) into nginx.conf. The script finishes by enabling gunicorn and nginx at startup.
|
Which inserts the specified user (if not nginx) into nginx.conf. The script finishes by enabling gunicorn and nginx at startup.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ source ./vars
|
|||||||
|
|
||||||
# check if root
|
# check if root
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
echo -e "This script must be run as root"
|
echo -e "This script must be run as root"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd /root/
|
cd /root/
|
||||||
@@ -288,4 +288,4 @@ systemctl enable nginx 1>> $nginxlogloc 2>> $nginxlogloc
|
|||||||
tput setaf 2
|
tput setaf 2
|
||||||
echo -e "Done! Navigate to $hostname to access the site. Logs can be found in $logdir"
|
echo -e "Done! Navigate to $hostname to access the site. Logs can be found in $logdir"
|
||||||
tput setaf 9
|
tput setaf 9
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
12
uninstall.sh
12
uninstall.sh
@@ -4,7 +4,7 @@ source ./vars
|
|||||||
# remove nginx conf
|
# remove nginx conf
|
||||||
tput setaf 2
|
tput setaf 2
|
||||||
echo "Uninstalling nginx"
|
echo "Uninstalling nginx"
|
||||||
tput setaf 0
|
tput setaf 9
|
||||||
systemctl stop nginx 1> /dev/null 2> /dev/null
|
systemctl stop nginx 1> /dev/null 2> /dev/null
|
||||||
systemctl disable nginx 1> /dev/null 2> /dev/null
|
systemctl disable nginx 1> /dev/null 2> /dev/null
|
||||||
rm -f /etc/nginx/conf.d/$projectname.conf
|
rm -f /etc/nginx/conf.d/$projectname.conf
|
||||||
@@ -12,7 +12,7 @@ rm -f /etc/nginx/conf.d/$projectname.conf
|
|||||||
# remove gunicorn
|
# remove gunicorn
|
||||||
tput setaf 2
|
tput setaf 2
|
||||||
echo "Uninstalling gunicorn"
|
echo "Uninstalling gunicorn"
|
||||||
tput setaf 0
|
tput setaf 9
|
||||||
systemctl disable gunicorn 1> /dev/null 2> /dev/null
|
systemctl disable gunicorn 1> /dev/null 2> /dev/null
|
||||||
systemctl stop gunicorn 1> /dev/null 2> /dev/null
|
systemctl stop gunicorn 1> /dev/null 2> /dev/null
|
||||||
rm -f /etc/systemd/system/gunicorn.service
|
rm -f /etc/systemd/system/gunicorn.service
|
||||||
@@ -20,19 +20,19 @@ rm -f /etc/systemd/system/gunicorn.service
|
|||||||
# remove project
|
# remove project
|
||||||
tput setaf 2
|
tput setaf 2
|
||||||
echo "Removing Django project"
|
echo "Removing Django project"
|
||||||
tput setaf 0
|
tput setaf 9
|
||||||
rm -rf /home/$user/$projectname
|
rm -rf /home/$user/$projectname
|
||||||
|
|
||||||
# remove python
|
# remove python
|
||||||
tput setaf 2
|
tput setaf 2
|
||||||
echo "Uninstalling python"
|
echo "Uninstalling python"
|
||||||
tput setaf 0
|
tput setaf 9
|
||||||
rm -rf $pyinstalldir
|
rm -rf $pyinstalldir
|
||||||
|
|
||||||
# remove yum dependencies
|
# remove yum dependencies
|
||||||
tput setaf 2
|
tput setaf 2
|
||||||
echo "Uninstalling dependencies"
|
echo "Uninstalling dependencies"
|
||||||
tput setaf 0
|
tput setaf 9
|
||||||
packages=(gcc wget nginx libsqlite3x-devel.x86_64 postgresql-server postgresql-devel postgresql-contrib bzip2-devel zlib-devel libffi-devel openssl-devel policycoreutils-python.x86_64)
|
packages=(gcc wget nginx libsqlite3x-devel.x86_64 postgresql-server postgresql-devel postgresql-contrib bzip2-devel zlib-devel libffi-devel openssl-devel policycoreutils-python.x86_64)
|
||||||
for package in ${packages[@]};
|
for package in ${packages[@]};
|
||||||
do
|
do
|
||||||
@@ -41,4 +41,4 @@ do
|
|||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo -e "\tyum failed to remove $package."
|
echo -e "\tyum failed to remove $package."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user