#!/bin/sh :<<'########################################################################' Usage: make_chrony.sh This script downloads and constructs the chrony extension. See ------------------------------------------------------------------------ Change-log: 2011-10-09 First version. ------------------------------------------------------------------------ This script was written in 2011 by vitex from forum.tinycorelinux.net. To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. See http://creativecommons.org/publicdomain/zero/1.0/ for a copy of the CC0 Public Domain Dedication under which this work is distributed. ######################################################################## # Specify the name of the extension. EXTENSION=chrony # Specify the base portion of the extension. EXTENSION0=chrony #----------------------------------------------------------------------- # Install the extensions needed to build this extension. tce-load -wi compiletc.tcz groff.tcz #----------------------------------------------------------------------- # Specify the temporary directory that will contain the build components. TMP=/tmp/tcz # Specify the directory in which the squashfs files will be assembled. SQUASHFS=$TMP/squashfs # Specify the directory in which the submission package will be assembled. PACKAGE=$TMP/package #----------------------------------------------------------------------- # Specify the location containing the software distribution. VERSION=1.26 DOWNLOAD=http://download.tuxfamily.org/chrony/chrony-$VERSION.tar.gz #----------------------------------------------------------------------- # Download if necessary. tar tzf $TMP/$(basename $DOWNLOAD) 1>/dev/null 2>&1 || wget -O- $DOWNLOAD >$TMP/$(basename $DOWNLOAD) #----------------------------------------------------------------------- # Save the download for GPL compliance. cp $TMP/$(basename $DOWNLOAD) $PACKAGE #----------------------------------------------------------------------- # Compute the name of the directory into which the software will be unpacked. DIRECTORY=$TMP/$EXTENSION0-$VERSION #----------------------------------------------------------------------- # Unpack the software. rm -fR $DIRECTORY tar xzf $TMP/$(basename $DOWNLOAD) -C $TMP #----------------------------------------------------------------------- export CFLAGS="-march=i486 -mtune=i686 -Os -pipe" export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe" export LDFLAGS="-Wl,-O1" #----------------------------------------------------------------------- # Build the software. { cd $DIRECTORY ; ./configure ; make ; touch $TMP/TIMESTAMP ; sudo make install ; } #----------------------------------------------------------------------- # Copy the installed files (those newer than $TMP/TIMESTAMP) from # /usr/local to $SQUASHFS/usr/local. ( cd / find usr/local -not -type d -newer $TMP/TIMESTAMP | grep -v /man/ | grep -v /doc/ | cpio -pvd $SQUASHFS ) #----------------------------------------------------------------------- # Make a default configuration file. mkdir -p $SQUASHFS/usr/local/etc/$EXTENSION cat >$SQUASHFS/usr/local/etc/$EXTENSION/$EXTENSION.conf.sample <$SQUASHFS/usr/local/etc/$EXTENSION/$EXTENSION.keys.sample <$SQUASHFS/usr/local/etc/init.d/$EXTENSION <<'EOF' #!/bin/sh # chrony start script [ $(id -u) = 0 ] || { echo "must be root" ; exit 1; } start(){ /usr/local/sbin/chronyd -f /usr/local/etc/chrony/chrony.conf } stop(){ kill $(pidof chronyd) } restart(){ pidof chronyd >/dev/null && stop start } case $1 in start) start ;; stop) stop ;; restart) restart ;; *) echo "Usage $0 {start|stop|restart}"; exit 1 esac EOF chmod +x $SQUASHFS/usr/local/etc/init.d/$EXTENSION #----------------------------------------------------------------------- # Create an initialization script that creates default configuration # files if the user has not supplied them and then start a background # to activate chrony once DNS is available. mkdir -p $SQUASHFS/usr/local/tce.installed cat >$SQUASHFS/usr/local/tce.installed/$EXTENSION </dev/null 2>&1 ; do sleep 1 ; done ; sleep 2 /usr/local/sbin/chronyd -f /usr/local/etc/chrony/chrony.conf sleep 10 ; echo -e 'password mc\nburst 5/10\nquit\n' | chronyc )& EOF sudo chmod +x $SQUASHFS/usr/local/tce.installed/$EXTENSION #----------------------------------------------------------------------- # Create $EXTENSION.tcz.dep. ( echo readline.tcz ; echo libcap.tcz ) >$PACKAGE/$EXTENSION.tcz.dep #----------------------------------------------------------------------- # Create $EXTENSION.tcz.info. cat >$PACKAGE/$EXTENSION.tcz.info <