From eafd1d9ae62146d1cb858f7aaab1bdabff51b66d Mon Sep 17 00:00:00 2001 From: benjamyn Date: Wed, 20 Feb 2019 22:34:45 +1100 Subject: [PATCH] Initial commit --- .blank.service | 13 +++++++++++++ blank.service | 13 +++++++++++++ intsall.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ paste.conf | 11 +++++++++++ 4 files changed, 79 insertions(+) create mode 100644 .blank.service create mode 100644 blank.service create mode 100644 intsall.sh create mode 100644 paste.conf diff --git a/.blank.service b/.blank.service new file mode 100644 index 0000000..242c0ab --- /dev/null +++ b/.blank.service @@ -0,0 +1,13 @@ +[Unit] +Description=Gunicorn instance to serve paste +After=network.target + +[Service] +User=UNAME +Group=UGROUP +WorkingDirectory=WORKINGDIR +Environment="PATH=ENVIRONMENT/bin" +ExecStart=ENVIRONMENT/bin/gunicorn --workers 3 --bind unix:paste.sock -m 007 wsgi + +[Install] +WantedBy=multi-user.target diff --git a/blank.service b/blank.service new file mode 100644 index 0000000..242c0ab --- /dev/null +++ b/blank.service @@ -0,0 +1,13 @@ +[Unit] +Description=Gunicorn instance to serve paste +After=network.target + +[Service] +User=UNAME +Group=UGROUP +WorkingDirectory=WORKINGDIR +Environment="PATH=ENVIRONMENT/bin" +ExecStart=ENVIRONMENT/bin/gunicorn --workers 3 --bind unix:paste.sock -m 007 wsgi + +[Install] +WantedBy=multi-user.target diff --git a/intsall.sh b/intsall.sh new file mode 100644 index 0000000..fc4fb03 --- /dev/null +++ b/intsall.sh @@ -0,0 +1,42 @@ +#!/bin/bash +#if [[ $EUID -ne 0 ]]; then +# echo "This script must be run as root" +# exit 1 +#fi +CURRENTDIR=`pwd` +ENVDIR=$CURRENTDIR"/env" +WORKINGDIR=$CURRENTDIR"/paste" +USERNAME=paste +NGINXGROUP=nginx +REPO="https://git.vps.benjamyn-testing.com/benjamyn/paste.git" +PROTOCOL='https://' +URL=testing.int.local + +echo "Getting the repo from $REPO" +git clone $REPO + +echo "Making changes :)" +echo "Editing URL" +sed -i s+PREURL+$URL+g paste/paste.py paste/templates/post.html paste.conf +sed -i s+PREPROTO+$PROTOCOL+g paste/paste.py paste/templates/post.html +echo "Done :)" + +echo "Creating the service file" + +sed -i s+UNAME+$USERNAME+g blank.service +sed -i s+UGROUP+$NGINXGROUP+g blank.service +sed -i s+WORKINGDIR+"$WORKINGDIR"+g blank.service paste.conf +sed -i s+ENVIRONMENT+"$ENVDIR"+g blank.service + +echo "Setting up the virtualenv" +virtualenv env +$ENVDIR/bin/pip install flask gunicorn + +echo "Installing the service" +cp blank.service /etc/systemd/system/paste.service + +echo "Setting permissions on the files" +chmod -R $USERNAME:$NGINXGROUP $CURRENTDIR + +echo "Installing nginx config to /etc/nginx/conf.d" +cp paste.conf /etc/nginx/conf.d/paste.conf \ No newline at end of file diff --git a/paste.conf b/paste.conf new file mode 100644 index 0000000..a89f16c --- /dev/null +++ b/paste.conf @@ -0,0 +1,11 @@ +server { + listen 80; + server_name PREURL; + location / { + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://unix:/home/ben/scripts/paste/paste/paste.sock; + } +} \ No newline at end of file