Index

joshstock.in / 9764b4c

Source for serving and static templating/compiling of https://joshstock.in.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
7521 Jan 2020 21:05baaa825Move copynginx script to nginx/copynginxJosh Stockin1450N

Blob @ joshstock.in / nginx / copynginx

text/x-shellscript939 bytesdownload raw
1#!/usr/bin/env bash
2
3SCRIPTPATH=$(dirname $(realpath -s $0))
4
5usage() {
6 echo "usage: sudo ./copynginx [prod | test]"
7 exit 1
8}
9if [ "$EUID" -ne 0 ]; then
10 echo "error: must run as root"
11 usage
12fi
13if [ $# -eq 0 ]; then
14 usage
15fi
16if [ "$1" != "prod" ] && [ "$1" != "test" ]; then
17 usage
18fi
19
20if [ ! -f $SCRIPTPATH/nginx.conf ]; then
21 echo "error: $SCRIPTPATH/nginx.conf is nonexistent"
22 exit 1
23fi
24echo -e "copying nginx.conf"
25cp -v $SCRIPTPATH/nginx.conf /etc/nginx/nginx.conf
26
27if [ -d /etc/nginx/joshstock.in/ ]; then
28 echo -e "clearing /etc/nginx/joshstock.in/"
29 rm -rv /etc/nginx/joshstock.in/*
30else
31 echo -e "create new /etc/nginx/joshstock.in/"
32 mkdir -pv /etc/nginx/joshstock.in/
33fi
34
35if [ ! -d $SCRIPTPATH/$1 ]; then
36 echo -e "error: $SCRIPTPATH/$1 is nonexistent"
37 exit 1
38fi
39echo -e "copying $1 configuration"
40cp -rv $SCRIPTPATH/$1/* /etc/nginx/joshstock.in/
41
42echo -e "attempting to reload nginx"
43service nginx reload
44
45echo -e "done"
46