Просмотр исходного кода

Replace ntpdate with systemd's timesyncd

Previously NTP was setup via ntpdate which resulted in a situation on
most systemd installations where NTP was effectively being setup twice
because timesyncd is usually enabled by default. This effectively
renders setting up ntpdate redundant as what it does is already done
by timesyncd. Being that Hestia only supports systemd installations the
most logical resolution is to replace ntpdate with timesyncd setup
during installation. That is what I try to do here.
James Buren 5 лет назад
Родитель
Сommit
34e5797bc5
2 измененных файлов с 9 добавлено и 25 удалено
  1. 5 13
      install/hst-install-debian.sh
  2. 4 12
      install/hst-install-ubuntu.sh

+ 5 - 13
install/hst-install-debian.sh

@@ -41,7 +41,7 @@ if [ "$release" -eq 9 ]; then
         dovecot-pop3d roundcube-core net-tools roundcube-mysql roundcube-plugins
         mariadb-client mariadb-common mariadb-server postgresql
         postgresql-contrib phppgadmin phpmyadmin mc flex whois rssh git idn zip
-        sudo bc ftp lsof ntpdate rrdtool quota e2fslibs bsdutils e2fsprogs curl
+        sudo bc ftp lsof rrdtool quota e2fslibs bsdutils e2fsprogs curl
         imagemagick fail2ban dnsutils bsdmainutils cron hestia hestia-nginx
         hestia-php expect libmail-dkim-perl unrar-free vim-common acl sysstat
         rsyslog ssh setpriv ipset libapache2-mod-ruid2"
@@ -57,7 +57,7 @@ elif [ "$release" -eq 10 ]; then
         clamav-daemon spamassassin dovecot-imapd dovecot-pop3d roundcube-core
         net-tools roundcube-mysql roundcube-plugins mariadb-client
         mariadb-common mariadb-server postgresql postgresql-contrib phpmyadmin
-        phppgadmin mc flex whois git idn zip sudo bc ftp lsof ntpdate rrdtool
+        phppgadmin mc flex whois git idn zip sudo bc ftp lsof rrdtool
         quota e2fslibs bsdutils e2fsprogs curl imagemagick fail2ban dnsutils
         bsdmainutils cron hestia hestia-nginx hestia-php expect
         libmail-dkim-perl unrar-free vim-common acl sysstat rsyslog ssh util-linux
@@ -310,13 +310,6 @@ apt-get -qq update
 # Creating backup directory
 mkdir -p $hst_backups
 
-# Checking ntpdate
-if [ ! -e '/usr/sbin/ntpdate' ]; then
-    echo "[ * ] Installing ntpdate..."
-    apt-get -y install ntpdate >> $LOG
-    check_result $? "Can't install ntpdate"
-fi
-
 # Checking wget
 if [ ! -e '/usr/bin/wget' ]; then
     echo "[ * ] Installing wget..."
@@ -965,10 +958,9 @@ if [ -z "$(grep ^/usr/sbin/nologin /etc/shells)" ]; then
 fi
 
 # Configuring NTP
-echo '#!/bin/sh' > /etc/cron.daily/ntpdate
-echo "$(which ntpdate) -s pool.ntp.org" >> /etc/cron.daily/ntpdate
-chmod 755 /etc/cron.daily/ntpdate
-ntpdate -s pool.ntp.org
+sed -i 's/#NTP=/NTP=pool.ntp.org/' /etc/systemd/timesyncd.conf
+systemctl enable systemd-timesyncd
+systemctl start systemd-timesyncd
 
 # Setup rssh
 if [ ! "$release" -eq 10 ]; then

+ 4 - 12
install/hst-install-ubuntu.sh

@@ -35,7 +35,7 @@ software="apache2 apache2.2-common apache2-suexec-custom apache2-utils
     cron curl dnsutils dovecot-imapd dovecot-pop3d e2fslibs e2fsprogs exim4
     exim4-daemon-heavy expect fail2ban flex ftp git idn imagemagick
     libapache2-mod-fcgid libapache2-mod-php$fpm_v libapache2-mod-rpaf
-    lsof mc mariadb-client mariadb-common mariadb-server nginx ntpdate
+    lsof mc mariadb-client mariadb-common mariadb-server nginx
     php$fpm_v php$fpm_v-cgi php$fpm_v-common php$fpm_v-curl phpmyadmin
     php$fpm_v-mysql php$fpm_v-imap php$fpm_v-ldap php$fpm_v-apcu phppgadmin
     php$fpm_v-pgsql php$fpm_v-zip php$fpm_v-bz2 php$fpm_v-cli php$fpm_v-gd
@@ -292,13 +292,6 @@ apt-get -qq update
 # Creating backup directory
 mkdir -p $hst_backups
 
-# Checking ntpdate
-if [ ! -e '/usr/sbin/ntpdate' ]; then
-    echo "[ * ] Installing ntpdate..."
-    apt-get -y install ntpdate >> $LOG
-    check_result $? "Can't install ntpdate"
-fi
-
 # Checking wget
 if [ ! -e '/usr/bin/wget' ]; then
     echo "[ * ] Installing wget..."
@@ -959,10 +952,9 @@ if [ -z "$(grep nologin /etc/shells)" ]; then
 fi
 
 # Configuring NTP
-echo '#!/bin/sh' > /etc/cron.daily/ntpdate
-echo "$(which ntpdate) -s pool.ntp.org" >> /etc/cron.daily/ntpdate
-chmod 755 /etc/cron.daily/ntpdate
-ntpdate -s pool.ntp.org
+sed -i 's/#NTP=/NTP=pool.ntp.org/' /etc/systemd/timesyncd.conf
+systemctl enable systemd-timesyncd
+systemctl start systemd-timesyncd
 
 # Setup rssh
 if [ "$release" != '20.04' ]; then