-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·77 lines (61 loc) · 1.66 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
#Copy default config file if it doesn't exists
mkdir -p /etc/Backup2Azure
if [ ! -f "/etc/Backup2Azure/backup2azure.conf" ]; then
cp backup2azure.conf /etc/Backup2Azure/
fi
#Copy executable script
mkdir -p /opt/Backup2Azure
cp AzUpload.sh /opt/Backup2Azure/AzUpload.sh
#Create backup upload service
cat <<EOF >/etc/systemd/system/backup2azure.timer
[Unit]
Description=Backup2Azure timer
Requires=backup2azure.service
[Timer]
Unit=backup2azure.service
#Every 3 months
#OnCalendar=quarterly
OnCalendar=Mon 02,05,08,11-01..07 00:00:00
[Install]
WantedBy=timers.target
EOF
cat <<EOF >/etc/systemd/system/backup2azure.service
[Unit]
Description=Backup2Azure service
After=network.target
Wants=backup2azure.timer
[Service]
Type=oneshot
EnvironmentFile=/etc/Backup2Azure/backup2azure.conf
ExecStart=bash /opt/Backup2Azure/AzUpload.sh
StandardOutput=truncate:/var/log/backup2azure.log
StandardError=truncate:/var/log/backup2azure.log
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now backup2azure.timer
#Installing keepalive service for login token
cat <<EOF >/etc/systemd/system/azlogin.timer
[Unit]
Description=Azure Login keepalive timer
Requires=azlogin.service
[Timer]
Unit=azlogin.service
OnCalendar=monthly
[Install]
WantedBy=timers.target
EOF
cat <<EOF >/etc/systemd/system/azlogin.service
[Unit]
Description=Azure Login keepalive service
After=network.target
Wants=azlogin.timer
[Service]
Type=oneshot
EnvironmentFile=/etc/Backup2Azure/backup2azure.conf
ExecStart=/bin/bash -c 'az login --service-principal -u \${sp_app_id} -p \${sp_password} --tenant \${sp_tenant_id}'
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now azlogin.timer