-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·60 lines (50 loc) · 1.47 KB
/
run.sh
File metadata and controls
executable file
·60 lines (50 loc) · 1.47 KB
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
#!/bin/sh
certKey="client.cert client.key server.cert server.key server.crl ca.cert
ca.key"
pkiPath="/usr/share/taskd/pki"
taskdCmd="/usr/bin/taskd"
: ${cn:="localhost"}
: ${data:="/var/lib/taskd"}
: ${ip:="127.0.0.1"}
: ${log:="/var/log/taskd.log"}
: ${pid:="/var/run/taskd.pid"}
: ${port:="53589"}
_generateCertKey () {
cd ${pkiPath}
sed -i "s@^CN=.*@CN=${cn}@g" vars
./generate
}
_certConfig () {
for ck in ${certKey}; do
${taskdCmd} config ${ck} ${pkiPath}/${ck}.pem --data ${data}
done
}
if [ ! -f ${data}/config ]; then
${taskdCmd} init --data ${data}
${taskdCmd} config log ${log} --data ${data}
${taskdCmd} config pid.file ${pid} --data ${data}
${taskdCmd} config server ${ip}:${port} --data ${data}
_generateCertKey
_certConfig
else
if ! grep -Fxq "log=${log}" ${data}/config; then
${taskdCmd} config log ${log} --data ${data}
fi
if ! grep -Fxq "pid.file=${pid}" ${data}/config; then
${taskdCmd} config pid.file ${pid} --data ${data}
fi
if ! grep -Fxq "server=${ip}:${port}" ${data}/config; then
${taskdCmd} config server ${ip}:${port} --data ${data}
fi
if ! grep -Fxq "CN=${cn}" ${pkiPath}/vars; then
sed -i "s@^CN=.*@CN=${cn}@g" ${pkiPath}/vars
fi
for file in ${certKey}; do
if [ ! -f ${pkiPath}/${file}.pem ]; then
_generateCertKey
_certConfig
break
fi
done
fi
${taskdCmd} server --data ${data}