Skip to content

Instantly share code, notes, and snippets.

@hdoverobinson
Last active October 21, 2018 17:59
Show Gist options
  • Save hdoverobinson/82831e1a2d142d92408efd64152a4313 to your computer and use it in GitHub Desktop.
Save hdoverobinson/82831e1a2d142d92408efd64152a4313 to your computer and use it in GitHub Desktop.
Installs NTP on Debian/Ubuntu without prompt for deletion of /usr/src/ntp
#!/bin/bash
###Installs a minimal NTP on Debian/Ubuntu with ACTS, PPS, and NMEA clock drivers and disables timesync.d###
###Installs useful packages for working with PPS and i2c clocks###
NTPVERSION_MAJOR="4.2"
NTPVERSION_MINOR="8p12"
ADDPACKAGES="adjtimex i2c-tools pps-tools"
COREPACKAGES="ntp"
NTPURL="https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p12.tar.gz"
###INSTALL NTP PACKAGES###
sed -i 's/.*deb-src/deb-src/g' /etc/apt/sources.list &&
apt-get -y update &&
apt-get -y install $ADDPACKAGES $COREPACKAGES &&
apt-get -y build-dep $COREPACKAGES &&
###COMPILE AND INSTALL NTP###
systemctl stop systemd-timesyncd &&
systemctl disable systemd-timesyncd &&
rm -rf /usr/src/ntp/ &&
mkdir -p /usr/src/ntp/ &&
cd /usr/src/ntp/ &&
wget $NTPURL &&
tar -xzvf ntp-${NTPVERSION_MAJOR}.${NTPVERSION_MINOR}.tar.gz &&
cd ntp-${NTPVERSION_MAJOR}.${NTPVERSION_MINOR}/ &&
#enable 128MB memlock with only ACTS, NMEA, and PPS clocks and run as non-root user
./configure --prefix=/usr --disable-all-clocks --disable-parse-clocks --enable-linuxcaps --enable-ACTS --enable-ATOM --enable-NMEA --with-memlock=128 &&
make -j4 &&
make -j4 install &&
/etc/init.d/ntp stop &&
usermod -g dialout ntp &&
/etc/init.d/ntp start &&
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment