-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·48 lines (39 loc) · 1.65 KB
/
install.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
#!/bin/bash
# Make sure only root can run our script
if [[ "$(id -u)" -ne 0 ]]
then
echo "This script must be run as root" 1>&2
exit 1
fi
copy_files()
{
LETSENCRYPT_PATH=${1:-/apps/letsencrypt}
\curl -sSL https://raw.githubusercontent.com/sleede/letsencrypt/master/etc/systemd/system/letsencrypt_renew.service > "/etc/systemd/system/letsencrypt_renew.service"
\curl -sSL https://raw.githubusercontent.com/sleede/letsencrypt/master/etc/systemd/system/letsencrypt.timer > "/etc/systemd/system/letsencrypt.timer"
\curl -sSL https://raw.githubusercontent.com/sleede/letsencrypt/master/etc/systemd/system/[email protected] > "/etc/systemd/system/[email protected]"
mkdir -p "$LETSENCRYPT_PATH/etc/config/"
mkdir -p "$LETSENCRYPT_PATH/etc/webrootauth/"
\curl -sSL https://raw.githubusercontent.com/sleede/letsencrypt/master/apps/letsencrypt/etc/config/webroot.ini > "$LETSENCRYPT_PATH/etc/config/webroot.ini"
\curl -sSL https://raw.githubusercontent.com/sleede/letsencrypt/master/apps/letsencrypt/commands.sh > "$LETSENCRYPT_PATH/commands.sh"
}
configure()
{
printf "\n\nLet's encrypt requires an email address to receive notifications about certificate expiration.\n"
read -rp "Email address > " email </dev/tty
sed -i.bak "s/EMAIL_REPLACE/$email/g" "$LETSENCRYPT_PATH/etc/config/webroot.ini"
rm "$LETSENCRYPT_PATH/etc/config/webroot.ini.bak"
}
install_commands()
{
systemctl daemon-reload
systemctl enable letsencrypt.timer
echo "[[ -s \"$LETSENCRYPT_PATH/commands.sh\" ]] && source \"$LETSENCRYPT_PATH/commands.sh\"" | tee -a "$HOME/.bashrc"
source "$HOME/.bashrc"
}
setup()
{
copy_files
configure
install_commands
}
setup "$@"