Merge pull request #52 from jtanx/master
[matches/MCTX3420.git] / server-configs / install.sh
1 #!/bin/bash
2
3 # Check running as root
4 if [ "$(whoami)" != "root" ]; then
5         (echo "Run $0 as root.") 1>&2
6         exit 1
7 fi
8
9 nconf=/usr/share/nginx/conf
10 # Generate the ssl cert, if necessary
11 if [ ! -d "$nconf" ]; then
12         echo "ssl cert not found at $nconf, generating..."
13         ./gen_ssl_cert.sh $1
14         if [[ $? != 0 ]] ; then
15                 (echo "gen_ssl_cert failed, exiting.") 1>&2
16                 exit 1
17         fi;
18 fi
19
20 nginx=/etc/nginx
21 # Check for nginx
22 if [ ! -d "$nginx" ]; then
23         (echo "Install nginx.") 1>&2
24         exit 1
25 fi
26
27 # Copy nginx configs
28 echo
29 echo "Copying nginx configs..."
30 cp -v nginx/fastcgi_params ./nginx/mime.types $nginx/
31 rm -fv $nginx/sites-enabled/*
32 cp -v nginx/sites-enabled/mctxconfig $nginx/sites-enabled
33
34 echo
35 echo "Restarting nginx..."
36 /etc/init.d/nginx restart
37
38 echo
39 echo "Note: Check the document root for the nginx config is set correctly."
40
41 # Copy syslog configs
42 rsyslog=/etc/rsyslog.d
43 lrotate=/etc/logrotate.d
44 if [ -d "$rsyslog" ]; then
45         echo
46         echo "Copying rsyslog configs..."
47         cp -v rsyslog.d/30-mctxserv.conf $rsyslog/
48
49         echo
50         echo "Restarting rsyslog..."
51         /etc/init.d/rsyslog restart
52 else
53         echo
54         (echo "Could not find rsyslog at $rsyslog. Skipping.") 1>&2
55 fi
56
57 if [ -d "$lrotate" ]; then
58         echo
59         echo "Copying logrotate configs..."
60         cp -v logrotate.d/mctxserv.conf $lrotate/
61 else
62         echo
63         (echo "Could not find logrotate at $lrotate. Skipping.") 1>&2
64 fi
65
66

UCC git Repository :: git.ucc.asn.au