#!/bin/bash #=========================== # UMVIRT LINUX FROM SCRATCH #=========================== # Compilation script. # Network mode. #=========================== # Release: 0.2.3 # Package: kea #=========================== # DB commit: 9479b41c328304e88d8b007b04bc0dff783bbc6e # APP commit: b0e7f121177a769c20a4c985867d650259b096ce #=========================== echo "ULFS Package installation start" echo "===============================" echo "Package: kea" echo "Release: 0.2.3" downloadFile() { local filename=$1 echo "Downloading $filename ..." if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl -k -O $filename else wget --no-check-certificate -nc $filename fi } echo "loading environment settings(profile)" . /etc/profile 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/kea/ #Saving start timestamp date +%s > /var/log/ulfs-packages/kea/start.time #Going to source directory... cd /sources #Checking dependances... #Checking krb5... if [ ! -f /var/cache/ulfs-packages/krb5 ]; then echo "Dependance \"krb5\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/krb5/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/krb5/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/krb5 ]; then echo "Dependance \"krb5\" is not installed. Exiting..." exit fi fi #Checking boost... if [ ! -f /var/cache/ulfs-packages/boost ]; then echo "Dependance \"boost\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/boost/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/boost/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/boost ]; then echo "Dependance \"boost\" is not installed. Exiting..." exit fi fi #Checking mariadb-client... if [ ! -f /var/cache/ulfs-packages/mariadb-client ]; then echo "Dependance \"mariadb-client\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/mariadb-client/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/mariadb-client/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/mariadb-client ]; then echo "Dependance \"mariadb-client\" is not installed. Exiting..." exit fi fi #Checking postgresql-client... if [ ! -f /var/cache/ulfs-packages/postgresql-client ]; then echo "Dependance \"postgresql-client\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/postgresql-client/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/postgresql-client/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/postgresql-client ]; then echo "Dependance \"postgresql-client\" is not installed. Exiting..." exit fi fi #Checking valgrind... if [ ! -f /var/cache/ulfs-packages/valgrind ]; then echo "Dependance \"valgrind\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/valgrind/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/valgrind/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/valgrind ]; then echo "Dependance \"valgrind\" is not installed. Exiting..." exit fi fi #Checking log4cplus... if [ ! -f /var/cache/ulfs-packages/log4cplus ]; then echo "Dependance \"log4cplus\" not found. Trying to install..."; if [[ "$ULFS_DOWNLOAD_APP" == "curl" ]]; then curl https://umvirt.com/linux/packages//0.2.3/log4cplus/install -k | bash else wget --no-check-certificate https://umvirt.com/linux/packages//0.2.3/log4cplus/install -O - | bash fi if [ ! -f /var/cache/ulfs-packages/log4cplus ]; then echo "Dependance \"log4cplus\" is not installed. Exiting..." exit fi fi #Saving downloading timestamp date +%s > /var/log/ulfs-packages/kea/download.time #Downloading source package archive... downloadFile https://umvirt.com/linux/downloads/0.2.3/packages/k/kea-2.6.1.tar.gz.md5sum downloadFile https://umvirt.com/linux/downloads/0.2.3/packages/k/kea-2.6.1.tar.gz #Checking source package file existance if [ ! -f kea-2.6.1.tar.gz ]; then echo "Error: Can't find kea-2.6.1.tar.gz. Exiting!" exit fi #Checking source package file checksum if [ -f kea-2.6.1.tar.gz.md5sum ]; then MD5=`LANG=C md5sum -c kea-2.6.1.tar.gz.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of kea-2.6.1.tar.gz is wrong. Exiting!" exit fi fi #Downloadning patches... downloadFile https://umvirt.com/linux/downloads/0.2.3/patches/kea-2.6.1-fix_boost_1_87-1.patch #Saving cleanup timestamp date +%s > /var/log/ulfs-packages/kea/cleanup.time rm -rfv /sources/kea-2.6.1/ #Saving extracting timestamp date +%s > /var/log/ulfs-packages/kea/unpack.time #Extracting tar source package archive with default parameters... tar -xf kea-2.6.1.tar.gz #Checking package directory size after unpack... du -s kea-2.6.1 | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/kea/unpack.size #Going to source package directory... cd kea-2.6.1 #Applying patches... patch -Np1 -i ../kea-2.6.1-fix_boost_1_87-1.patch #Saving configuration timestamp date +%s > /var/log/ulfs-packages/kea/configure.time #Sleep 1 second sleep 1 if [[ "$ULFS_PKG_DATERESET" == "YES" ]] then #Changing all files creation time (except build configuration files) in source directory to find them after installation find /sources/kea-2.6.1 \! -path "*/configure*" \! -path "*/Makefile*" \! -path "*.make" \! -path "*.m4" \! -path "*.am" \! -path "*.mk" \! -path "*.stamp" \! -path "*gentpl.py" -exec touch -m {} + fi #Running configuration script... echo "loading environment settings(profile)" . /etc/profile echo "checking config file" if [ -f $ULFS_CONFIG_FILE ] then echo "loading config file $ULFS_CONFIG_FILE..." . $ULFS_CONFIG_FILE fi cat > ulfs_configure.sh << EOIS echo "Initializing distributed build environment... " if [[ "\$ULFS_ICECC" == "YES" ]] then export PATH="\$ULFS_ICECC_PATH:\$PATH" echo "ICECC" fi echo "Environment debug..." echo "PATH: \$PATH" echo "MAKEFLAGS: \$MAKEFLAGS" echo "NINJAJOBS: \$NINJAJOBS" env | grep ULFS ./configure --prefix=/usr \\ --sysconfdir=/etc \\ --localstatedir=/var \\ --enable-shell \\ --with-openssl \\ --disable-static \\ --with-pgsql \\ --with-mysql \\ --docdir=/usr/share/doc/kea-2.6.1 EOIS cat ulfs_configure.sh | bash 2>&1 | tee /var/log/ulfs-packages/kea/configure.log #Saving build timestamp date +%s > /var/log/ulfs-packages/kea/build.time #Running build script... echo "loading environment settings(profile)" . /etc/profile echo "checking config file" if [ -f $ULFS_CONFIG_FILE ] then echo "loading config file $ULFS_CONFIG_FILE..." . $ULFS_CONFIG_FILE fi cat > ulfs_build.sh << EOIS echo "Initializing distributed build environment... " if [[ "\$ULFS_ICECC" == "YES" ]] then export PATH="\$ULFS_ICECC_PATH:\$PATH" echo "ICECC" fi echo "Environment debug..." echo "PATH: \$PATH" echo "MAKEFLAGS: \$MAKEFLAGS" echo "NINJAJOBS: \$NINJAJOBS" env | grep ULFS make EOIS cat ulfs_build.sh | bash 2>&1 | tee /var/log/ulfs-packages/kea/build.log #Saving install timestamp date +%s > /var/log/ulfs-packages/kea/install.time #Running install script... cat > ulfs_install.sh << EOIS make -j1 install cat > /etc/kea/kea-ctrl-agent.conf << "EOF" // Begin /etc/kea/kea-ctrl-agent.conf { // This is a basic configuration for the Kea Control Agent. // RESTful interface to be available at http://127.0.0.1:8000/ "Control-agent": { "http-host": "127.0.0.1", "http-port": 8000, "control-sockets": { "dhcp4": { "socket-type": "unix", "socket-name": "/run/kea4-ctrl-socket" }, "dhcp6": { "socket-type": "unix", "socket-name": "/run/kea6-ctrl-socket" }, "d2": { "socket-type": "unix", "socket-name": "/run/kea-ddns-ctrl-socket" } }, "loggers": [ { "name": "kea-ctrl-agent", "output_options": [ { "output": "/var/log/kea-ctrl-agent.log", "pattern": "%D{%Y-%m-%d %H:%M:%S.%q} %-5p %m\\n" } ], "severity": "INFO", "debuglevel": 0 } ] } } // End /etc/kea/kea-ctrl-agent.conf EOF cat > /etc/kea/kea-dhcp4.conf << "EOF" // Begin /etc/kea/kea-dhcp4.conf { "Dhcp4": { // Add names of your network interfaces to listen on. "interfaces-config": { "interfaces": [ "eth0", "eth2" ] }, "control-socket": { "socket-type": "unix", "socket-name": "/run/kea4-ctrl-socket" }, "lease-database": { "type": "memfile", "lfc-interval": 3600 }, "expired-leases-processing": { "reclaim-timer-wait-time": 10, "flush-reclaimed-timer-wait-time": 25, "hold-reclaimed-time": 3600, "max-reclaim-leases": 100, "max-reclaim-time": 250, "unwarned-reclaim-cycles": 5 }, "renew-timer": 900, "rebind-timer": 1800, "valid-lifetime": 3600, // Enable DDNS - Kea will dynamically update the DNS "ddns-send-updates" : true, "ddns-qualifying-suffix": "your.domain.tld", "dhcp-ddns" : { "enable-updates": true }, "subnet4": [ { "id": 1001, // Each subnet requires a unique numeric id "subnet": "192.168.56.0/24", "pools": [ { "pool": "192.168.56.16 - 192.168.56.254" } ], "option-data": [ { "name": "domain-name", "data": "your.domain.tld" }, { "name": "domain-name-servers", "data": "192.168.56.2, 192.168.3.7" }, { "name": "domain-search", "data": "your.domain.tld" }, { "name": "routers", "data": "192.168.56.2" } ] } ], "loggers": [ { "name": "kea-dhcp4", "output_options": [ { "output": "/var/log/kea-dhcp4.log", "pattern": "%D{%Y-%m-%d %H:%M:%S.%q} %-5p %m\\n" } ], "severity": "INFO", "debuglevel": 0 } ] } } // End /etc/kea/kea-dhcp4.conf EOF cat > /etc/kea/kea-dhcp-ddns.conf << "EOF" // Begin /etc/kea/kea-dhcp-ddns.conf { "DhcpDdns": { "ip-address": "127.0.0.1", "port": 53001, "control-socket": { "socket-type": "unix", "socket-name": "/run/kea-ddns-ctrl-socket" }, "tsig-keys": [ { "name" : "rndc-key", "algorithm" : "hmac-sha256", "secret" : "1FU5hD7faYaajQCjSdA54JkTPQxbbPrRnzOKqHcD9cM=" } ], "forward-ddns" : { "ddns-domains" : [ { "name" : "your.domain.tld.", "key-name": "rndc-key", "dns-servers" : [ { "ip-address" : "127.0.0.1", "port" : 53 } ] } ] }, "reverse-ddns" : { "ddns-domains" : [ { "name" : "56.168.192.in-addr.arpa.", "key-name": "rndc-key", "dns-servers" : [ { "ip-address" : "127.0.0.1", "port" : 53 } ] } ] }, "loggers": [ { "name": "kea-dhcp-ddns", "output_options": [ { "output": "/var/log/kea-ddns.log", "pattern": "%D{%Y-%m-%d %H:%M:%S.%q} %-5p %m\\n" } ], "severity": "INFO", "debuglevel": 0 } ] } } // End /etc/kea/kea-dhcp-ddns.conf EOF EOIS echo "/sbin/ldconfig" >> ulfs_install.sh USER=`whoami` if [ "$USER" == "root" ] ; then cat ulfs_install.sh | bash 2>&1 | tee /var/log/ulfs-packages/kea/install.log else cat ulfs_install.sh | sudo bash 2>&1 | tee /var/log/ulfs-packages/kea/install.log fi #Saving finish timestamp date +%s > /var/log/ulfs-packages/kea/finish.time #Checking package directory size after unpack... cd /sources du -s kea-2.6.1 | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/kea/install.size echo "ULFS package installation completed." #Producing files list echo "Looking for installed files..." if [ -f /var/log/ulfs-packages/kea/files.txt ]; then rm /var/log/ulfs-packages/kea/files.txt fi USER=`whoami` if [ "$USER" == "root" ] ; then find /bin -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /sbin -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /usr -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /etc -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time \! -path /etc/ld.so.cache >> /var/log/ulfs-packages/kea/files.txt find /opt -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /lib -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /lib64 -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt find /var -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time \! -path "/var/log/ulfs-packages/kea/*" \! -path /var/cache/ldconfig/aux-cache >> /var/log/ulfs-packages/kea/files.txt else sudo find /bin -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /sbin -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /usr -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /etc -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time \! -path /etc/ld.so.cache >> /var/log/ulfs-packages/kea/files.txt sudo find /opt -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /lib -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /lib64 -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time >> /var/log/ulfs-packages/kea/files.txt sudo find /var -type f -newer /var/log/ulfs-packages/kea/configure.time \! -newer /var/log/ulfs-packages/kea/finish.time \! -path "/var/log/ulfs-packages/kea/*" \! -path /var/cache/ldconfig/aux-cache >> /var/log/ulfs-packages/kea/files.txt fi #Marking package as installed... mkdir -p /var/cache/ulfs-packages USER=`whoami` if [ "$USER" == "root" ] ; then touch /var/cache/ulfs-packages/kea else sudo touch /var/cache/ulfs-packages/kea fi #Calculate delta size a=`cat /var/log/ulfs-packages/kea/unpack.size` b=`cat /var/log/ulfs-packages/kea/install.size` c=$(($b-$a)) echo $c > /var/log/ulfs-packages/kea/delta.size #Calculate prepare time a=`cat /var/log/ulfs-packages/kea/start.time` b=`cat /var/log/ulfs-packages/kea/configure.time` dp=$(($b-$a)) #Calculate download time a=`cat /var/log/ulfs-packages/kea/download.time` b=`cat /var/log/ulfs-packages/kea/unpack.time` dd=$(($b-$a)) #Calculate delta time a=`cat /var/log/ulfs-packages/kea/configure.time` b=`cat /var/log/ulfs-packages/kea/finish.time` db=$(($b-$a)) echo $db > /var/log/ulfs-packages/kea/delta.time #Report echo "" echo "ULFS Package installation report" echo "================================" echo "Package: kea" echo "Release: 0.2.3" echo "Build size: $c" echo "Prepare time: $dp sec." echo "Download time: $dd sec." echo "Build time: $db sec." #End of script