-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathntp_verify.sh
More file actions
executable file
·31 lines (26 loc) · 905 Bytes
/
ntp_verify.sh
File metadata and controls
executable file
·31 lines (26 loc) · 905 Bytes
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
#!/bin/bash
if [ -z "$(service ntp status | grep -w active)" ]; then
echo 'NOTICE: ntp is not running'
service ntp start
fi
if [ ! -f "/etc/ntp.conf" ] && [ ! -f "/etc/ntp.conf.bak" ]; then
echo 'NOTICE: ups...restore ntp service'
apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall ntp >> /dev/null 2>&1
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
bash "${SCRIPT_DIR}/ntp_deploy.sh"
exit $?
fi
if [ ! -f "/etc/ntp.conf.bak" ]; then
cp /etc/ntp.conf /etc/ntp.conf.bak
echo 'NOTICE: bak file restore'
fi
if [ ! -f "/etc/ntp.conf" ]; then
cp /etc/ntp.conf.bak /etc/ntp.conf
echo 'NOTICE: conf file restore'
fi
if [ -n "$(diff /etc/ntp.conf.bak /etc/ntp.conf)" ]; then
echo 'NOTICE: /etc/ntp.conf was changed. Calculated diff:'
diff -U0 /etc/ntp.conf.bak /etc/ntp.conf
cp /etc/ntp.conf.bak /etc/ntp.conf
service ntp restart
fi