#!/bin/bash #=========================== # UMVIRT LINUX FROM SCRATCH #=========================== # Compilation script. # Network mode. #=========================== # Release: 0.1 # Package: bind #=========================== # DB commit: d35a620850806ab581b32cb34d268a904c9c0a5f # APP commit: #=========================== echo "ULFS Package installation start" echo "===============================" echo "Package: bind" echo "Release: 0.1" echo "checking config file" if [ -f $ULFS_CONFIG_FILE ] then echo "loading config file $ULFS_CONFIG_FILE..." . $ULFS_CONFIG_FILE fi #Creating log directory mkdir -p /var/log/ulfs-packages/bind/ #Saving start timestamp date +%s > /var/log/ulfs-packages/bind/start.time #Going to source directory... cd /sources #Checking dependances... #Checking libcap-pam... if [ ! -f /var/cache/ulfs-packages/libcap-pam ]; then echo "Dependance \"libcap-pam\" not found. Trying to install..."; wget --no-check-certificate https://ulfs.org/linux/packages//0.1/libcap-pam/install -O - | bash if [ ! -f /var/cache/ulfs-packages/libcap-pam ]; then echo "Dependance \"libcap-pam\" is not installed. Exiting..." exit fi fi #Saving downloading timestamp date +%s > /var/log/ulfs-packages/bind/download.time #Downloading source package archive... wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.1/packages/b/bind-9.13.2.tar.gz.md5sum wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.1/packages/b/bind-9.13.2.tar.gz #Checking source package file existance if [ ! -f bind-9.13.2.tar.gz ]; then echo "Error: Can't find bind-9.13.2.tar.gz. Exiting!" exit fi #Checking source package file checksum if [ -f bind-9.13.2.tar.gz.md5sum ]; then MD5=`LANG=C md5sum -c bind-9.13.2.tar.gz.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of bind-9.13.2.tar.gz is wrong. Exiting!" exit fi fi #Saving cleanup timestamp date +%s > /var/log/ulfs-packages/bind/cleanup.time rm -rfv /sources/bind-9.13.2/ #Saving extracting timestamp date +%s > /var/log/ulfs-packages/bind/unpack.time #Extracting tar source package archive with default parameters... tar -xf bind-9.13.2.tar.gz #Checking package directory size after unpack... du -s bind-9.13.2 | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/bind/unpack.size #Going to source package directory... cd bind-9.13.2 #Saving configuration timestamp date +%s > /var/log/ulfs-packages/bind/configure.time #Sleep 1 second sleep 1 #Running configuration script... ./configure --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ --mandir=/usr/share/man \ --enable-threads \ --with-libtool \ --disable-static #Saving build timestamp date +%s > /var/log/ulfs-packages/bind/build.time #Running build script... make #Saving install timestamp date +%s > /var/log/ulfs-packages/bind/install.time #Running install script... cat > ulfs_install.sh << EOIS make install && install -v -m755 -d /usr/share/doc/bind-9.13.2/{arm,misc} && install -v -m644 doc/arm/*.html \ /usr/share/doc/bind-9.13.2/arm && install -v -m644 doc/misc/{dnssec,ipv6,migrat*,options,rfc-compliance,roadmap,sdb} \ /usr/share/doc/bind-9.13.2/misc groupadd -g 20 named && useradd -c "BIND Owner" -g named -s /bin/false -u 20 named && install -d -m770 -o named -g named /srv/named mkdir -p /srv/named && cd /srv/named && mkdir -p dev etc/namedb/{slave,pz} usr/lib/engines var/run/named && mknod /srv/named/dev/null c 1 3 && mknod /srv/named/dev/urandom c 1 9 && chmod 666 /srv/named/dev/{null,urandom} && cp /etc/localtime etc && touch /srv/named/managed-keys.bind rndc-confgen -r /dev/urandom -b 512 > /etc/rndc.conf && sed '/conf/d;/^#/!d;s:^# ::' /etc/rndc.conf > /srv/named/etc/named.conf cat >> /srv/named/etc/named.conf << "EOF" options { directory "/etc/namedb"; pid-file "/var/run/named.pid"; statistics-file "/var/run/named.stats"; }; zone "." { type hint; file "root.hints"; }; zone "0.0.127.in-addr.arpa" { type master; file "pz/127.0.0"; }; // Bind 9 now logs by default through syslog (except debug). // These are the default logging rules. logging { category default { default_syslog; default_debug; }; category unmatched { null; }; channel default_syslog { syslog daemon; // send to syslog's daemon // facility severity info; // only send priority info // and higher }; channel default_debug { file "named.run"; // write to named.run in // the working directory // Note: stderr is used instead // of "named.run" // if the server is started // with the '-f' option. severity dynamic; // log at the server's // current debug level }; channel default_stderr { stderr; // writes to stderr severity info; // only send priority info // and higher }; channel null { null; // toss anything sent to // this channel }; }; EOF cat > /srv/named/etc/namedb/pz/127.0.0 << "EOF" \$TTL 3D @ IN SOA ns.local.domain. hostmaster.local.domain. ( 1 ; Serial 8H ; Refresh 2H ; Retry 4W ; Expire 1D) ; Minimum TTL NS ns.local.domain. 1 PTR localhost. EOF cat > /srv/named/etc/namedb/root.hints << "EOF" . 6D IN NS A.ROOT-SERVERS.NET. . 6D IN NS B.ROOT-SERVERS.NET. . 6D IN NS C.ROOT-SERVERS.NET. . 6D IN NS D.ROOT-SERVERS.NET. . 6D IN NS E.ROOT-SERVERS.NET. . 6D IN NS F.ROOT-SERVERS.NET. . 6D IN NS G.ROOT-SERVERS.NET. . 6D IN NS H.ROOT-SERVERS.NET. . 6D IN NS I.ROOT-SERVERS.NET. . 6D IN NS J.ROOT-SERVERS.NET. . 6D IN NS K.ROOT-SERVERS.NET. . 6D IN NS L.ROOT-SERVERS.NET. . 6D IN NS M.ROOT-SERVERS.NET. A.ROOT-SERVERS.NET. 6D IN A 198.41.0.4 A.ROOT-SERVERS.NET. 6D IN AAAA 2001:503:ba3e::2:30 B.ROOT-SERVERS.NET. 6D IN A 192.228.79.201 B.ROOT-SERVERS.NET. 6D IN AAAA 2001:500:200::b C.ROOT-SERVERS.NET. 6D IN A 192.33.4.12 C.ROOT-SERVERS.NET. 6D IN AAAA 2001:500:2::c D.ROOT-SERVERS.NET. 6D IN A 199.7.91.13 D.ROOT-SERVERS.NET. 6D IN AAAA 2001:500:2d::d E.ROOT-SERVERS.NET. 6D IN A 192.203.230.10 E.ROOT-SERVERS.NET. 6D IN AAAA 2001:500:a8::e F.ROOT-SERVERS.NET. 6D IN A 192.5.5.241 F.ROOT-SERVERS.NET. 6D IN AAAA 2001:500:2f::f G.ROOT-SERVERS.NET. 6D IN A 192.112.36.4 G.ROOT-SERVERS.NET. 6D IN AAAA 2001:500:12::d0d H.ROOT-SERVERS.NET. 6D IN A 198.97.190.53 H.ROOT-SERVERS.NET. 6D IN AAAA 2001:500:1::53 I.ROOT-SERVERS.NET. 6D IN A 192.36.148.17 I.ROOT-SERVERS.NET. 6D IN AAAA 2001:7fe::53 J.ROOT-SERVERS.NET. 6D IN A 192.58.128.30 J.ROOT-SERVERS.NET. 6D IN AAAA 2001:503:c27::2:30 K.ROOT-SERVERS.NET. 6D IN A 193.0.14.129 K.ROOT-SERVERS.NET. 6D IN AAAA 2001:7fd::1 L.ROOT-SERVERS.NET. 6D IN A 199.7.83.42 L.ROOT-SERVERS.NET. 6D IN AAAA 2001:500:9f::42 M.ROOT-SERVERS.NET. 6D IN A 202.12.27.33 M.ROOT-SERVERS.NET. 6D IN AAAA 2001:dc3::35 EOF EOIS USER=`whoami` if [ "$USER" == "root" ] ; then cat ulfs_install.sh | bash 2>&1 | tee /var/log/ulfs-packages/bind/install.log else cat ulfs_install.sh | sudo bash 2>&1 | tee /var/log/ulfs-packages/bind/install.log fi #Saving finish timestamp date +%s > /var/log/ulfs-packages/bind/finish.time #Checking package directory size after unpack... cd /sources du -s bind-9.13.2 | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/bind/install.size echo "ULFS package installation completed." #Producing files list echo "Looking for installed files..." if [ -f /var/log/ulfs-packages/bind/files.txt ]; then rm /var/log/ulfs-packages/bind/files.txt fi USER=`whoami` if [ "$USER" == "root" ] ; then find /bin -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt find /sbin -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt find /usr -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt find /etc -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt find /opt -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt find /lib -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt find /lib64 -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt find /var -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time \! -path "/var/log/ulfs-packages/bind/*" >> /var/log/ulfs-packages/bind/files.txt else sudo find /bin -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt sudo find /sbin -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt sudo find /usr -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt sudo find /etc -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt sudo find /opt -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt sudo find /lib -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt sudo find /lib64 -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time >> /var/log/ulfs-packages/bind/files.txt sudo find /var -type f -newer /var/log/ulfs-packages/bind/configure.time \! -newer /var/log/ulfs-packages/bind/finish.time \! -path "/var/log/ulfs-packages/bind/*" >> /var/log/ulfs-packages/bind/files.txt fi #Marking package as installed... mkdir -p /var/cache/ulfs-packages USER=`whoami` if [ "$USER" == "root" ] ; then touch /var/cache/ulfs-packages/bind touch /var/cache/ulfs-packages/bind else sudo touch /var/cache/ulfs-packages/bind sudo touch /var/cache/ulfs-packages/bind fi #Calculate delta size a=`cat /var/log/ulfs-packages/bind/unpack.size` b=`cat /var/log/ulfs-packages/bind/install.size` c=$(($b-$a)) echo $c > /var/log/ulfs-packages/bind/delta.size #Calculate prepare time a=`cat /var/log/ulfs-packages/bind/start.time` b=`cat /var/log/ulfs-packages/bind/configure.time` dp=$(($b-$a)) #Calculate download time a=`cat /var/log/ulfs-packages/bind/download.time` b=`cat /var/log/ulfs-packages/bind/unpack.time` dd=$(($b-$a)) #Calculate delta time a=`cat /var/log/ulfs-packages/bind/configure.time` b=`cat /var/log/ulfs-packages/bind/finish.time` db=$(($b-$a)) echo $db > /var/log/ulfs-packages/bind/delta.time #Report echo "" echo "ULFS Package installation report" echo "================================" echo "Package: bind" echo "Release: 0.1" echo "Build size: $c" echo "Prepare time: $dp sec." echo "Download time: $dd sec." echo "Build time: $db sec." #End of script