update README

This commit is contained in:
ducoterra
2018-09-16 22:29:26 -04:00
parent 3d2c761aa4
commit 4e96fac5c6
4 changed files with 201 additions and 133 deletions

View File

@@ -22,91 +22,27 @@ if [ $install_epel_release=True ] ; then
fi
# install dependencies
echo -e "\tInstalling gcc"
yum -y install gcc 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install gcc. $yumlogmsg"
exit 1
fi
echo -e "\tInstalling wget"
yum -y install wget 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install a wget. $yumlogmsg"
exit 1
fi
echo -e "\tInstalling nginx"
yum -y install nginx 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install nginx. $yumlogmsg"
exit 1
fi
echo -e "\tInstalling libsqlite3x-devel.x86_64"
yum -y install libsqlite3x-devel.x86_64 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install libsqlite3x-devel.x86_64 . $yumlogmsg"
exit 1
fi
echo -e "\tInstalling postgresql-server"
yum -y install postgresql-server 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install postgresql-server. $yumlogmsg"
exit 1
fi
echo -e "\tInstalling postgresql-devel"
yum -y install postgresql-devel 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install postgresql-devel. $yumlogmsg"
exit 1
fi
echo -e "\tInstalling postgresql-contrib"
yum -y install postgresql-contrib 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install postgresql-contrib. $yumlogmsg"
exit 1
fi
echo -e "\tInstalling bzip2-devel"
yum -y install bzip2-devel 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install bzip2-devel. $yumlogmsg"
exit 1
fi
echo -e "\tInstalling zlib-devel"
yum -y install zlib-devel 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install zlib-devel. $yumlogmsg"
exit 1
fi
echo -e "\tInstalling ibffi-devel"
yum -y install libffi-devel 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install libffi-devel. $yumlogmsg"
exit 1
fi
echo -e "\tInstalling openssl-devel"
yum -y install openssl-devel 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install openssl-devel. $yumlogmsg"
exit 1
fi
echo -e "\tInstalling policycoreutils-python.x86_64"
yum -y install policycoreutils-python.x86_64 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install policycoreutils-python.x86_64. $yumlogmsg"
exit 1
fi
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[@]};
do
echo -e "\tInstalling $package"
yum -y install $package 1>> $yumlogloc 2>> $yumlogloc 3>> $yumlogloc
if [ $? -ne 0 ] ; then
echo -e "yum failed to install $package. $yumlogmsg"
exit 1
fi
done
# set firewall
echo -e "firewall-cmd --zone=public --add-port=80/tcp --permanent" > $firelogloc
firewall-cmd --zone=public --add-port=80/tcp --permanent 1>> $firelogloc 2>> $firelogloc
if [ $? -ne 0 ] ; then
echo -e "\tfirewall 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 1>> $firelogloc 2>> $firelogloc
if [ $? -ne 0 ] ; then
echo -e "\tfirewall failed to update port 443 correctly, (this may not be an issue). $firelogmsg"
fi
ports=(80 443)
for port in ${ports[@]};
do
echo -e "firewall-cmd --zone=public --add-port=$port/tcp --permanent" > $firelogloc
firewall-cmd --zone=public --add-port=$port/tcp --permanent 1>> $firelogloc 2>> $firelogloc
if [ $? -ne 0 ] ; then
echo -e "\tfirewall failed to update port $port correctly (this may not be an issue). $firelogmsg"
fi
done
echo -e "firewall-cmd --reload" >> $firelogloc
firewall-cmd --reload 1>> $firelogloc 2>> $firelogloc
@@ -128,6 +64,8 @@ fi
tput setaf 2
echo -e "Installing Python"
tput setaf 0
# fetch Python
wget $pylink 1> $pylogloc 2>> $pylogloc
if [ $? -ne 0 ] ; then
echo -e "Failed to fetch python, make sure wget is installed and $pylink is what you're after. $pylogmsg"
@@ -143,8 +81,10 @@ if [ $? -ne 0 ] ; then
echo -e "Missing python directory. $pylogmsg"
exit 1
fi
# install Python
echo -e "\tConfigure"
./configure --prefix /usr/src/python37 1>> $pylogloc 2>> $pylogloc
./configure --prefix $pyinstalldir 1>> $pylogloc 2>> $pylogloc
if [ $? -ne 0 ] ; then
echo -e "./configure failed. $pylogmsg"
exit 1
@@ -161,6 +101,8 @@ if [ $? -ne 0 ] ; then
echo -e "make altinstall failed. $pylogmsg"
exit 1
fi
# upgrade pip and install virtualenv
echo -e "\tUpgrading pip"
/usr/src/python37/bin/python3.7 -m pip install --upgrade pip 1>> $pylogloc 2>> $pylogloc
if [ $? -ne 0 ] ; then
@@ -186,7 +128,9 @@ fi
tput setaf 2
echo -e "Starting Django project"
tput setaf 0
echo id -u $user
# check user and create dirs
id -u $user > /dev/null
if [ $? = 0 ]; then
adduser $user
fi
@@ -199,6 +143,8 @@ if [ $? -ne 0 ] ; then
echo -e "Failed to create $projectname directory. $djamsg"
exit 1
fi
# virtual environment
echo -e "\tCreating venv"
cd /home/$user/
/usr/src/python37/bin/python3.7 -m virtualenv $projectname/venv 1>> $djalogloc 2>> $djalogloc
@@ -211,24 +157,20 @@ if [ $? -ne 0 ] ; then
echo -e "Failed to source virtual environment. $djamsg"
exit 1
fi
echo -e "\tInstalling django"
pip install django >> $djalogloc
if [ $? -ne 0 ] ; then
echo -e "Failed to install pip dependencies. $djamsg"
exit 1
fi
echo -e "\tInstalling gunicorn"
pip install gunicorn >> $djalogloc
if [ $? -ne 0 ] ; then
echo -e "Failed to install pip dependencies. $djamsg"
exit 1
fi
echo -e "\tInstalling psycopg2-binary"
pip install psycopg2-binary >> $djalogloc
if [ $? -ne 0 ] ; then
echo -e "Failed to install pip dependencies. $djamsg"
exit 1
fi
# pip installs
pips=(django gunicorn psycopg2-binary)
for pip in ${pips[@]};
do
echo -e "\tInstalling $pip"
pip install $pip >> $djalogloc
if [ $? -ne 0 ] ; then
echo -e "Failed to install $pip. $djamsg"
exit 1
fi
done
# start django project
echo -e "\tStarting django project"
cd $projectname
django-admin startproject $projectname >> $djalogloc
@@ -236,6 +178,8 @@ if [ $? -ne 0 ] ; then
echo -e "Failed to start project $projectname with django-admin. $djamsg"
exit 1
fi
# update allowed hosts
cd /home/$user/
echo -e "echo -e sed -i 's/ALLOWED_HOSTS = []/ALLOWED_HOSTS = [\"$hostname\"]/' $projectname/$projectname/$projectname/settings.py" >> $djalogloc
sed -i "s/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = \[\"$hostname\"\]/" $projectname/$projectname/$projectname/settings.py
@@ -249,6 +193,8 @@ if [ $? -ne 0 ] ; then
echo -e "Failed to append STATIC_ROOT. $djamsg"
exit 1
fi
# collect static, migrate
echo -e "\tCollecting static"
python $projectname/$projectname/manage.py collectstatic >> $djalogloc
if [ $? -ne 0 ] ; then
@@ -328,7 +274,7 @@ server {
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_pass http://unix:/home/$user/$projectname/$projectname.sock;
}
}" > /etc/nginx/conf.d/mysite.conf
}" > /etc/nginx/conf.d/$projectname.conf
# set the nginx user
if [ ! $user = "nginx" ] ; then
sed -i "s/user nginx/user $user nginx/" /etc/nginx/nginx.conf