[go: up one dir, main page]

Menu

[r271]: / main / bin / enroll.sh  Maximize  Restore  History

Download this file

61 lines (56 with data), 1.8 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
####################################################################
# #
# enroll.sh #
# #
####################################################################
# #
# This shell script is used to enroll the device with the Server #
####################################################################
OPENSSL_CONF=./openssl.cnf
export OPENSSL_CONF
RANDFILE=./.rnd
export RANDFILE
if [ $# -le 0 ]; then
echo "Usage: <script name> <list of osp server ip addresses>"
exit 127
fi
openssl req -outform PEM -nodes -newkey rsa:512 -md5 -new -out certreq.pem -keyform PEM -keyout pkey.pem
ret_val=$?
export ret_val
echo ""
echo "Error Code returned from openssl command :" $ret_val
if [ "$ret_val" != "0" ]; then
echo "Request Failed"
exit 127
fi
enroll -function getcacert -caurl http://$1:1080/tep > cacert_0.pem
ret_val=$?
export ret_val
echo "[SP: $1]Error Code returned from getcacert command :" $ret_val
if [ "$ret_val" != "0" ]; then
echo "Request Failed"
exit 127
fi
enroll -function request -username trans -password nexus -customer 1000 -device 1000 -cacert cacert_0.pem -certreq certreq.pem -sslurl https://$1:1443/tep > localcert.pem
ret_val=$?
export ret_val
echo "Error Code returned from localcert command :" $ret_val
if [ "$ret_val" != "0" ]; then
echo "Request Failed"
exit 127
fi
i=1
shift
while [ $# -ge 1 ]; do
enroll -function getcacert -caurl http://$1:1080/tep > cacert_$i.pem
ret_val=$?
export ret_val
echo "[SP: $1]Error Code returned from getcacert command :" $ret_val
if [ "$ret_val" != "0" ]; then
echo "Request Failed"
exit 127
fi
i=`expr $i + 1`
shift
done