-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
47 lines (39 loc) · 1.52 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
#!/usr/bin/env sh
if [ "$(whoami)" != "root" ]; then
echo Script must be run as root
exit 1
fi
# Uninstall old version
[ -e /usr/local/bin/uninstall-pve-cert-copy.sh ] && /usr/local/bin/uninstall-pve-cert-copy.sh
mkdir --parents /etc/systemd/system/pveproxy.service.d
cat << EOF > /usr/local/bin/pve-cert-copy.sh
#!/usr/bin/env sh
[ ! -e /etc/proxmox-backup ] && exit 0
cp --preserve=timestamps /etc/pve/local/pveproxy-ssl.key /etc/proxmox-backup/proxy.key
cp --preserve=timestamps /etc/pve/local/pveproxy-ssl.pem /etc/proxmox-backup/proxy.pem
chmod 640 /etc/proxmox-backup/proxy.key /etc/proxmox-backup/proxy.pem
chgrp backup /etc/proxmox-backup/proxy.key /etc/proxmox-backup/proxy.pem
systemctl reload proxmox-backup-proxy.service
EOF
cat << EOF > /etc/systemd/system/pveproxy.service.d/pve-cert-copy-override.conf
[Service]
ExecReload=-/usr/local/bin/pve-cert-copy.sh
ExecStartPost=-/usr/local/bin/pve-cert-copy.sh
EOF
cat << EOF > /usr/local/bin/uninstall-pve-cert-copy.sh
#!/usr/bin/env sh
if [ "\$(whoami)" != "root" ]; then
echo Script must be run as root
exit 1
fi
rm /etc/systemd/system/pveproxy.service.d/pve-cert-copy-override.conf
[ \$(ls -A /etc/systemd/system/pveproxy.service.d) ] || rmdir /etc/systemd/system/pveproxy.service.d
systemctl daemon-reload 2>/dev/null
rm /usr/local/bin/pve-cert-copy.sh
rm /usr/local/bin/uninstall-pve-cert-copy.sh
EOF
chmod u+x /usr/local/bin/uninstall-pve-cert-copy.sh
chmod u+x /usr/local/bin/pve-cert-copy.sh
systemctl daemon-reload
# Run once after installation
/usr/local/bin/pve-cert-copy.sh