22 Commits

Author SHA1 Message Date
ducoterra
0e619dd4ef add shebang 2018-12-12 21:54:26 -05:00
ducoterra
2e88de6714 add origin before ssh-agent 2018-12-03 11:52:15 -05:00
ducoterra
6342cbbd89 move git init and git remote add origin to before ssh-agen 2018-12-02 14:12:21 -05:00
ducoterra
34b929130d don't remove project dir 2018-11-25 17:43:04 -05:00
ducoterra
f3b2e4b787 try double quotes 2018-11-25 17:33:51 -05:00
ducoterra
54df19f71a fix string comparison again 2018-11-25 17:26:09 -05:00
ducoterra
ebab968766 fix string comparison 2018-11-25 17:24:51 -05:00
ducoterra
7e37fba048 check if vars filled out 2018-11-25 17:17:37 -05:00
ducoterra
adcf23c73c source vars 2018-11-25 16:44:14 -05:00
ducoterra
c686c1a915 add shebang 2018-11-25 16:39:09 -05:00
ducoterra
72139c9e63 revert changes 2018-11-25 16:38:47 -05:00
ducoterra
86dff989b6 Revert "push apt output to log"
This reverts commit 650002bfe8.
2018-11-25 16:37:33 -05:00
ducoterra
9705f3bc7b adding semi-colons 2018-11-25 16:28:12 -05:00
ducoterra
9a3a4bed6f fix [[ not found 2018-11-25 16:26:15 -05:00
ducoterra
c0ddc4cf1c chmod +x vars 2018-11-25 16:25:40 -05:00
ducoterra
6e907483a2 check root first 2018-11-25 16:21:38 -05:00
ducoterra
1f4081c6ef ./vars 2018-11-25 16:21:08 -05:00
ducoterra
21662b97f2 switch to sudo user 2018-11-25 16:20:08 -05:00
ducoterra
832386ff47 remove rogue character 2018-10-01 09:04:55 -04:00
ducoterra
650002bfe8 push apt output to log 2018-09-30 19:19:40 -04:00
ducoterra
333bf8f3c2 update with psycopg2 package dependency 2018-09-30 19:14:14 -04:00
ducoterra
7784ac5607 remove ufw 2018-09-30 18:18:16 -04:00
5 changed files with 36 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
# Django Setup for Ubuntu 18.04
# Django Setup for Raspbian Jessie
## Install
```bash
vim vars

View File

@@ -1,15 +1,30 @@
#!/bin/bash
################################################################################s
# Dependencies
# Installs Dependencies automatically
################################################################################
# check if root
if [ $EUID -ne 0 ] ; then
echo -e "This script must be run as root"
exit 1
fi
# source vars
source vars
# check if root
if [[ $EUID -ne 0 ]]; then
echo -e "This script must be run as root"
exit 1
if [[ $user == "" ]] ; then
echo -e "User missing from vars."
exit 1
fi
if [[ $projectname == "" ]] ; then
echo -e "Project Name missing from vars."
exit 1
fi
if [[ $hostname == "" ]] ; then
echo -e "Hostname missing from vars."
exit 1
fi
tput setaf 2
@@ -17,11 +32,13 @@ echo -e "Installing dependencies"
tput setaf 9
# create necessary dirs
if [ ! -d $logdir ] ; then
mkdir $logdir
fi
mkdir $logdir
fi;
# install dependencies
packages=(gcc wget nginx ufw make sqlite3 bzip2 openssl libffi-dev libssl-dev libsqlite3-dev zlib1g-dev libbz2-dev)
packages=(gcc wget nginx ufw make sqlite3 bzip2 openssl libffi-dev libssl-dev libsqlite3-dev zlib1g-dev libbz2-dev libpq-dev);
echo -e "\tRunning apt update";
apt update 1> $aptlogloc 2>> $aptlogloc 3>> $aptlogloc;
for package in ${packages[@]};
do
echo -e "\tInstalling $package"
@@ -36,15 +53,15 @@ done
ports=(22 80 443)
for port in ${ports[@]};
do
echo -e "ufw allow $port/tcp" > $firelogloc
echo -e "ufw allow $port/tcp" 1>> $firelogloc 2>> $firelogloc
ufw allow $port/tcp 1>> $firelogloc 2>> $firelogloc
if [ $? -ne 0 ] ; then
echo -e "\tfirewall failed to update port $port correctly. $firelogmsg"
exit 1
fi
done
echo -e "\tenabling ufw"
ufw --force enable
echo -e "\tEnabling ufw"
ufw --force enable 1>> $firelogloc 2>> $firelogloc
################################################################################
# Python
@@ -184,9 +201,9 @@ fi
if [ $usegit = True ] ; then
echo -e "\tCloning django project"
ssh-agent bash -c 'ssh-add $gitkey 1>> $gitlogloc 2>> $gitlogloc 3>> $gitlogloc;
git init 1>> $gitlogloc 2>> $gitlogloc 3>> $gitlogloc;
git remote add origin $giturl 1>> $gitlogloc 2>> $gitlogloc 3>> $gitlogloc;
ssh-agent bash -c 'ssh-add $gitkey 1>> $gitlogloc 2>> $gitlogloc 3>> $gitlogloc;
git pull origin master 1>> $gitlogloc 2>> $gitlogloc 3>> $gitlogloc;'
echo -e "\tInstalling pip requirements"
pip install -r requirements.txt 1>> $gitlogloc 2>> $gitlogloc 3>> $gitlogloc

View File

@@ -1,3 +1,5 @@
#!/bin/bash
################################################################################
# Performs a QUICK uninstall #
# - Does not uninstall dependencies #
@@ -22,9 +24,3 @@ tput setaf 9
systemctl disable gunicorn 1> /dev/null 2> /dev/null
systemctl stop gunicorn 1> /dev/null 2> /dev/null
rm -f /etc/systemd/system/gunicorn.service
# remove project
tput setaf 2
echo "Removing Django project"
tput setaf 9
rm -rf /home/$user/$projectname

View File

@@ -1,3 +1,5 @@
#!/bin/bash
################################################################################
# Performs a FULL uninstall #
################################################################################

2
vars Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/bin/bash
# django project settings
export user=""
export projectname=""