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 "写入完成"

 

posted @ 2020-10-28 13:53  WH·xiao  阅读(212)  评论(0编辑  收藏  举报