Index

joshstock.in / 05d74a2

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
12713 Oct 2021 20:1605d74a2Separate nginx environment settings for prod and testJosh Stockin174G

Blob @ joshstock.in / nginx / copynginx

text/x-shellscript1037 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/conf.d/ ]; then
28 echo -e "clearing /etc/nginx/conf.d/"
29 rm -rv /etc/nginx/conf.d
30fi
31
32if [ -d /etc/nginx/sites-enabled/ ]; then
33 echo -e "clearing /etc/nginx/sites-enabled/"
34 rm -rv /etc/nginx/sites-enabled
35fi
36
37if [ -d /etc/nginx/env/ ]; then
38 echo -e "clearing /etc/nginx/env/"
39 rm -rv /etc/nginx/env
40fi
41
42if [ ! -d $SCRIPTPATH/$1 ]; then
43 echo -e "error: $SCRIPTPATH/$1 is nonexistent"
44 exit 1
45fi
46echo -e "copying $1 configuration"
47cp -rv $SCRIPTPATH/$1/* /etc/nginx
48
49echo -e "attempting to reload nginx"
50service nginx reload
51
52echo -e "done"
53