-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcertbot.sh
More file actions
executable file
·63 lines (52 loc) · 1.17 KB
/
certbot.sh
File metadata and controls
executable file
·63 lines (52 loc) · 1.17 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
61
62
63
#!/bin/bash
function showHelp() {
echo "Available options :"
echo "-f | --file File contains list of domain separated by new line"
echo "-h | --help Show help"
}
while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do case $1 in
-f | --file )
shift; file=$1
;;
-h | --help )
showHelp
exit
;;
* )
echo "Invalid option $1"
showHelp
exit 1
;;
esac; shift; done
if [[ "$1" == '--' ]]; then shift; fi
if [[ -z $file ]]; then
echo "File can't be empty!"
showHelp
exit
fi
if [[ ! -f $file ]]; then
echo "$file doesn't exist"
exit
fi
getArray() {
array=()
counter=1
while IFS= read -r line
do
if [[ $counter == 50 ]]; then
echo 'Maximum domain in 1 certificate is 50!'
exit
fi
array+=("$line")
((counter++))
done < "$1"
}
getArray $file
command="sudo certbot"
for e in "${array[@]}"
do
command+=" -d $e -d *.$e"
done
command+=" --manual --preferred-challenges dns certonly"
# Run the command
echo $command