Skip to content

Instantly share code, notes, and snippets.

@ywatase
Created March 3, 2016 04:19
Show Gist options
  • Save ywatase/38e366b2c82cce852508 to your computer and use it in GitHub Desktop.
Save ywatase/38e366b2c82cce852508 to your computer and use it in GitHub Desktop.
#!/bin/sh
# install & set up daemontools and so on.
#
# Author : Y.Watase
# Date : 2007/01/11
# Last Modified: 2016/03/03.
# Mail : [email protected]
################################################################################
# setting
################################################################################
INSTALL_DAEMONTOOLS=y
INSTALL_UCSPI_TCP=y
SRC_DIR=/usr/local/src
DAEMONTOOLS_DIR=/package
################################################################################
# software version
################################################################################
# {{{
VERSION_DAEMONTOOLS=0.76
VERSION_UCSPI_TCP=0.88
URL_DJBMAN='http://smarden.org/pape/djb/manpages/'
FILE_DAEMONTOOLS='daemontools-0.76-man'
DIR_DAEMONTOOLS='daemontools-man'
FILE_UCSPI_TCP='ucspi-tcp-0.88-man'
DIR_UCSPI_TCP='ucspi-tcp-0.88-man'
# }}}
################################################################################
# function
################################################################################
# {{{
download () {
# {{{
mkdir -p $SRC_DIR/tar
cd $SRC_DIR/tar
wget http://cr.yp.to/daemontools/daemontools-$VERSION_DAEMONTOOLS.tar.gz
wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-$VERSION_UCSPI_TCP.tar.gz
# man
wget $URL_DJBMAN/$FILE_DAEMONTOOLS.tar.gz
wget $URL_DJBMAN/$FILE_UCSPI_TCP.tar.gz
# mkdir $SRC_DIR/tar/patches
# cd $SRC_DIR/tar/patches
# wget --timeout=30 http://pub.kaone.net/public/daemontools-$VERSION_DAEMONTOOLS.errno.patch
# wget --timeout=30 http://pub.kaone.net/public/ucspi-tcp-$VERSION_UCSPI_TCP.a_record.patch
# wget --timeout=30 http://pub.kaone.net/public/ucspi-tcp-$VERSION_UCSPI_TCP.errno.patch
# wget --timeout=30 http://pub.kaone.net/public/ucspi-tcp-$VERSION_UCSPI_TCP.nobase.patch
# }}}
}
is_centos6 () {
# {{{
local DIST=`head -1 /etc/issue | perl -ane 'print $F[0]'`
if [ x$DIST = xCentOS ] ; then
local OS_VERSION=`head -1 /etc/issue | perl -ne '/CentOS\s(?:Linux\s)?release\s([\d]+)[\d\.]*/;print $1'`
if [ $OS_VERSION -ge 6 ] ; then
echo CentOS 6 !
true
return
fi
fi
false
return
# }}}
}
# }}}
########################################
# daemontools
########################################
# {{{
install_daemontools () {
# {{{
mkdir -p $DAEMONTOOLS_DIR
chmod 1755 $DAEMONTOOLS_DIR
cd $DAEMONTOOLS_DIR
tar -xpzf $SRC_DIR/tar/daemontools-$VERSION_DAEMONTOOLS.tar.gz
cd admin/daemontools-$VERSION_DAEMONTOOLS
# patch -p1 < $SRC_DIR/tar/patches/daemontools-$VERSION_DAEMONTOOLS.errno.patch
if [ "$(uname -m)" = "x86_64" ] ; then
patch -p1 <<END
--- admin/src/conf-cc.orig 2001-07-13 01:49:49.000000000 +0900
+++ admin/src/conf-cc 2014-07-24 21:03:51.700700405 +0900
@@ -1,3 +1,3 @@
-gcc -O2 -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings
+gcc -O2 --include /usr/include/errno.h
This will be used to compile .c files.
END
fi
package/install
if is_centos6 ; then
cat > /etc/init/svscan.conf <<END
start on runlevel [2345]
stop on runlevel [S016]
respawn
exec /command/svscanboot
END
fi
# man
cd $SRC_DIR/tar
tar xzf $FILE_DAEMONTOOLS.tar.gz
cd $DIR_DAEMONTOOLS
for NUM in 1 2 3 4 5 6 7 8
do
gzip -f *.$NUM && cp *.$NUM.gz /usr/share/man/man$NUM/
done
# }}}
}
setup_daemontools () {
return
}
# }}}
########################################
# ucspi_tcp
########################################
# {{{
install_ucspi_tcp () {
# {{{
cd $SRC_DIR
tar -xzf tar/ucspi-tcp-$VERSION_UCSPI_TCP.tar.gz
cd ucspi-tcp-$VERSION_UCSPI_TCP
# patch -p1 < $SRC_DIR/tar/patches/ucspi-tcp-$VERSION_UCSPI_TCP.errno.patch
# patch -p1 < $SRC_DIR/tar/patches/ucspi-tcp-$VERSION_UCSPI_TCP.a_record.patch
# patch -p1 < $SRC_DIR/tar/patches/ucspi-tcp-$VERSION_UCSPI_TCP.nobase.patch
make
make setup check
# man
cd $SRC_DIR/tar
tar xzf $FILE_UCSPI_TCP.tar.gz
cd $DIR_UCSPI_TCP
for NUM in 1 2 3 4 5 6 7 8
do
gzip *.$NUM && cp *.$NUM.gz /usr/share/man/man$NUM/
done
# }}}
}
setup_ucspi_tcp () {
return
}
# }}}
################################################################################
# main
################################################################################
download
if [ x$INSTALL_DAEMONTOOLS == "xy" ] ; then
install_daemontools
setup_daemontools
fi
if [ x$INSTALL_UCSPI_TCP == "xy" ] ; then
install_ucspi_tcp
setup_ucspi_tcp
fi
if is_centos6 ; then
echo 'Delete "SV:123456:respawn:/usr/local/bin/svscanboot" from /etc/inittab by yourself'
fi
#!/bin/sh
ENABLE_IPV6=n
INSTALL_TINYDNS=n
INSTALL_DNSCACHE=y
INSTALL_MAN=n
DNSCACHE_IP="127.0.0.1"
DNSCACHE_ALLOW="127.0.0.1"
DNSCACHE_PATH="/etc/dnscache"
TINYDNS_IP="127.0.0.1"
TINYDNS_PATH="/etc/tinydns"
URL_DJBMAN='http://smarden.org/pape/djb/manpages/'
FILE_DJBDNS='djbdns-1.05-man'
DIR_DJBDNS='djbdns-man'
SRC_DIR=/usr/local/src
getRootIP(){
for NAME in a b c d e f g h i j k l m
do
/usr/local/bin/dnsip $NAME.root-servers.net >> $1
done
}
if ! [ "`which dnsq`" ] ; then
mkdir -p $SRC_DIR/tar
cd $SRC_DIR/tar
wget http://cr.yp.to/djbdns/djbdns-1.05.tar.gz
cd $SRC_DIR
tar zxvf tar/djbdns-1.05.tar.gz
cd djbdns-*
if [ x$ENABLE_IPV6 == 'xy' ] ; then
wget http://www.fefe.de/dns/djbdns-1.05-test19.diff.bz2
bunzip2 djbdns-1.05-test19.diff.bz2
patch -p1 < djbdns-1.05-test19.diff
wget http://www.gentei.org/~yuuji/software/djbdnspatch/djbdns-1.05-ipv6arpa+BSDok-1.diff.gz
gunzip djbdns-1.05-ipv6arpa+BSDok-1.diff.gz
patch -p0 < djbdns-1.05-ipv6arpa+BSDok-1.diff
else
wget http://djbware.csi.hu/patches/djbdns-1.05.errno.patch
patch -p1 < djbdns-1.05.errno.patch
fi
make
make setup
make check
fi
if [ x$INSTALL_DNSCACHE == 'xy' ] ; then
groupadd djbdns
useradd -d /dev/null -g djbdns -s /bin/true dnscache
useradd -d /dev/null -g djbdns -s /bin/true dnslog
/usr/local/bin/dnscache-conf dnscache dnslog $DNSCACHE_PATH $DNSCACHE_IP
rm $DNSCACHE_PATH/root/servers/@
getRootIP "$DNSCACHE_PATH/root/servers/@"
for ALLOW_IP in $DNSCACHE_ALLOW
do
touch $DNSCACHE_PATH/root/ip/$ALLOW_IP
done
ln -s $DNSCACHE_PATH /service/dnscache
fi
if [ x$INSTALL_TINYDNS == 'xy' ] ; then
groupadd djbdns
useradd -d /dev/null -g djbdns -s /bin/true tinydns
useradd -d /dev/null -g djbdns -s /bin/true dnslog
/usr/local/bin/tinydns-conf tinydns dnslog $TINYDNS_PATH $TINYDNS_IP
ln -s $TINYDNS_PATH /service/tinydns
fi
# man
if [ x$INSTALL_MAN == 'xy' ] ; then
cd $SRC_DIR/tar
wget $URL_DJBMAN/$FILE_DJBDNS.tar.gz
tar xzf $FILE_DJBDNS.tar.gz
cd $DIR_DJBDNS
for NUM in 1 2 3 4 5 6 7 8
do
gzip *.$NUM && cp *.$NUM.gz /usr/share/man/man$NUM/
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment