-
Notifications
You must be signed in to change notification settings - Fork 14
/
setup.sh
executable file
·171 lines (159 loc) · 4.35 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/sh
##########################################################
# setup.sh 20170708 Frank4DD
#
# This script creates the required application structure,
# e.g. creates directories and CA files for WebCert.
#
# Run as root.
##########################################################
WEBCA_HOME=/srv/app/webCA
WEBCA_BASE=/srv/www/webcert
echo "Check for $WEBCA_HOME folder."
if [ -d $WEBCA_HOME ]; then
ls -ld $WEBCA_HOME
echo "$WEBCA_HOME folder exists."
else
echo "Creating $WEBCA_HOME folder..."
mkdir $WEBCA_HOME
chmod 750 $WEBCA_HOME
chgrp www-data $WEBCA_HOME
ls -ld $WEBCA_HOME
fi
echo "Done."
echo
echo "Check for $WEBCA_HOME/private folder."
if [ -d $WEBCA_HOME/private ]; then
ls -ld $WEBCA_HOME/private
echo "$WEBCA_HOME/private folder exists."
else
echo "Creating $WEBCA_HOME/private folder..."
mkdir $WEBCA_HOME/private
chmod 750 $WEBCA_HOME/private
chgrp www-data $WEBCA_HOME/private
ls -ld $WEBCA_HOME/private
fi
echo "Done."
echo
echo "Check for $WEBCA_HOME/private/cakey.pem private key."
if [ -f $WEBCA_HOME/private/cakey.pem ]; then
ls -l $WEBCA_HOME/private/cakey.pem
echo "$WEBCA_HOME/private/cakey.pem private key exists."
else
echo "Creating $WEBCA_HOME/private/cakey.pem private key..."
openssl genrsa -aes256 -out $WEBCA_HOME/private/cakey.pem 4096
chmod 640 $WEBCA_HOME/private/cakey.pem
chgrp www-data $WEBCA_HOME/private/cakey.pem
ls -l $WEBCA_HOME/private/cakey.pem
fi
echo "Done."
echo
echo "Check for $WEBCA_HOME/cacert.pem CA certificate."
if [ -f $WEBCA_HOME/cacert.pem ]; then
ls -l $WEBCA_HOME/cacert.pem
echo "$WEBCA_HOME/cacert.pem CA certificate exists."
else
echo "Creating $WEBCA_HOME/cacert.pem CA certificate..."
openssl req -new -x509 -days 1826 -key $WEBCA_HOME/private/cakey.pem -out $WEBCA_HOME/cacert.pem
chmod 640 $WEBCA_HOME/cacert.pem
chgrp www-data $WEBCA_HOME/cacert.pem
ls -l $WEBCA_HOME/cacert.pem
fi
echo "Done."
echo
echo "Check for $WEBCA_HOME/serial file."
if [ -f $WEBCA_HOME/serial ]; then
ls -l $WEBCA_HOME/serial
echo "$WEBCA_HOME/serial file exists, content:"
cat $WEBCA_HOME/serial
echo OK
else
echo "Creating $WEBCA_HOME/serial..."
echo "00" > $WEBCA_HOME/serial
chmod 660 $WEBCA_HOME/serial
chgrp www-data $WEBCA_HOME/serial
ls -l $WEBCA_HOME/serial
cat $WEBCA_HOME/serial
fi
echo "Done."
echo
echo "Check for $WEBCA_HOME/certs folder."
if [ -d $WEBCA_HOME/certs ]; then
ls -ld $WEBCA_HOME/certs
echo "$WEBCA_HOME/certs folder exists"
echo OK
else
echo "Creating $WEBCA_HOME/certs..."
mkdir $WEBCA_HOME/certs
chmod 770 $WEBCA_HOME/certs
chgrp www-data $WEBCA_HOME/certs
ls -ld $WEBCA_HOME/certs
fi
echo "Done."
echo
echo "Check for $WEBCA_BASE folder."
if [ -d $WEBCA_BASE ]; then
ls -ld $WEBCA_BASE
echo "$WEBCA_BASE folder exists."
else
echo "Creating $WEBCA_BASE folder..."
mkdir $WEBCA_BASE
chmod 750 $WEBCA_BASE
chgrp www-data $WEBCA_BASE
ls -ld $WEBCA_BASE
fi
echo "Done."
echo
echo "Check for $WEBCA_BASE/style folder."
if [ -d $WEBCA_BASE/style ]; then
ls -ld $WEBCA_BASE/style
echo "$WEBCA_BASE/style folder exists."
else
echo "Creating $WEBCA_BASE/style folder..."
mkdir $WEBCA_BASE/style
chmod 750 $WEBCA_BASE/style
chgrp www-data $WEBCA_BASE/style
ls -ld $WEBCA_BASE/style
fi
echo "Done."
echo
echo "Check for $WEBCA_BASE/images folder."
if [ -d $WEBCA_BASE/images ]; then
ls -ld $WEBCA_BASE/images
echo "$WEBCA_BASE/images folder exists."
else
echo "Creating $WEBCA_BASE/images folder..."
mkdir $WEBCA_BASE/images
chmod 750 $WEBCA_BASE/images
chgrp www-data $WEBCA_BASE/images
ls -ld $WEBCA_BASE/images
fi
echo "Done."
echo
echo "Check for $WEBCA_BASE/cgi-bin folder."
if [ -d $WEBCA_BASE/cgi-bin ]; then
ls -ld $WEBCA_BASE/cgi-bin
echo "$WEBCA_BASE/cgi-bin folder exists."
else
echo "Creating $WEBCA_BASE/cgi-bin folder..."
mkdir $WEBCA_BASE/cgi-bin
chmod 750 $WEBCA_BASE/cgi-bin
chgrp www-data $WEBCA_BASE/cgi-bin
ls -ld $WEBCA_BASE/cgi-bin
fi
echo "Done."
echo
echo "Check for $WEBCA_BASE/export folder."
if [ -d $WEBCA_BASE/export ]; then
ls -ld $WEBCA_BASE/export
echo "$WEBCA_BASE/export folder exists"
echo OK
else
echo "Creating $WEBCA_BASE/export..."
mkdir $WEBCA_BASE/export
chmod 770 $WEBCA_BASE/export
chgrp www-data $WEBCA_BASE/export
ls -ld $WEBCA_BASE/export
fi
echo "Done."
echo "End of setup.sh"