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