-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathletsencrypt-manager.sh
executable file
·64 lines (54 loc) · 1.49 KB
/
letsencrypt-manager.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
#!/bin/bash
le_path='/opt/letsencrypt'
echo '#############################'
echo '### ###'
echo '### Letsencrypt manager ###'
echo '### ###'
echo '#############################'
echo
echo 'What would you like to do:'
echo ' (1) Install letsencrypt'
echo ' (2) Register a domain'
echo ' (3) Renew a domain'
echo
echo -n 'Please choose a number: '
read choice
function title {
echo -e "\e[32m$1"
}
function check_if_letsencrypt_installed {
if [ ! -d $le_path ]; then
echo -e "\n[ERROR] Please install letsencrypt first.\n"
exit 0;
fi
}
function install_letsencrypt {
echo
title 'Updating packages list...'
echo `sudo apt-get update`
title 'Installing git and bc...'
echo `sudo apt-get -y install git bc`
title 'Cloning letsencrypt...'
echo `sudo git clone https://github.com/letsencrypt/letsencrypt $le_path`
}
function register_domain {
check_if_letsencrypt_installed
/opt/letsencrypt/letsencrypt-auto certonly --standalone
}
function renew_domain {
check_if_letsencrypt_installed
echo
echo -n 'Enter your domain: '
read -a app_domain
echo -n 'Path to your application root folder: '
read app_path
$le_path/letsencrypt-auto certonly -a webroot --agree-tos --renew-by-default --webroot-path=$app_path -d ${app_domain[0]} -d ${app_domain[1]}
title 'Done, reload your server'
}
if [ $choice -eq 1 ] ; then
install_letsencrypt
elif [ $choice -eq 2 ] ; then
register_domain
elif [ $choice -eq 3 ] ; then
renew_domain
fi