-
Notifications
You must be signed in to change notification settings - Fork 0
/
regenerate.expect
executable file
·54 lines (38 loc) · 1.42 KB
/
regenerate.expect
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
#!/usr/bin/expect
# change the following variables to match your setup
# - user_account_public_key -> this is your letsencrypt account's public key
# - certificate_request_csr -> this is your SSL's Certificate Signing Request file.
# - email -> a contact e-mail.
set user_account_public_key user_account.public_key
set certificate_request_csr certificate_request.csr
set email it_sys@mydomain.tld
# how much time should we wait for a response from letsencrypt servers
set timeout 10
# this will hold the 3 first openssl commands
set args {}
# launching the script
spawn python sign_csr.py -p $user_account_public_key $certificate_request_csr -e $email
# capture the three openssl commands
expect -re "openssl (.+?.json)" { lappend args $expect_out(1,string)}
expect -re "openssl (.+?.json)" { lappend args $expect_out(1,string)}
expect -re "openssl (.+?.json)" { lappend args $expect_out(1,string)}
# execute the commands
foreach arg $args {
exec openssl {*}[split $arg]
}
# "Press enter to continue"
send "\r"
# "We need you to sign one more document"
expect -re "openssl (.+?.json)" {
exec openssl {*}[split $expect_out(1,string)]
}
# "Press enter to continue"
send "\r"
# "Run the following python HTTP server on port 80"
expect -re {sudo python -c "(.+?s.serve_forever\(\))"} {
exec ./disableport80
exec python -c $expect_out(1,string) &
}
# "Press enter when you're done"
send "\r"
interact