update READEME

This commit is contained in:
ducoterra
2018-09-28 21:33:48 -04:00
parent d996b0ff94
commit 95a03394b2
2 changed files with 32 additions and 54 deletions

View File

@@ -15,20 +15,23 @@ export gitkey="" <-- put the path to the ssh key git will use here
```
```bash
sudo ./install.sh
sudo -s <-- you must be root to run script
./install.sh
```
## Reset
If anything goes wrong with the project and you don't want to perform a full uninstall:
```bash
sudo ./reset
sudo -s
./reset
```
will reset the project but leave the dependencies installed. You can rerun the installer with different variables to fix what was incorrect. WARNING: This will delete your project (including your database)
## Uninstall
To completely remove every trace of the project from your server:
```bash
sudo ./uninstall
sudo -s
./uninstall
```
This will completely remove everything.
@@ -37,18 +40,15 @@ This will completely remove everything.
### vars
```bash
# Django project settings
user="centos"
projectname="mysite"
hostname="centos.duco.net"
user=""
projectname=""
hostname=""
letsencrypt=False
# set True if CentOS minimal install
install_epel_release=False
# general install settings
logdir="/var/log/djangosetup/"
yumlogloc=$logdir"yum.log"
yumlogmsg="See $yumlogloc for more info."
aptlogloc=$logdir"apt.log"
aptlogmsg="See $aptlogloc for more info."
firelogloc=$logdir"firewall.log"
firelogmsg="See $firelogloc for more info."
pylogloc=$logdir"python.log"
@@ -72,15 +72,11 @@ My recommendation is to use nginx as the user. The installer takes care of creat
The projectname variable can be whatever you want. When Django starts the project it will use this name.
The hostname will be inserted into "ALLOWED_HOSTS" in your app settings. Multiple hosts are not supported at the moment so set this to the address you'll test with. You can add additional hosts by manually editing ```settings.py```.
```install_epel_release=True```
If you are installing this on a system with the minimal CentOS build you'll need install_epel_release to be True. ```epel_release``` installs nginx. Kinda hard to run the site without that.
The hostname will be added as an environment variable for gunicorn. Multiple hosts are not supported at the moment so set this to the address you'll test with. You can add additional hosts by manually editing ```settings.py```.
## Install
### Dependencies
In order for this script to work its magic you'll need a few packages provided by Yum. This part is likely to break due to Yum's inconsistency accross distributions, firewall and proxy configurations, and whether CentOS had its morning coffee.
In order for this script to work its magic you'll need a few packages provided by apt.
```bash
# check if root
@@ -97,61 +93,43 @@ tput setaf 0
if [ ! -d $logdir ] ; then
mkdir $logdir
fi
if [ $install_epel_release = True ] ; then
yum -y install epel-release 1>> $yumlogloc 2>> $yumlogloc 3>> $pylogloc
fi
```
The first part of the script is fairly straight forward. If you aren't root user, the installer can't use yum and won't work. After checking if you are the root user it creates the necessary directories to prevent future complaints and installs the aforementioned epel-release package if you want it.
The first part of the script is fairly straight forward. If you aren't root user, the installer can't use apt and won't work. After checking if you are the root user it creates the necessary directories to prevent future complaints.
```bash
# install dependencies
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 ufw make sqlite3 bzip2 openssl libffi-dev libssl-dev libsqlite3-dev zlib1g-dev libbz2-dev)
for package in ${packages[@]};
do
echo -e "\tInstalling $package"
yum -y install $package 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
touch $aptlogloc
apt install -y $package 1>> $aptlogloc 2>> $aptlogloc 3>> $aptlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install $package. $yumlogmsg"
echo -e "apt failed to install $package. $aptlogmsg"
exit 1
fi
done
```
The next part of the script installs yum dependencies. The script verifies that the installation goes smoothly and exits if an error occurs.
The next part of the script installs apt dependencies. The script verifies that the installation goes smoothly and exits if an error occurs.
### Firewall
```bash
# set firewall
echo -e "firewall-cmd --zone=public --add-port=80/tcp --permanent" > $firelogloc
firewall-cmd --zone=public --add-port=80/tcp --permanent >> $firelogloc
# firewall
ports=(22 80 443)
for port in ${ports[@]};
do
echo -e "ufw allow $port/tcp" > $firelogloc
ufw allow $port/tcp 1>> $firelogloc 2>> $firelogloc
if [ $? -ne 0 ] ; then
echo -e "firewall failed to update port 80 correctly (this may not be an issue). $firelogmsg"
fi
echo -e "firewall-cmd --zone=public --add-port=443/tcp --permanent" >> $firelogloc
firewall-cmd --zone=public --add-port=443/tcp --permanent >> $firelogloc
if [ $? -ne 0 ] ; then
echo -e "firewall failed to update port 443 correctly, (this may not be an issue). $firelogmsg"
fi
echo -e "firewall-cmd --reload" >> $firelogloc
firewall-cmd --reload >> $firelogloc
if [ $? -ne 0 ] ; then
echo -e "firewall failed to reload, (this may not be an issue). $firelogmsg"
fi
echo -e "semanage permissive -a httpd_t" >> $firelogloc
semanage permissive -a httpd_t >> $firelogloc
if [ $? -ne 0 ] ; then
echo -e "semanage failed to set permissive. See $firelogmsg"
echo -e "\tfirewall failed to update port $port correctly. $firelogmsg"
exit 1
fi
done
```
The firewall commands are specific to a CentOS 7 minimal install. You may not need them. The installer doesn't really care if they fail because they aren't mission critical. It'll yell at you and that's about it.
The **semanage** command fixes an issue where the websocket would be inaccessible after an install.
The next part of the script opens the necessary ports through ufw.
### Python
```bash

View File

@@ -37,7 +37,7 @@ rm -rf $pyinstalldir
tput setaf 2
echo "Uninstalling dependencies"
tput setaf 9
packages=(gcc wget nginx ufw make sqlite3 bzip2 zlib1g-dev libffi-dev openssl)
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"