3、判断应用是否安装

#!/bin/bash

if ! [ -x "$(command -v ntpd)" ]; then
  echo 'Error: ntp is not installed.' >&2
  yum install -y ntp
fi

cp /etc/ntp.conf /etc/ntp-bak

echo "写入配置文件"

cat > /etc/ntp.conf << EOF
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
server 134.65.18.2
server 134.65.66.3
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
EOF

echo "写入完成"
原文地址:https://www.cnblogs.com/whxiao/p/13890678.html