Last active
March 5, 2024 18:13
-
-
Save mattrude/9d795f707ce20f6bdab9f2c52ff26e69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "${LOGNAME}" != "root" ]; then | |
echo "This script must be ran by the 'root' user, but was ran by the ${LOGNAME} instead." | |
exit 1 | |
fi | |
UPDATE=0 | |
################################################################################ | |
aptupdate(){ | |
PACKETS="libtomcrypt-dev nettle-dev build-essential libcap-dev bison" | |
dpkg --get-selections |sed 's/:/ /g' |awk '{print $1}' > /tmp/installed-packages.txt | |
INSTALLPACKETS="" | |
for a in $PACKETS | |
do | |
if [ `egrep "^$a$" /tmp/installed-packages.txt |wc -l` != "1" ]; then | |
echo "$a is not installed" | |
INSTALLPACKETS="$a $INSTALLPACKETS" | |
fi | |
done | |
rm -f /tmp/installed-packages.txt | |
if [ "$INSTALLPACKETS" != "" ]; then | |
apt install -y $INSTALLPACKETS | |
fi | |
} | |
if [ ! `getent passwd _chrony |wc -l` -eq 1 ]; then | |
adduser --system --group --comment 'Chrony daemon' --home /var/lib/chrony --quiet _chrony | |
fi | |
################################################################################ | |
if [ -f /var/src/chrony/.git/config ]; then | |
cd /var/src/chrony/ | |
OLDGITID="`git rev-parse HEAD`" | |
NEWGITID="`git rev-parse origin/master`" | |
NEWGITID=`git ls-remote --heads https://gitlab.com/chrony/chrony.git |grep "refs/heads/master" |awk '{ print $1 }'` | |
if [ "${OLDGITID}" != "${NEWGITID}" ]; then | |
git pull -q | |
UPDATE=1 | |
fi | |
else | |
aptupdate | |
mkdir -p /var/src; rm -rf /var/src/chrony | |
git clone -q https://gitlab.com/chrony/chrony.git /var/src/chrony | |
cd /var/src/chrony | |
UPDATE=1 | |
fi | |
if [ ${UPDATE} == 1 ]; then | |
echo -n "`git rev-parse --short HEAD`" > version.txt && \ | |
git log -1 --format="%at" | xargs -I{} date -d @{} +_%Y-%m-%d >> version.txt && \ | |
./configure --prefix=/usr --sysconfdir=/etc/chrony --with-user=_chrony --enable-scfilter && \ | |
sed -i 's/$(MAKE) -C doc install//g' Makefile && make clean && make && make install && \ | |
systemctl restart chronyd.service && echo "Install Complete!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment