Index

joshstock.in / 5a74171

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
12413 Oct 2021 20:045a74171Update nginx configurationsJosh Stockin1117G

Blob @ joshstock.in / nginx / copynginx

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