updating script
This commit is contained in:
68
install.sh
68
install.sh
@@ -1,23 +1,32 @@
|
|||||||
# vars
|
# vars
|
||||||
yumlogloc="/root/logs/yum.log"
|
|
||||||
yumlogmsg="See logs/yum.log for more info."
|
|
||||||
|
|
||||||
firelogloc="/root/logs/firewall.log"
|
|
||||||
firelogmsg="See logs/firewall.log for more info."
|
|
||||||
|
|
||||||
pylogloc="/root/logs/python.log"
|
|
||||||
pylogmsg="See logs/python.log for more info."
|
|
||||||
pylink="https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz"
|
|
||||||
|
|
||||||
user="centos"
|
user="centos"
|
||||||
djalog="/root/logs/django.log"
|
|
||||||
djamsg="See logs/django.log for more info."
|
|
||||||
projectname="mysite"
|
projectname="mysite"
|
||||||
hostname="centos.duco.net"
|
hostname="centos.duco.net"
|
||||||
|
letsencrypt=False
|
||||||
|
pylink="https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz"
|
||||||
|
|
||||||
# if you are doing this on a personal install you will prob need this.
|
# if you are doing this on a personal install you will prob need this.
|
||||||
install_epel_release=False
|
install_epel_release=False
|
||||||
|
|
||||||
|
logdir = "/var/log/djangosetup/"
|
||||||
|
scriptdir = "/root/scripts"
|
||||||
|
|
||||||
|
yumlogloc=$logdir"yum.log"
|
||||||
|
yumlogmsg="See $yumlogloc for more info."
|
||||||
|
|
||||||
|
firelogloc=$logdir"firewall.log"
|
||||||
|
firelogmsg="See $firelogloc for more info."
|
||||||
|
|
||||||
|
pylogloc=$logdir"python.log"
|
||||||
|
pylogmsg="See $pylogloc for more info."
|
||||||
|
|
||||||
|
djalogloc=$logdir"django.log"
|
||||||
|
djamsg="See $djalogloc for more info."
|
||||||
|
|
||||||
|
gunicornlogloc=$logdir"gunicorn.log"
|
||||||
|
|
||||||
|
nginxlogloc=$logdir"nginx.log"
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# Installs Dependencies automatically
|
# Installs Dependencies automatically
|
||||||
@@ -33,11 +42,8 @@ cd /root/
|
|||||||
|
|
||||||
echo "Installing dependencies..."
|
echo "Installing dependencies..."
|
||||||
# create necessary dirs
|
# create necessary dirs
|
||||||
if [ ! -d "/root/scripts" ] ; then
|
if [ ! -d $logdir ] ; then
|
||||||
mkdir scripts
|
mkdir $logdir
|
||||||
fi
|
|
||||||
if [ ! -d "/root/logs" ] ; then
|
|
||||||
mkdir logs
|
|
||||||
fi
|
fi
|
||||||
if [ $install_epel_release = True ] ; then
|
if [ $install_epel_release = True ] ; then
|
||||||
yum -y install epel-release
|
yum -y install epel-release
|
||||||
@@ -52,25 +58,25 @@ fi
|
|||||||
|
|
||||||
# set firewall
|
# set firewall
|
||||||
echo "firewall-cmd --zone=public --add-port=80/tcp --permanent" > $firelogloc
|
echo "firewall-cmd --zone=public --add-port=80/tcp --permanent" > $firelogloc
|
||||||
firewall-cmd --zone=public --add-port=80/tcp --permanent >> logs/firewall.log
|
firewall-cmd --zone=public --add-port=80/tcp --permanent >> $firelogloc
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "firewall failed to update port 80 correctly (this may not be an issue). $firelogmsg"
|
echo "firewall failed to update port 80 correctly (this may not be an issue). $firelogmsg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "firewall-cmd --zone=public --add-port=443/tcp --permanent" >> $firelogloc
|
echo "firewall-cmd --zone=public --add-port=443/tcp --permanent" >> $firelogloc
|
||||||
firewall-cmd --zone=public --add-port=443/tcp --permanent >> logs/firewall.log
|
firewall-cmd --zone=public --add-port=443/tcp --permanent >> $firelogloc
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "firewall failed to update port 443 correctly, (this may not be an issue). $firelogmsg"
|
echo "firewall failed to update port 443 correctly, (this may not be an issue). $firelogmsg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "firewall-cmd --reload" >> $firelogloc
|
echo "firewall-cmd --reload" >> $firelogloc
|
||||||
firewall-cmd --reload >> logs/firewall.log
|
firewall-cmd --reload >> $firelogloc
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "firewall failed to reload, (this may not be an issue). $firelogmsg"
|
echo "firewall failed to reload, (this may not be an issue). $firelogmsg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "semanage permissive -a httpd_t" >> $firelogloc
|
echo "semanage permissive -a httpd_t" >> $firelogloc
|
||||||
semanage permissive -a httpd_t >> logs/firewall.log
|
semanage permissive -a httpd_t >> $firelogloc
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "semanage failed to set permissive. See $firelogmsg"
|
echo "semanage failed to set permissive. See $firelogmsg"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -83,7 +89,7 @@ echo "Done."
|
|||||||
# TODO: 1.
|
# TODO: 1.
|
||||||
################################################################################
|
################################################################################
|
||||||
echo "Installing python..."
|
echo "Installing python..."
|
||||||
wget $pylink > $pylogloc
|
wget -O - $pylink > $pylogloc
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "Failed to fetch python, make sure wget is installed and $pylink is what you're after. $pylogmsg"
|
echo "Failed to fetch python, make sure wget is installed and $pylink is what you're after. $pylogmsg"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -146,23 +152,23 @@ if [ $? -ne 0 ] ; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd /home/$user/
|
cd /home/$user/
|
||||||
/usr/src/python37/bin/python3.7 -m virtualenv $projectname/venv >> $djalog
|
/usr/src/python37/bin/python3.7 -m virtualenv $projectname/venv >> $djaloglo
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "Failed to create virtual environment. $djamsg"
|
echo "Failed to create virtual environment. $djamsg"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
source $projectname/venv/bin/activate >> $djalog
|
source $projectname/venv/bin/activate >> $djalogloc
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "Failed to source virtual environment. $djamsg"
|
echo "Failed to source virtual environment. $djamsg"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
pip install django gunicorn psycopg2-binary >> $djalog
|
pip install django gunicorn psycopg2-binary >> $djalogloc
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "Failed to install pip dependencies. $djamsg"
|
echo "Failed to install pip dependencies. $djamsg"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd $projectname
|
cd $projectname
|
||||||
django-admin startproject $projectname >> $djalog
|
django-admin startproject $projectname >> $djalogloc
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "Failed to start project $projectname with django-admin. $djamsg"
|
echo "Failed to start project $projectname with django-admin. $djamsg"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -225,8 +231,8 @@ ExecStart=/home/$user/$projectname/venv/bin/gunicorn --workers 3 --bind unix:/ho
|
|||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target" > /etc/systemd/system/gunicorn.service
|
WantedBy=multi-user.target" > /etc/systemd/system/gunicorn.service
|
||||||
systemctl start gunicorn
|
systemctl start gunicorn > $gunicornlogloc
|
||||||
systemctl status gunicorn
|
systemctl status gunicorn >> $gunicornlogloc
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -256,7 +262,7 @@ server {
|
|||||||
if [ ! $user = "nginx" ] ; then
|
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
|
||||||
systemctl restart nginx
|
systemctl restart nginx >> $nginxlogloc
|
||||||
systemctl status nginx
|
systemctl status nginx >> $nginxlogloc
|
||||||
|
|
||||||
echo "Done. Logs can be found in /root/logs/"
|
echo "Done. Logs can be found in $logdir"
|
||||||
|
|||||||
Reference in New Issue
Block a user