updating script
This commit is contained in:
68
install.sh
68
install.sh
@@ -1,23 +1,32 @@
|
||||
# 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"
|
||||
djalog="/root/logs/django.log"
|
||||
djamsg="See logs/django.log for more info."
|
||||
projectname="mysite"
|
||||
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.
|
||||
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
|
||||
# Installs Dependencies automatically
|
||||
@@ -33,11 +42,8 @@ cd /root/
|
||||
|
||||
echo "Installing dependencies..."
|
||||
# create necessary dirs
|
||||
if [ ! -d "/root/scripts" ] ; then
|
||||
mkdir scripts
|
||||
fi
|
||||
if [ ! -d "/root/logs" ] ; then
|
||||
mkdir logs
|
||||
if [ ! -d $logdir ] ; then
|
||||
mkdir $logdir
|
||||
fi
|
||||
if [ $install_epel_release = True ] ; then
|
||||
yum -y install epel-release
|
||||
@@ -52,25 +58,25 @@ fi
|
||||
|
||||
# set firewall
|
||||
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
|
||||
echo "firewall failed to update port 80 correctly (this may not be an issue). $firelogmsg"
|
||||
fi
|
||||
|
||||
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
|
||||
echo "firewall failed to update port 443 correctly, (this may not be an issue). $firelogmsg"
|
||||
fi
|
||||
|
||||
echo "firewall-cmd --reload" >> $firelogloc
|
||||
firewall-cmd --reload >> logs/firewall.log
|
||||
firewall-cmd --reload >> $firelogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "firewall failed to reload, (this may not be an issue). $firelogmsg"
|
||||
fi
|
||||
|
||||
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
|
||||
echo "semanage failed to set permissive. See $firelogmsg"
|
||||
exit 1
|
||||
@@ -83,7 +89,7 @@ echo "Done."
|
||||
# TODO: 1.
|
||||
################################################################################
|
||||
echo "Installing python..."
|
||||
wget $pylink > $pylogloc
|
||||
wget -O - $pylink > $pylogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "Failed to fetch python, make sure wget is installed and $pylink is what you're after. $pylogmsg"
|
||||
exit 1
|
||||
@@ -146,23 +152,23 @@ if [ $? -ne 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
echo "Failed to create virtual environment. $djamsg"
|
||||
exit 1
|
||||
fi
|
||||
source $projectname/venv/bin/activate >> $djalog
|
||||
source $projectname/venv/bin/activate >> $djalogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "Failed to source virtual environment. $djamsg"
|
||||
exit 1
|
||||
fi
|
||||
pip install django gunicorn psycopg2-binary >> $djalog
|
||||
pip install django gunicorn psycopg2-binary >> $djalogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "Failed to install pip dependencies. $djamsg"
|
||||
exit 1
|
||||
fi
|
||||
cd $projectname
|
||||
django-admin startproject $projectname >> $djalog
|
||||
django-admin startproject $projectname >> $djalogloc
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "Failed to start project $projectname with django-admin. $djamsg"
|
||||
exit 1
|
||||
@@ -225,8 +231,8 @@ ExecStart=/home/$user/$projectname/venv/bin/gunicorn --workers 3 --bind unix:/ho
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target" > /etc/systemd/system/gunicorn.service
|
||||
systemctl start gunicorn
|
||||
systemctl status gunicorn
|
||||
systemctl start gunicorn > $gunicornlogloc
|
||||
systemctl status gunicorn >> $gunicornlogloc
|
||||
echo "Done."
|
||||
|
||||
################################################################################
|
||||
@@ -256,7 +262,7 @@ server {
|
||||
if [ ! $user = "nginx" ] ; then
|
||||
sed -i "s/user nginx/user $user nginx/" /etc/nginx/nginx.conf
|
||||
fi
|
||||
systemctl restart nginx
|
||||
systemctl status nginx
|
||||
systemctl restart nginx >> $nginxlogloc
|
||||
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