1 | #!/usr/bin/env bash |
2 |
|
3 | SCRIPTPATH=$(dirname $(realpath -s $0)) |
4 |
|
5 | usage() { |
6 | echo "usage: sudo ./copynginx [prod | test]" |
7 | exit 1 |
8 | } |
9 | if [ "$EUID" -ne 0 ]; then |
10 | echo "error: must run as root" |
11 | usage |
12 | fi |
13 | if [ $# -eq 0 ]; then |
14 | usage |
15 | fi |
16 | if [ "$1" != "prod" ] && [ "$1" != "test" ]; then |
17 | usage |
18 | fi |
19 |
|
20 | echo -e "copying nginx.conf" |
21 | cp -v $SCRIPTPATH/nginx/nginx.conf /etc/nginx/nginx.conf |
22 | echo -e "\nclearing /etc/nginx/joshstock.in/" |
23 | rm -rv /etc/nginx/joshstock.in/ |
24 | echo -e "\ncreate new /etc/nginx/joshstock.in/" |
25 | mkdir -pv /etc/nginx/joshstock.in/ |
26 | echo -e "\ncopying $1 configuration" |
27 | cp -rv $SCRIPTPATH/nginx/$1/* /etc/nginx/joshstock.in/ |
28 | echo -e "\nattempting to reload nginx" |
29 | service nginx reload |
30 | echo -e "\ndone" |
31 |
|