#!/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 echo "Starting paste service" systemctl start paste.service echo "Restarting nginx service" systemctl restart nginx echo "Done :)"