Create a gist now

Instantly share code, notes, and snippets.

@ytnobody /README.pod
Last active Dec 24, 2015

dtinstall - daemontools installer script

NAME

dtinstall - daemontools install script

VERSION

0.76.3

GET STARTED

How to use ?

 # curl -L http://is.gd/_dtinstall | bash

AUTHOR

ytnobody <ytnobody@gmail.com>

LICENSE

This script is free software. You can redistribute it and/or modify it under the same terms.

#!/bin/sh
#
# dtinstall
# version 0.76.3 by ytnobody <ytnobody@gmail.com>
#
# 2015/12/24 0.76.3
# - Modified to work under docker
# 2014/09/03 0.76.2
# - Added a patch logic for compat to 64bit system
# 2011/06/20 0.76.1
# - Added a logic that searches libc.so.6
#
VERSION=0.76.3
die ()
{
echo ERROR: $* > /dev/stderr
exit
}
if [ -z "$(which patch)" ] ; then
die "patch is not installed!"
fi
echo PROBING GLIBC
if [ -z "$GLIBC_PATH" ] ; then
GLIBC_PATH=$( find / -name libc.so.6 | sed -n 1p )
fi
echo 'GLIBC_PATH = '$GLIBC_PATH
echo VERSION CHECK
GLIBC_VERSION=$( $GLIBC_PATH | perl -le '
my $line = <STDIN>;
my ( $version ) = $line =~ /release version (.*?),/;
my ( $major, $miner, $revision ) = split /\./, $version;
print $major. sprintf( "%03d", $miner ). sprintf( "%03d", $revision );
' )
echo "\t" glibc : $GLIBC_VERSION
if [ $( whoami ) != "root" ] ; then
die It can only root;
fi
mkdir -v /package
cd /package/
wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
tar zxvf daemontools-0.76.tar.gz
cd admin/daemontools-0.76/
if [ $GLIBC_VERSION -ge 2003002 ] ; then
wget http://qmail.org/moni.csi.hu/pub/glibc-2.3.1/daemontools-0.76.errno.patch
patch -p1 < daemontools-0.76.errno.patch
fi
# patch for 64bit os (or under docker)
rootproc=$(ps 1 | sed 1d | awk '{print($5)}')
is_docker=1
if [ "$rootproc" == "/bin/init" ] || [ "$rootproc" == "/sbin/launchd" ] ; then
is_docker=0
fi
if [ ! -z $(uname -i | grep 64) ] || [ $is_docker == 1 ] ; then
cat << EOF > ./compile/conf-cc
gcc -O2 --include /usr/include/errno.h/
This will be used to compile .c files.
EOF
fi
# install
./package/install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment